从 4d NetCDF 文件中提取海底数据

Extracting ocean bottom data from 4d NetCDF files

我有海洋 pH 值、o2 等的全球 4D NetCDF 文件。每个文件都有 1 个变量和 4 个维度(时间、经度、纬度和深度)。我希望从不包含 NA 的每个单元格的最底部深度提取数据。我试过将 NCO 的 ncks 与负 hyperslab 一起使用:

ncks -d depth,-1 in.nc out.nc

但是,这只为我提供了最深深度箱(即 -5700 米深度箱)的数据,为所有较浅的海洋区域输出 NaN。有没有办法以类似的方式提取数据,但指定我想要每个单元格的最深非 NaN 值?

我可以使用 R、CDO 或 NCO。提前感谢您提供的任何帮助。

如果您能够 运行 一个简单的 Python 脚本,您可以使用 nctoolkit (https://nctoolkit.readthedocs.io/en/latest/installing.html) 执行此操作,它使用 CDO 作为后端。对于一个文件,您将执行以下操作:

import nctoolkit as nc
data = nc.open_data("infile.nc")
bottom = nc.open_data("infile.nc")
bottom.bottom_mask()
data.multiply(bottom)
data.vertical_sum()
data.to_nc("outfile.nc")