- 积分
- 35958
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-5-13
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 一大碗年糕 于 2023-7-25 00:18 编辑
试了下geocat的month_to_season(原ncl month_to_season)函数,与自己计算的两种重考虑权重的月平均均有差异。说明该函数确实没考虑不同月天数的权重,与考虑权重时的误差在E-2,如果不在意这点误差可以考虑使用
- ### gc ###
- gc_ds = gc.climatologies.month_to_season(ds.sel(time=slice("1940","2022")),"JJA")
- ### weighted ###
- ds_season = ds.groupby('time.season')['JJA']
- month_length = ds_season.time.dt.days_in_month
- month_length
- # 按“ time.season”分组来计算权重。
- weights = month_length.groupby('time.season')['JJA'].groupby('time.year') / month_length.groupby('time.season')['JJA'].groupby('time.year').sum()
- weights
- # 计算加权平均值
- ds_season_weighted = (ds_season * weights).groupby('time.year').sum(dim='time')
复制代码
|
|