comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Add a new variable to netCDF file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Add a new variable to netCDF file? [message #78066 is a reply to message #78063] Tue, 25 October 2011 06:37 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

Ashley Berg wrote:
> So, I know how to overwrite a variable in a netCDF file, but how do I
> add a new one?
>
> I have a netCDF file with about 30 variables and I want to add two new
> ones. It would be a pain to have to copy over all 30 vars plus the
> new ones into a new file, so is there a way to add variables using the
> netCDF operators? I've been experimenting but haven't been able to
> find a way to do it (when I try to write a new variable to the file,
> it complains that it can't find the variable, which implies it's
> looking to overwrite an existing one rather than tack on the new one).

0) Open the existing file for writing (NCDF_OPEN)
1) Put the netcdf file in DEFINE mode (NCDF_CONTROL)
2) If required, define new dimensions (NCDF_DIMDEF)
3) Define the new variable (NCDF_VARDEF)
4) Repeat 2-3 as necessary for multiple dimensions/variables.
5) Put the netcdf in DATA mode (NCDF_CONTROL)
6) Write the new variable data to the file (NCDF_VARPUT)
7) Repeat 7 as necessary for multiple variables.
8) Close the file (NCDF_CLOSE)

cheers,

paulv

>
> Thanks!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Religious Wars
Next Topic: How to determine if ENVI is loaded?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 23:20:33 PDT 2025

Total time taken to generate the page: 0.80112 seconds