我有一个netCDF文件FORCING.nc,其中包含一个带有属性值units: hours since 2007-12-28 22:00:00的变量time。在python代码中,如下所示:
from netCDF4 import Dataset
Dataset('FORCING.nc')["time"]产出如下:
Out[3]:
<class 'netCDF4._netCDF4.Variable'>
float32 time(time)
units: hours since 2007-12-28 22:00:00
unlimited dimensions:
current shape = (13,)
filling on, default _FillValue of 9.969209968386869e+36 used我想将units的属性从hours since 2007-12-28 22:00:00更改为hours since 1996-01-01 22:00:00。1996-01-01 22:00:00来自bash脚本中的变量$start_date。
所以我想用这样的方法:
ncatted -a units,time,o,c,'hours since '$start_date FORCING.nc它将参数'hours since '+$start_date提供给随后捕获的命令,实际上它是'hours since 1996-01-01 22:00:00'。但我收到的错误信息如下:
ncatted: ERROR file start_date not found. It does not exist on the local filesystem, nor does it match remote filename patterns (e.g., http://foo or foo.bar.edu:file).
ncatted: HINT file-not-found errors usually arise from filename typos, incorrect paths, missing files, or capricious gods. Please verify spelling and location of requested file. If the file resides on a High Performance Storage System (HPSS) accessible via the 'hsi' command, then add the --hpss option and re-try command.我想是因为“2007-12-28小时”和"22:00:00“之间有空隙。如果我使用ncatted -a units,time,o,c,'hours since 2007-12-28 22:00:00' FORCING.nc,它可以正常工作。但是我如何使用$start_date呢?因为每次运行代码时start_date都是不同的.
谢谢!
发布于 2022-04-10 00:04:44
你快到了!试一试
ncatted -a units,time,o,c,'hours since '"$start_date" FORCING.nc空壳引用规则。不能和他们生活在一起,没有他们就活不下去。
https://stackoverflow.com/questions/71809330
复制相似问题