【问题标题】:calculating some seasonal climate metrics with Iris使用 Iris 计算一些季节性气候指标
【发布时间】:2020-12-15 18:49:45
【问题描述】:

我有一个新项目,计算一些季节性气候指标。作为其中的一部分,我需要确定一组气候月度数据中最潮湿的季度:

print(pr_cube)
 
Precipitation / (mm)                (time: 12; latitude: 125; longitude: 211) 
     Dimension coordinates:
          time                           x             -               -
          latitude                       -             x               -
          longitude                      -             -               x
 

其中时间是每个月,用 coord('time) = 30 年的平均值

DimCoord([2030-01-01 00:00:00, 2030-02-01 00:00:00, 2030-03-01 00:00:00, 
       2030-04-01 00:00:00, 2030-05-01 00:00:00, 2030-06-01 00:00:00,
       2030-07-01 00:00:00, 2030-08-01 00:00:00, 2030-09-01 00:00:00,
       2030-10-01 00:00:00, 2030-11-01 00:00:00, 2030-12-01 00:00:00]

我想知道是否可以为所有连续 3 个月的集合添加季节坐标,包括“环绕”,如下所示:

iris.coord_categorisation.add_season(cube, coord, name='season', 
       seasons=(''jfm', 'fma', 'mam', 'amj', 'mjj', 'jja', 'jas', 'aso', 'son', 'ond', 'ndj', 'djf'))
   

season = ('jfm', 'fma', 'mam', 'amj', 'mjj', 'jja', 'jas', 'aso', 'son', 'ond', 'ndj', 'djf')
iris.coord_categorisation.add_season_membership(cube, coord, season, name='all_quarters')
 

尚未对此进行测试,只是想知道是否有建议或建议?

然后,获得最大降雨量的季节?

Qtr_max_rain = pr_cube.collapsed('season', iris.analysis.MAX)

这样可以正常工作吗?

【问题讨论】:

    标签: python-iris


    【解决方案1】:

    可能有一种方法可以使用coord_categorisation 来实现这一点,但我相信最简单的方法是使用iris.cube.Cube.rolling_window()。没有本地方法可以按照您需要的方式进行环绕,因此您可以通过在现有数据的末尾复制 Jan 和 Feb 来破解它。

    我已经测试了以下内容,它似乎按预期工作。希望它对你有用。

    # Create extra cube based on Jan and Feb from pr_cube.
    extra_months_cube = pr_cube[:2, ...]
    # Replace time coordinate with another that is advanced by a year - ensures correct sorting.
    # Adjust addition depending on the unit of the time coordinate.
    extra_months_coord = extra_months_cube.coord("time") + (24 * 365)
    extra_months_cube.remove_coord("time")
    extra_months_cube.add_dim_coord(extra_months_coord, 0)
    
    # Combine original cube with extra cube.
    both_cubes = iris.cube.CubeList([pr_cube, extra_months_cube])
    fourteen_month_cube = both_cubes.concatenate_cube()
    
    # Generate cube of 3-month MAX aggregations.
    rolling_cube = fourteen_month_cube.rolling_window("time", iris.analysis.MAX, 3)
    

    完成后,您当然可以使用 iris.cube.Cube.add_aux_coord() 添加建议的三个月标签。

    【讨论】:

      猜你喜欢
      • 2021-12-20
      • 2021-06-29
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 2018-08-24
      • 1970-01-01
      • 2019-05-20
      • 2020-01-31
      相关资源
      最近更新 更多