我正在使用大气模型进行理想化实验,输出格式为netcdf。但是netcdf文件头并没有清楚地描述变量和维度。例如:
netcdf qc3d {
dimensions:
Time = UNLIMITED ; // (1453 currently)
bottom_top = 45 ;
south_north = 32 ;
west_east = 12288 ;
variables:
float Time(Time) ;
Time:axis = "Time" ;
Time:long_name = "Time" ;
Time:standard_name = "Time" ;
Time:units = "minutes since 1900-01-01 " ;
double zc(bottom_top) ;
zc:axis = "Z" ;
zc:long_name = "vertical height of model layers, MSL" ;
zc:standard_name = "altitude" ;
zc:units = "m" ;
zc:positive = "up" ;
double yc(south_north) ;
yc:axis = "Y" ;
yc:long_name = "y-coordinate of grid cell centers in Cartesian system" ;
yc:units = "m" ;
double xc(west_east) ;
xc:axis = "X" ;
xc:long_name = "x-coordinate of grid cell centers in Cartesian system" ;
xc:units = "m" ;
float qc(Time, bottom_top, south_north, west_east) ;
qc:long_name = "cloud water mixing ratio" ;
qc:standard_name = "cloud_water_mixing" ;
qc:units = "kg kg-1" ;
qc:_FillValue = 9.96921e+36f ;
qc:missing_value = 9.96921e+36f ;
// global attributes:
:model_tag = "CSU VVM" ;
:references = "http://kiwi.atmos.colostate.edu/pubs/joon-hee-tech_report.pdf" ;
:contact = "jung@atmos.colostate.edu" ;
:institution = "Colorado State University" ;
:VVM_casename = "GATE_PHASE_III " ;
}
有4个维度,时间(时间),zc(bottom_top),yc(south_north),xc(west_east)和5变量,其中前4个变量应该是第五个变量的维度,因此称为qc。但似乎没有。维度只是一个从1到45的序列号索引,32 ......不管怎样。
我想计算一些变量,它是压力的函数。在CDO中,脚本就像这样
cdo expr,"pottemp=temp*((100000/clev(temp))^0.287);" ifile pottemp.nc
(此代码来自here)
但我只是获得了一系列索引,如1,2,3 ......当我使用这个函数时,不是真正的压力级别,clev(qv)。
那么如何重写变量维度,如qc from
qc(Time, bottom_top, south_north, west_east) ;
至
qc(Time, zc, yc, xc) ;
我认为我可以在matlab中完成这个,但我只是不想打开这个数据集,因为它的大小太大了......所以我试图找到一些像ncks或cdo这样的工具,但仍然没有做到此
非常感谢。
答案 0 :(得分:2)
使用NCO尝试
ncap2 -s 'pottemp=temp*((100000/zc)^0.287)' in.nc out.nc
扩展答案以涵盖下面的其他问题:
首先使用ncap2将zc显式设置为ascii文件中的值:
ncap2 -s 'zc[$zc]={1.5,900,2500,3500}' in.nc out.nc
(假设zc是4号尺寸)。然后根据zc定义pottemp。