简体   繁体   English

如何从 Python 中的每小时数据 netcdf 文件中找到最高日温度?

[英]How to find maximum daily temperature from hourly data netcdf file in Python?

I am trying to find the maximum daily temperature from hourly data (3 hour intervals).我试图从每小时数据(3 小时间隔)中找到每日最高温度。 I am new to netcdf files and python so I'm not sure where to start.我是 netcdf 文件和 python 的新手,所以我不确定从哪里开始。 How would I find the maximum daily value?我如何找到最大的每日价值? Can I use max() for that?我可以使用 max() 吗?

file='air.2m.2018.nc'
ncin = Dataset(file,'r')
#put data into numpy arrays
lons=ncin.variables['lon'][:]
lats=ncin.variables['lat'][:]
lats1=ncin.variables['lat'][:,0]
temp=ncin.variables['air'][:]

time_2018=ncin.variables['time']
dtime = netCDF4.num2date(time_2018[:],time_2018.units)

When I print(dtime) it looks like this:当我打印(dtime)时,它看起来像这样:

 cftime.DatetimeGregorian(2018, 1, 1, 0, 0, 0, 0)
 cftime.DatetimeGregorian(2018, 1, 1, 3, 0, 0, 0)

This should be pretty easy to achieve with xarray:这应该很容易用 xarray 实现:

import xarray as xr
nc = xr.open_dataset('air.2m.2018.nc')
nc.resample(time='1D').max()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python Map Reduce 从每小时数据中查找每个气象站的每日最高、最低、平均和温度变化 - Python Map Reduce to find daily max, min, mean and variance in temperature for each weather station from hourly data 如何从 ERA5 每小时 netCDF 数据计算每日平均值? - How to calculate daily average from ERA5 hourly netCDF data? 每小时数据到每日数据python - Hourly data to daily data python Python:从CSV文件提取每日/每小时余额 - Python: extract daily/hourly balance from a CSV file Python:使用 ffill() 将数据帧从每日数据上采样到每小时数据 - Python: upsampling dataframe from daily to hourly data using ffill() 从python中的每日netcdf文件计算每月平均值 - Calculating monthly mean from daily netcdf file in python 如何使用 Python 从 netcdf 中的每日降雨量数据计算 2、3 和 5 天累积降雨量 - How to compute 2, 3 and 5-days accumulated rainfall from daily rainfall data in netcdf using Python 如何聚合每日温度数据以使用月份作为python字典中的键? - How to aggregate daily temperature data to use the months as keys in a dictionary for python? 熊猫:如何避免从每小时到每天的数据重新采样时发生fillna - Pandas : How to avoid fillna while resampling from hourly to daily data 从每小时数据中找出每天的最大值 - Find maximum value of each day from hourly data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM