import xarray as xr import matplotlib.pyplot as plt if __name__=='__main__': ds=xr.open_dataset(r'D:\pythonsx\zl\sst.mnmean.nc') sst=ds['sst'] sstsel=sst.loc[:,5:-5,190:240] #5°S-5°N,170°W-120°W enso=sstsel.mean(dim=['lat', 'lon'])#区域平均 ensom=enso.mean('time') #print(ensom) ensoa=enso-ensom #print(ensoa)修改这段代码,筛选出大于0.5的年份
时间: 2023-06-14 09:05:06 浏览: 129
wrfout文件变量提取.zip_equipment5rq_ncl_python wrf 库_wrf.out 格式_wrfout
5星 · 资源好评率100%
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
if __name__=='__main__':
ds=xr.open_dataset(r'D:\pythonsx\zl\sst.mnmean.nc')
sst=ds['sst']
sstsel=sst.loc[:,5:-5,190:240] #5°S-5°N,170°W-120°W
enso=sstsel.mean(dim=['lat', 'lon'])#区域平均
ensom=enso.mean('time')
ensoa=enso-ensom
# Modified code to filter out years with values greater than 0.5
enso_yearly = ensoa.resample(time="Y").mean()
enso_yearly = enso_yearly.dropna(dim="time")
enso_yearly = enso_yearly.where(enso_yearly > 0.5, drop=True)
print(enso_yearly)
阅读全文