微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过纬度以 nlat/nlon 格式对 CMIP netCDF 文件进行子集化

如何解决通过纬度以 nlat/nlon 格式对 CMIP netCDF 文件进行子集化

我对 python 和处理 netCDF 文件都很陌生,我一直在尝试按纬度对 CMIP 输出进行子集化。我一直在遵循的所有示例似乎都非常简单,只需根据纬度/经度进行提取即可。

我遇到的问题是,对于我的实验,尺寸采用“nlat”和“nlon”格式(我认为这是纬度数)。到目前为止,我已经发现这可能与网格有关,我需要将它从数组中转换以获得“真实”的纬度和经度(然后我可以对其进行子集化)。

此实验包含海洋叶绿素数据,我的最终目标是能够对实验进行子集化以获得南半球纬度带的平均值。我不是在寻找如何解决这个问题的精确答案,但如果有人有任何关于如何将这个文件转换为处理真实坐标的指示,我会更多。

任何建议将不胜感激。 谢谢!

文件信息的完整转储在这里

Conventions: CF-1.7 CMIP-6.2
activity_id: ScenarioMIP
branch_method: standard
branch_time_in_child: 735110.0
branch_time_in_parent: 735110.0
case_id: 1731
cesm_casename: b.e21.Bssp245cmip6.f09_g17.CMIP6-ssp2-4.5.102
contact: cesm_cmip6@ucar.edu
creation_date: 2020-05-26T19:43:22Z
data_specs_version: 01.00.31
experiment: ssp-based RCP scenario with medium radiative forcing by the end of the century.  Following approximately RCP4.5 global forcing pathway with ssp2 socioeconomic conditions. Radiative forcing reaches a level of 4.5 W/m2 in 2100. Concentration-driven.
experiment_id: ssp245
external_variables: areacello volcello
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.ssp245.none.r11i1p1f1
grid: native gx1v7 displaced pole grid (384x320 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research,climate and Global Dynamics Laboratory,1850 Table Mesa Drive,Boulder,CO 80305,USA
institution_id: NCAR
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: historical
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r11i1p1f1
physics_index: 1
product: model-output
realization_index: 11
realm: ocnBgchem
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); ocean: POP2 (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m); sea_ice: CICE5.1 (same grid as ocean); land: CLM5 0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); aerosol: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); atmoschem: MAM4 (0.9x1.25 finite volume grid; 288 x 192 longitude/latitude; 32 levels; top level 2.25 mb); landIce: CISM2.1; ocnBgchem: MARBL (320x384 longitude/latitude; 60 levels; top grid cell 0-10 m)
source_id: CESM2
source_type: AOGCM BGC AER
sub_experiment: none
sub_experiment_id: none
table_id: Omon
tracking_id: hdl:21.14100/2f01427e-7a24-40fe-93a6-88c87923afea
variable_id: chl
variant_info: CMIP6 ssp2-4.5 experiments (2015-2100) with CAM6,interactive land (CLM5),coupled ocean (POP2) with biogeochemistry (MARBL),interactive sea ice (CICE5.1),and non-evolving land ice (CISM2.1).

variant_label: r11i1p1f1
dimensions(sizes): nlat(384),vertices(4),lev(15),time(600),d2(2),nlon(320)
variables(dimensions): float32 chl(time,lev,nlat,nlon),float64 lat(nlat,float64 lev(lev),float64 lon(nlat,int32 nlat(nlat),int32 nlon(nlon),float64 time(time),float64 time_bnds(time,d2),float32 lat_bnds(nlat,nlon,vertices),float32 lon_bnds(nlat,float32 lev_bnds(lev,d2)
groups:

解决方法

解决这个问题的最简单方法是 Python 可能是我的 nctoolkit 包 (https://nctoolkit.readthedocs.io/en/latest/)。您可以使用 xarray 执行此操作,但您需要为每个 CMIP 模型网格修改任何代码。

nctoolkit 使用 CDO 作为后端,应该能够或多或少地处理任何 CMIP 网格,除了使用高度不规则网格的组。但是你提到的那个应该没问题。

如果您想计算南半球的纬度平均值(纬向平均值),您可以执行以下操作:

import nctoolkit as nc
ds = nc.open_data("infile.nc")
ds.crop(lat = [-90,0])
ds.zonal_mean()
# to visualize
ds.plot()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。