python - 在 netcdf 文件中将时间轴单位从 "years since"更改为 "days since"

标签 python netcdf nco cdo-climate

我有一个 netcdf 文件,有人传给我,它使用“自 DATE 以来的年数”作为时间单位:

    double time(time) ;
    time:standard_name = "time" ;
    time:long_name = "time" ;
    time:calendar = "proleptic_gregorian" ;
    time:axis = "T" ;
    time:units = "years since 2000-1-1 00:00:00" ;

我想将单位更改为相同基准日期的“天数”——显然需要更改时间变量以保持一致。我希望有一个使用 nco 或 cdo 的解决方案,但我有点难过。 (python 解决方案也可以,但实际上我需要这样做的原因是我实际上无法使用 xarray 打开文件。)

最佳答案

尝试 NCO 的 udunits() 函数记录 here :

ncap2 -O -s '@units="days since 2000-1-1 00:00:00";time=udunits(time,@units);time@units=@units' in.nc out.nc

关于python - 在 netcdf 文件中将时间轴单位从 "years since"更改为 "days since",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64624632/

相关文章:

python - 导入错误 : No module named pkg_resources

python - 将 xarray 数据变量重新分配给 xarray 坐标

python - 如何将每日 netcdf 文件转换为每月 netcdf 文件

python - Python中通过散点提取二维网格场的值

netcdf - 如何将新数据附加到现有 netcdf 文件中

python - 将多个NetCDF文件组合成timeseries多维数组python

python - 使用 $exists 的 Pymongo

Python Strip 列表以删除不需要的字符

python - 确认 postgres 'update' 查询在 python 中有效

database - 在 matlab 中创建多维 NetCDF