time unit conversion

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
atul
Posts: 11
Joined: Mon May 02, 2016 12:54 pm
Location: IIT kharagpur

time unit conversion

#1 Unread post by atul »

Hi

I downloaded data NCEP2 data for creating forcing files manually because opendap server is not working

so now I have file like air.2m.gauss.2011.nc and the time have referencing from year1800 as shown below

have unit in hours ( time:units = "hours since 1800-1-1 00:00:0.0" ;)

double time(time) ;
time:units = "hours since 1800-1-1 00:00:0.0" ;
time:long_name = "Time" ;
time:actual_range = 1849584., 1858338. ;
time:delta_t = "0000-00-00 06:00:00" ;
time:standard_name = "time" ;
time:axis = "T" ;
time:coordinate_defines = "point" ;

I split the data for each month and then created forcing files

then I downloaded ECCO2 data using Yorig=1800 for climatology file and
data is saved in file like ECCO_Y2011M1.nc and so on. the time unit in these file is days

double time(time) ;
time:units = "days since 1-Jan-1800 00:00:0.0" ;


Now I want to convert the unit of variable time from hours to days in downloaded NCEP2 data

( time:units = "hours since 1800-1-1 00:00:0.0" ;) to time:units = "days since 1-Jan-1800 00:00:0.0" ;


how I can do this? is there any command in CDO or in NCO for this kind of conversion.

Thanks in advance :)

User avatar
wilkin
Posts: 879
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: time unit conversion

#2 Unread post by wilkin »

Since you are not changing the base date (1800-01-01 in both files) only the units from hours to days, you can make the conversion with the NCO tool ncap

Code: Select all

ncap -s 'time=time/24' orig_file new_file
then update the units attributes to keep the metadata accurate

Code: Select all

ncatted -a units,time,c,c,"days since 1800-01-01 00:00:0.0" new_file
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Post Reply