[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040423: Decoding time in netCDF - Urgent please



>From: Gourihar Kulkarni <address@hidden>
>Organization: University of Leeds
>Keywords: 200404231345.i3NDjHCT001644 netCDF time

Gourihar,

>I'm using netCDF air temperature subset data from NCEP Reanalysis Daily 
>Averages Pressure Level Data.It has 5 variables lon, lat , pressure,time and 
>air temp.
>The time data when I read it in Matlab shows some different numbers.
>For example  11 August 2001 shows 17536968 in netCDF
>             03 Jan    2001 shows 17540448  in netCDF etc.
>I went to 
>http://www.cdc.noaa.gov/PublicData/faq.html#2- it says they have cdcncdump 
>library which extracts exact date. But unfortunately I can't run 'C'language 
>on my Windows machine , which is used in cdcncdump.
>Any matlab file or function or program or any idea, which can tell me 
>to convert this netCDF daytime to normal daytime. 

A typical way that time is stored in a netCDF file is seconds since
an epoch (fixed time) like January 1, 1970.  The numbers you show
look like this form, but I am confused by the time for 11 August 2001
being less than the time for 3 January of the same year.  Perhaps
you copied down the time incorrectly for this email?

You can use the ncdump application that is bundled with the
binary netCDF distribution for Windows to perform an ASCII
dump of the values in a netCDF.  This will allow you to see
how the time is stored and then let you develop a Matlab function
to convert the number to a more recognizable date.

For instance, here is the beginning of an ncdump of a netCDF file we
got from another user:

ncdump -h radar-camra_chilbolton_20030604094429_678201604-rhi-dop.nc

netcdf radar-camra_chilbolton_20030604094429_678201604-rhi-dop {
dimensions:
        time = UNLIMITED ; // (103 currently)
        range = 300 ;
variables:
        float frequency ;
                frequency:units = "GHz" ;
                frequency:long_name = "Radar frequency" ;
        float latitude ;
                latitude:units = "degrees_north" ;
                latitude:long_name = "Latitude of antenna" ;
        float longitude ;
                longitude:units = "degrees_east" ;
                longitude:long_name = "Longitude of antenna" ;
        float altitude ;
                altitude:units = "m" ;
                altitude:long_name = "Altitude of antenna above mean sea level" 
;
        float time(time) ;
                time:units = "hours since 2003-06-04 00:00:00 00:00" ;
                time:long_name = "Decimal hours from midnight UTC to the middle 
of each ray" ;

 ...


'ncdump -h' says to dump the header of the file only.  I cut off the
listing right after the output for 'time' to illustrate the point.

In this case, the epoch is 2003-06-04 00:00:00 00:00 and the measure
is hours.  As I said above, your numbers look more like seconds since
a date like 1 January 1970.

You can grab a binary distribution of netCDF 3.5.0 from our anonymous
FTP server, ftp.unidata.ucar.edu.  The distribution is named
netcdf-3.5.0.win32bin.ZIP, and it can be found in the
pub/netcdf/contrib/win32 directory.  More information on the
use of the netCDF and accompanying utilities 'ncdump' and 'ncgen'
can be found in the netCDF section of our web site:

http://my.unidata.ucar.edu

Look under the list of links under the Data section on the homepage
for quick access to the netCDF documentation.

>Please help.
>Thanking you.
>Gourihar 
>University of Leeds, 
>UK 

Best of luck in your research.

Tom Yoksas
--
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publically available
through the web.  If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.