拆分 Netcdf 变量并重新写入文件

Split Netcdf variable and re-write the file

我有一个包含空气质量数据的 netcdf 文件。有 4 个维度:

time : 24 hours (midnight to midnight) 
level : 1 to 8 (this is the height in meters (0, 50, 250, 500, 1000, 2000, 3000, 5000 m)) 
latitude : 1 to 400
longitude : 1 to 700

我想新建一个netcdf文件,只保留level 1,删除其他level,因为我只需要surface。

我该怎么做?

我尝试使用 nccopy 命令行执行此操作,但它重现了数据集。我不知道如何删除其他级别。

您可以使用 NCO 进行 hyperslab,例如,

ncks -d level,0 in.nc out.nc

如果您还没有 NCO,但有 conda,请使用

安装 NCO
conda install -c conda-forge nco

您可以使用

在 cdo 中执行此操作
cdo sellevel,lev in.nc out.nc

选择用户给定列表中所需级别的所有字段,或

cdo sellevidx,idx in.nc out.nc

允许您 select 按级别索引代替。此处有更多详细信息:

https://code.mpimet.mpg.de/projects/cdo/embedded/index.html#x1-1360002.3.3