问题描述
我有一个 NetCDF 文件,其中包含许多变量(1d、2d、3d 和 4d).我想为 3d 变量之一添加一个新维度.
I have a NetCDF file which include lots of variables (1d, 2d, 3d, and 4d). I want to add a new dimension to one of the 3d variables.
为了更清楚,假设:
我有一个 3d 变量:A(d1, d2, d3)
I have a 3d variable: A(d1, d2, d3)
我想要 4d 变量:A(d1, d2, d3, d4)
I want to have 4d variable: A(d1, d2, d3, d4)
事实上,d4 是我想添加到我的变量中的新维度.我的文件中没有 d4.我知道它只有一个值.
In fact, d4 is the new dimension which I would like to add to my variable. I do not have d4 in my file. I know it has just one value.
如果有人指导我,我将不胜感激.
I would appreciate that if anyone guide me.
推荐答案
使用 NCO:
ncap2 -s 'defdim("d4",737);A_new[$d1,$d2,$d3,$d4]=A' in.nc out.nc
ncap2 -s 'defdim("d4",737);A_new[$d1,$d2,$d3,$d4]=A' in.nc out.nc
这篇关于为 netCDF 文件中的变量之一定义新维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!