如何在 xarray 中以 JJAS 而不是 JJA 的形式获得季节?

How to get season as JJAS instead of JJA in xarray?

如何在计算季节性平均值而不是 JJA 时在 xarray 中获取季风月份 (JJAS)?

import xarray as xr
fname='/home/krishna/SIMS/P1/*.nc'
ds=xr.open_mfdataset(fname)
temp=ds.temp
sea_temp=temp.groupby('time.season').mean(dim='time')
sea_temp.plot.imshow(col='season',robust=True)

输出以 JJA 月而不是 JJAS 显示。 如何计算 JJAS 的季节性平均值(6 月至 9 月)

我可以通过如下编写一个函数来解决这个问题

def is_jjas(month):
    return (month >= 6) & (month <= 9)

seasonal_temp = temp.sel(time=is_jjas(temp['time.month']))

我希望这能帮助那些对印度夏季季风季节 (JJAS) 的季节性平均值有同样疑问的人。