Re: unable to set time attribute for netCDF in IDL [message #78179] |
Mon, 31 October 2011 07:39 |
Erik[2]
Messages: 2 Registered: October 2011
|
Junior Member |
|
|
When in doubt, resort to the free NCAR's NCL language for this fix:
a = addfile("file.nc","r") ; read in file
var = a->var ; let's say var is (time, lat, lon)
var!0 = "time"
Time = (/0,1,2,3,4,5,6,7,8,9,10/) ; or Time = ispan(0,10,1) or... Time
= <some string>
var&time = Time
.
<snip>
.
;write out to netcdf file
b = addfile("out_file.nc","c")
b->var=var
There are also other time fixes one may do.
http://www.ncl.ucar.edu/
Erik
On Oct 29, 6:13 am, 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
|
|
|
Re: unable to set time attribute for netCDF in IDL [message #78188 is a reply to message #78179] |
Sat, 29 October 2011 10:52  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
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.")
|
|
|