This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: Raghavendra Prasad <address@hidden> >Subject: Re: 20030428: subject >Organization: ? >Keywords: time conventions G Raghavendra, > Can you kindly give me the syntax of putting time > data into a netCDF file. > > My requirement is as follow: > > ncid = nccreate("sst.nc", NC_CLOBBER); > lonid = ncdimdef(ncid,"lon",4096); > latid = ncdimdef(ncid,"lat",2048); > sstid = ncdimdef(ncid,"sst",4096*2048); > tineid = ncdimdef(ncid,"time",); I assume you meant to provide the size of the time dimensions as the "unlimited" dimension, which can grow as you add more times to the data. in that case, you want something like: timeid = ncdimdef(ncid,"time",NC_UNLIMITED); where "NC_UNLIMITED" is a constant defined in the the netcdf.h file to represent the dimension in a netCDF file that can increase in size. > Please tell me how to put time as 1/1/1999 00:00:00 to > 1/1/1999 23:59:59. I am under great pressure. There are various conventions for representing time in netCDF files, and which one you choose depends on what kinds of times you need to represent. I assume you want time to be a coordinate dimension, which means you also need a "time" variable with the same name as the time dimension, and it should have a "units" attribute that uses valid udunits syntax for time, for example: double time(time); time:units = "seconds since 1999-01-01 00:00:00"; which would permit very precise time values. Alternatively, if you only need time values within an hour, for example, you could use something like int time(time); time:units = "hours since 1999-01-01 00:00:00"; You should follow a published convention for how to represent time in a netCDF file. A good example is the CF Conventions for Climate and Forecast Metadata: http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-working.html or the COARDS Conventions: http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html Also see the netCDF Frequently Asked Question, "What is the best way to handle time using netCDF?": http://www.unidata.ucar.edu/packages/netcdf/faq.html#time --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://my.unidata.ucar.edu