python/iris を使用して、毎日のデータから年間の極値を取得しています。私aggregated_by('season_year', iris.analysis.MIN)
は極端な値を取得するために使用しますが、毎年いつ発生するかも知る必要があります。私は以下のコードを書きましたが、これは非常に遅いので、組み込みのiris
方法を誰かが知っているか、より効率的な別の方法を考えられるかどうか疑問に思っています。
ありがとうございました!
#--- get daily data
cma = iris.load_cube('daily_data.nc')
#--- get annual extremes
c_metric = cma.aggregated_by('season_year', iris.analysis.MIN)
#--- add date of when the extremes are occurring
extrdateli=[]
#loop over all years
for mij in range(c_metric.data.shape[0]):
#
# get extreme value
m = c_metric.data[mij]
#
#get values for this year
cma_thisseasyr = cma.extract(iris.Constraint(season_year=lambda season_year:season_year==c_metric.coord('season_year').points[mij]))
#
#get date in data cube for when this extreme occurs and print add as string to a list
extradateli += [ str(c_metric.coord('season_year').points[mij])+':'+','.join([''.join(_) for _ in zip([str(_) for _ in cma_thisseasyr.coord('day').points[np.where(cma_thisseasyr.data==m)]], [str(_) for _ in cma_thisseasyr.coord('month').points[np.where(cma_thisseasyr.data==m)]], [str(_) for _ in cma_thisseasyr.coord('year').points[np.where(cma_thisseasyr.data==m)]])])]
#add this list to the metric cube as attribute
c_metric.attributes['date_of_extreme_value'] = ' '.join(extrdateli)
#--- save to file
iris.save('annual_min.nc')