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

Home » Public Forums » archive » Modify netcdf attributes
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
Modify netcdf attributes [message #93491] Thu, 04 August 2016 11:49 Go to next message
khyde is currently offline  khyde
Messages: 21
Registered: November 2013
Junior Member
Hello,

Is it possible to change an existing global attribute in a netcdf file? I have figured out a couple different ways to add a new global attribute, but I would also like to modify the information stored in an existing attribute.

I've tried using NCDF_ATTPUT and NCDF_PUT, but the program crashes and actually shuts down IDL when I use NCDF_CLOSE to close the file.

One option I have is to first delete the attribute, then add it back with the updated information, but I was hoping to just modify the information so that the list of attributes stays in the same order.

Thanks,
-K
Re: Modify netcdf attributes [message #93519 is a reply to message #93491] Wed, 10 August 2016 08:37 Go to previous messageGo to next message
joe.sapp is currently offline  joe.sapp
Messages: 1
Registered: August 2016
Junior Member
On Thursday, August 4, 2016 at 2:49:08 PM UTC-4, KH wrote:
> Is it possible to change an existing global attribute in a netcdf file? I have figured out a couple different ways to add a new global attribute, but I would also like to modify the information stored in an existing attribute.

You need to be in "define" mode if the attribute is a different size from the existing one (e.g., a string). Try `ncdf_control, ncid, /redef` first to see if that fixes things.
Re: Modify netcdf attributes [message #93521 is a reply to message #93519] Wed, 10 August 2016 09:31 Go to previous messageGo to next message
khyde is currently offline  khyde
Messages: 21
Registered: November 2013
Junior Member
On Wednesday, August 10, 2016 at 11:37:56 AM UTC-4, joe....@noaa.gov wrote:
> On Thursday, August 4, 2016 at 2:49:08 PM UTC-4, KH wrote:
>> Is it possible to change an existing global attribute in a netcdf file? I have figured out a couple different ways to add a new global attribute, but I would also like to modify the information stored in an existing attribute.
>
> You need to be in "define" mode if the attribute is a different size from the existing one (e.g., a string). Try `ncdf_control, ncid, /redef` first to see if that fixes things.


Thank you for your suggestion. I tried the following:

1) id = ncdf_open(file,/write)
2) ncdf_control, id, /redef
3) ncdf_attput, id, 'title', 'new_title',/global
4) ncdf_control,id,/endef
5) ncdf_close, id

The program crashes the entire IDL session at step 4. I tried skipping this step as well, and then it crashes the system at ncdf_close. This happens in both on both the Mac and Linux OS.

Any thoughts on what I am doing wrong or is this something I just won't be able to do without first deleting the original attribute?

Thanks,
-K
Re: Modify netcdf attributes [message #93531 is a reply to message #93521] Thu, 11 August 2016 07:14 Go to previous message
khyde is currently offline  khyde
Messages: 21
Registered: November 2013
Junior Member
It turns out the .nc files I am trying to read are actually HDF5 files. Can the global attributes of a HDF5 file be easily modified? If so, could you point me in the right direction. There are so many H5 routines that I am not sure where to start.
Thanks again,
-K
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: plotting function will not compile
Next Topic: "Automatically indent lines" breaks copying and pasting code

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

Current Time: Wed Oct 08 13:32:07 PDT 2025

Total time taken to generate the page: 0.00528 seconds