unable to set time attribute for netCDF in IDL

  • Follow


Dear all,

I struggle to create netCDF output that has the correctly time axis
for further post-processing. I thought/tried different ways: (1)
writing the time variable, read in from a correct netCDF file,
directly to the output file, but it does not let me set the attribute.
(2) creating a date-time axis myself, which does not seem trivial.

Can you give advice or a code example on how to manage this issue?

Thanks,
Steph
0
Reply eesfi (1) 10/29/2011 10:13:21 AM

Stephanie writes: 

> I struggle to create netCDF output that has the correctly time axis
> for further post-processing. I thought/tried different ways: (1)
> writing the time variable, read in from a correct netCDF file,
> directly to the output file, but it does not let me set the attribute.
> (2) creating a date-time axis myself, which does not seem trivial.
> 
> Can you give advice or a code example on how to manage this issue?

I use the nCDF_File object in my Coyote Library to read,
write, and copy netCDF files. But I have updated the example
programs this morning to show how to write and read a time
dimension and variable in a netCDF file. You can find the
updated example program here:

   http://www.idlcoyote.com/programs/ncdf_file_examples.pro

Cheers,

David


-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
0
Reply news2122 (4023) 10/29/2011 5:52:03 PM


When in doubt, resort to the free NCAR's NCL language for this fix:

a =3D addfile("file.nc","r") ; read in file
var =3D a->var ; let's say var is (time, lat, lon)
var!0 =3D "time"
Time =3D (/0,1,2,3,4,5,6,7,8,9,10/) ; or Time =3D ispan(0,10,1) or... Time
=3D <some string>
var&time =3D Time
..
<snip>
..
;write out to netcdf file
b =3D addfile("out_file.nc","c")
b->var=3Dvar

There are also other time fixes one may do.
http://www.ncl.ucar.edu/

Erik



On Oct 29, 6:13=A0am, Stephanie <ee...@leeds.ac.uk> wrote:
> Dear all,
>
> I struggle to create netCDF output that has the correctly time axis
> for further post-processing. I thought/tried different ways: (1)
> writing the time variable, read in from a correct netCDF file,
> directly to the output file, but it does not let me set the attribute.
> (2) creating a date-time axis myself, which does not seem trivial.
>
> Can you give advice or a code example on how to manage this issue?
>
> Thanks,
> Steph

0
Reply nobleeu 10/31/2011 2:39:53 PM

2 Replies
43 Views

(page loaded in 0.069 seconds)


Reply: