iris是否有与cf_xarray resample使用类似的功能mean
?
dataset.cf.resample(T="Y").mean()
虽然不是很优雅,但我找到了一种方法来实现year
:
import iris
import iris.coord_categorisation
def year_mean(dataset):
# 1st step: Create an auxialiary coordinate
iris.coord_categorisation.add_year(dataset, "time", name="year")
# 2nd step: Mean over the auxiliary coordinate
result = dataset.aggregated_by(["year"], iris.analysis.MEAN)
# 3rd step: Fix cell_methods
method = iris.coords.CellMethod('mean', coords=['time'], intervals='1 year')
result.cell_methods = result.cell_methods[:-1]
result.add_cell_method(method)
# 4rd step: Remove the auxiliary coordinate
result.remove_coord("year")
return result
我认为这会产生最多的CF 标准输出。