Hi David, > I would like to encode data input and model output time values in a > netCDF file consistent with ISO 8601 methods for specifying time, such as > 2012-03-31T11 representing 11 am on March 31 > 2012-03-31T11.5 representing 11:30 > 2012-03-31T12 representing noon > 2012-03-31T12.5 > 2012-03-31T13 > 2012-03-31T13.5 representing 1:30 pm > etc > > What is the best practice for encoding these in the time dimension > values of a netCDF file. (We will be reading and writing these files > using the Fortran interface > (http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.pdf) To be CF-compliant, you should instead encode the times using units that are supported by the udunits library, as described here: http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#time-coordinate Then if you use ncdump to look at the time values with the "-T" option, it shows them as ISO-8601 strings. For example, if you have time values stored in a variable named "time" that uses the dimension named "time" and has units: time:units = "seconds since 2009-01-01" ; and you just use "ncdump" to see the time values, they might look like time = 7776000, 15597000 ; but if you use "ncdump -T" instead, they will be shown as time = "2009-04-01", "2009-06-30T12:30" ; There's no option to make the hours and minutes appear as "12.5" instead of "12:30", but I think the latter is ISO-8601 standard. Unfortunately, the ncgen utility can't yet convert ISO-8601 strings to udunits quantities, but there are other packages that do, e.g. the Python datetime module. If you decide to store time as strings rather than as numeric quantities that can be used in calculations, you will need to define a character array variable for each time, but your data won't be CF-compliant. In CDL notation, you could use something like dimensions: datelen = 15 ; // number of chars in every date-time string, blank padded time = unlimited; // time dimension variables: char time(time, datelen); // date-time in ISO-8601 notation data: time = "2012-03-31T11 ", "2012-03-31T11.5", "2012-03-31T12 ", ... The above use only the netCDF-classic character arrays, which require that an array of strings be represented as a multidimensional array of characters, using a convention such as blank padding to make it possible to associate strings with the associated dimension index. You can do better in netCDF-4, which supports real variable-length strings at the expense of some extra complexity in programming for access. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: BCN-163009 Department: Support netCDF Priority: Normal Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly 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.