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

Home » Public Forums » archive » Re: Deleting a variable from a NetCDF file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Deleting a variable from a NetCDF file [message #49460] Wed, 26 July 2006 09:34
alexzcervantes@gmail. is currently offline  alexzcervantes@gmail.
Messages: 7
Registered: July 2006
Junior Member
Thanks Paul!

Overwriting did the trick.

Alex
Paul Van Delst wrote:
> Mark Hadfield wrote:
>> alexzcervantes@gmail.com wrote:
>>
>>> How about overwriting a variable in a NetCDF file?
>>>
>>> My problem is that I have to overwrite a variable in a NetCDF file. I
>>> was thinking of deleting the variable, and then writing my new
>>> variable.
>>>
>>> Is there a flag that will allow me to just overwrite the variable?
>>
>>
>> Will the new variable have the same data type and dimensions as the
>> original? Then just rename it (NCDF_VARRENAME) and then overwrite the
>> data (NCDF_VARPUT).
>
> Also, do you want to overwrite the variable+data, or just the data associated wsith teh
> variable? If the former, then Mark's suggestions will do the trick. If the latter, then
> all you need to do is replace the data (using the varput routine).
>
> paulv
>
>
>> Otherwise you have to make a new file, copy over all the stuff you want
>> to keep, add the new stuff. The netCDF operators (NCO) are good for this
>> sort of thing:
>>
>> http://nco.sourceforge.net/
>>
>
>
> --
> Paul van Delst Ride lots.
> CIMSS @ NOAA/NCEP/EMC Eddy Merckx
> Ph: (301)763-8000 x7748
> Fax:(301)763-8545
Re: Deleting a variable from a NetCDF file [message #49477 is a reply to message #49460] Tue, 25 July 2006 07:35 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mark Hadfield wrote:
> alexzcervantes@gmail.com wrote:
>
>> How about overwriting a variable in a NetCDF file?
>>
>> My problem is that I have to overwrite a variable in a NetCDF file. I
>> was thinking of deleting the variable, and then writing my new
>> variable.
>>
>> Is there a flag that will allow me to just overwrite the variable?
>
>
> Will the new variable have the same data type and dimensions as the
> original? Then just rename it (NCDF_VARRENAME) and then overwrite the
> data (NCDF_VARPUT).

Also, do you want to overwrite the variable+data, or just the data associated wsith teh
variable? If the former, then Mark's suggestions will do the trick. If the latter, then
all you need to do is replace the data (using the varput routine).

paulv


> Otherwise you have to make a new file, copy over all the stuff you want
> to keep, add the new stuff. The netCDF operators (NCO) are good for this
> sort of thing:
>
> http://nco.sourceforge.net/
>


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
Re: Deleting a variable from a NetCDF file [message #49484 is a reply to message #49477] Mon, 24 July 2006 15:03 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
alexzcervantes@gmail.com wrote:
> How about overwriting a variable in a NetCDF file?
>
> My problem is that I have to overwrite a variable in a NetCDF file. I
> was thinking of deleting the variable, and then writing my new
> variable.
>
> Is there a flag that will allow me to just overwrite the variable?

Will the new variable have the same data type and dimensions as the
original? Then just rename it (NCDF_VARRENAME) and then overwrite the
data (NCDF_VARPUT).

Otherwise you have to make a new file, copy over all the stuff you want
to keep, add the new stuff. The netCDF operators (NCO) are good for this
sort of thing:

http://nco.sourceforge.net/

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Deleting a variable from a NetCDF file [message #49485 is a reply to message #49484] Mon, 24 July 2006 14:53 Go to previous message
alexzcervantes@gmail. is currently offline  alexzcervantes@gmail.
Messages: 7
Registered: July 2006
Junior Member
I was afraid of that.

How about overwriting a variable in a NetCDF file?

My problem is that I have to overwrite a variable in a NetCDF file. I
was thinking of deleting the variable, and then writing my new
variable.

Is there a flag that will allow me to just overwrite the variable?

Alex
Paul Van Delst wrote:
> alexzcervantes@gmail.com wrote:
>> Hi,
>>
>> I am pretty new to idl, and I could find out an answer to my problem in
>> the idl helper program.
>>
>> Does anyone know how to delete a variable from a NetCDF file?
>
> I don't believe you can. At least, not via the netCDF API. Neither the C, F95, nor IDL
> netCDF API has any details about deleting a variable from a file once it's in there. Just
> creating, writing and reading one.
>
> The Java API has a removeVariable method, but I don;t know if even that does what you want
> (it removes a variable from a netCDF group, as opposed to a file)
>
> paulv
>
> --
> Paul van Delst Ride lots.
> CIMSS @ NOAA/NCEP/EMC Eddy Merckx
> Ph: (301)763-8000 x7748
> Fax:(301)763-8545
Re: Deleting a variable from a NetCDF file [message #49487 is a reply to message #49485] Mon, 24 July 2006 14:02 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
alexzcervantes@gmail.com wrote:
> Hi,
>
> I am pretty new to idl, and I could find out an answer to my problem in
> the idl helper program.
>
> Does anyone know how to delete a variable from a NetCDF file?

I don't believe you can. At least, not via the netCDF API. Neither the C, F95, nor IDL
netCDF API has any details about deleting a variable from a file once it's in there. Just
creating, writing and reading one.

The Java API has a removeVariable method, but I don;t know if even that does what you want
(it removes a variable from a netCDF group, as opposed to a file)

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Array comparison
Next Topic: Re: Draw Widget in GUIBuilder?

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

Current Time: Wed Oct 08 19:04:02 PDT 2025

Total time taken to generate the page: 0.00464 seconds