how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00
Added by Subhra Sekhar Maity over 1 year ago
Hi everyone
I have a nc file with 13879 daily time steps starting from 1981-01-01. I want to convert the time steps to 1981-01-01 00:00-1981-01-01 23:00 format. How to do that with cdo? I am attaching two nc files one of which needs this conversion and other one contains the required time steps.
The one which required conversion is named as
1) imd_pr_1981_2018_clipped.nc
The other one which is in correct format is
2) pr_1981_2018_clipped_mm.nc
Please help me converting the time steps as stated above
Replies (5)
RE: how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00 - Added by Subhra Sekhar Maity over 1 year ago
I want to correct my question. My question is how should I incorporate the time_bnds in the nc file?
RE: how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00 - Added by Karin Meier-Fleischer over 1 year ago
If you want to change the time values then you can use CDO settaxis to set the time from 00:00:00 to 12:00:00. This won't change the variable data.
Set time to same time values as in pr_1981_2018_clipped_mm.nc:
cdo -setreftime,1900-01-01,00:00:00,1day \ -settaxis,1981-01-01,12:00:00,1day \ imd_pr_1981_2018_clipped.nc tmp.nc
Generate the time bounds and add it to the file with NCO's ncap2 routine:
ncap2 -O -s 'defdim("bnds",2);time_bnds=make_bounds(TIME,$bnds,"time_bnds");' \ tmp.nc imd_pr_1981_2018_clipped_changed.nc
Btw, for the first time step in imd_pr_1981_2018_clipped.nc all values of the variable RAINFALL are 0.
RE: how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00 - Added by Subhra Sekhar Maity over 1 year ago
Thank you very much Sir for the answer. It worked. Can you please suggest me from where I can learn such codes for CDO and NCO?
RE: how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00 - Added by Karin Meier-Fleischer over 1 year ago
RE: how to change time format in a nc file e.g. 1981-01-01 to 1981-01-01 00:00 -1981-01-01 23:00 - Added by Subhra Sekhar Maity over 1 year ago
Thank you so much