Change time axis units from “years since” to “days since” in netcdf file

情到浓时终转凉″ 提交于 2020-12-10 08:42:54

问题


I have a netcdf file that someone passed me that uses "years since DATE" as the time units:

    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" ;

I want to change the units to "Days since" the same base date - Obviously the timevariable needs to be changed to be consistent. I was hoping for a solution using nco or cdo, but I am a bit stumped. (A python solution would also be okay, but in fact the reason I need to do this is that I can't actually get the file to open with xarray.)


回答1:


Try NCO's udunits() function documented here:

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


来源:https://stackoverflow.com/questions/64624632/change-time-axis-units-from-years-since-to-days-since-in-netcdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!