我试图在xarray教程数据集中添加霜冻天数。在
airtemps = xr.tutorial.load_dataset('air_temperature')
# The set spans more than a year, let's take only one
airtemps = airtemps.sel(time=slice('2013-01-01', '2013-12-31'))
airtemps['air'] = airtemps.air - 273.15
数据是相当高分辨率的时间明智的,所以为了更容易处理,我重新取样 航空日=空气温度重采样('1D','time',how='mean') air_month=空气_日重采样('1M','time',how='mean')
因此,我希望在air_month
中有一个额外的变量,在所有三个维度上,平均天数都在零以下。在
我最天真的尝试就是这样
^{pr2}$然而,通过sum()
,我在这里失去了时间维度。我被困在这里,还没有把xarray的概念包装在我的头上。在
谢谢你的帮助!在
你快到了! 你的groupby非常相似(而且在某些方面更好,因为xarray的重采样还不是groupby)
相关问题 更多 >
编程相关推荐