如何为这个特殊的netCDF文件提供合适的时间轴?
“时间”作为维度和变量存在, 但是时间变量使用“serial \ date \ number”作为其维度。
有两个挑战: 1.变量与维度问题;和 2.“serial \ date \ number”似乎表示某些系统上的空格(带有反斜杠分隔符),但在其他系统上有下划线(“serial_date_number”)。
netcdf
dimensions:
lon = 80 ;
lat = 41 ;
pres = 27 ;
time = 12053 ;
serial\ date\ number = 12053 ;
variables:
double u_mjo(time, pres, lat, lon) ;
double lon(lon) ;
lon:units = "degrees_east" ;
double lat(lat) ;
lat:units = "degrees_north" ;
double p_level(pres) ;
p_level:units = "hPa" ;
double time(serial\ date\ number) ;
time:units = "days since 0000-01-01 00:00 UTC" ;
...
答案 0 :(得分:2)
以下是对我有用的程序仅使用NCO命令(没有ncdump / manual edit / ncgen步骤):
从OPeNDAP数据集中提取4个时间步骤到本地netCDF文件allfields.nc
:
ncks -d time,0,3 -d serial_date_number,0,3
http://weather.rsmas.miami.edu/repository/opendap/synth:100ae90b-71ac-4d38-add9-f8982a976322:L2FsbGZpZWxkcy5uYw==/entry
-O allfields.nc
将time
变量解压缩到单独的文件time.nc
:
ncks -v time allfields.nc time.nc
将除 {em} time
变量之外的所有提取到单独的文件fixed.nc
(这也会删除有问题的serial_date_number
维度):
ncks -C -x -v time allfields.nc fixed.nc
将维serial_data_number
重命名为time
:
ncrename -O -d serial_date_number,time time.nc
将文件固定时间附加到文件中:
ncks -A time.nc fixed.nc
我在此工作流程中使用和创建的文件可以在此处看到: http://geoport.whoi.edu/thredds/catalog/usgs/data2/rsignell/models/mapes/catalog.html
答案 1 :(得分:0)
将original.nc转换为fixed.nc解决2个挑战的解决方案是(在经过多次争论之后):
# 1. extract time from the original.nc file to create a new file with only time:
ncks -v time original.nc time.nc
# 2. remove the time variable from original.nc (which removes the problematic `serial_date_number dimension`)
ncks -C -x -v time original.nc fixed.nc
#3. Fix the time.nc file manually, with a text editor:
ncdump time.nc > time.txt # dump netCDF to text
## text-edit time.txt to fix up header,
## creating time = UNLIMITED ; // (12053 currently)
ncgen -o newtime.nc < time.txt # remake netCDF from text
# 4. Finally, concatenate the new time variable file into fixed.nc
ncks -A newtime.nc fixed.nc
答案 2 :(得分:0)
On Ubuntu 14.04 I was able to do:
ncrename -v variable\ with\ whitespace,variable_with_whitespace filein.nc fileout.nc