Re: How to change global attributes in a netCDF file

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 7 Mar 2006 15:57:54 -0700

On Mar 7, 2006, at 3:37 PM, Dennis Shea wrote:

> I posted message only because " it worked " :-)
>
> FYI: Frequently I use the netCDF operators [NCO]
> as suggested by Kate and Xianglei. In this
> particular instance, NCL was the simplest
> solution.
>
> The "w" approach with the addfile function only works
> when replacing something of the same size.
>

No, that used to be the case, but now you can overwrite an attribute
with a longer attribute:

ncl 1> f = addfile("testgatts.nc","c")
ncl 2> f_at_global_att = "a short att"
ncl 3> quit

$ ncdump testgatts.nc
netcdf testgatts {

// global attributes:
                 :global_att = "a short att" ;
}

ncl 0> f = addfile("testgatts.nc","w")
ncl 1> f_at_global_att = "a longer more fully qualified att"
ncl 2> quit

$ ncdump testgatts.nc
netcdf testgatts {

// global attributes:
                 :global_att = "a longer more fully qualified att" ;
}

  -dave

>
>
> D
>
>> Hi Dennis,
>>
>> Yes, your method worked quite well. Thank you so much.
>>
>> Yongxin
>>
>> On Mar 7, 2006, at 3:22 PM, Dennis Shea wrote:
>>
>>>>
>>>> I need to make changes in START_DATE in my netCDF file and then
>>>> write back to this file. Specifically, I need to do the following:
>>>>
>>>> Change from:
>>>>
>>>> :START_DATE = "2005-05-01_00:00:00"
>>>>
>>>> to:
>>>>
>>>> :START_DATE = "2005-06-01_00:00:00"
>>>>
>>>> Please let me know how I can do this or where I can find an
>>>> example to do this.
>>>>
>>>> Thanks,
>>>> Yongxin
>>> ------------------------------------------------
>>> Not untested
>>>
>>> Make a copy of your original file,
>>> then [you can do this interactively]
>>>
>>> ncl > f = addfile ("foo.nc", "w") ; note "w"
>>> ncl > f_at_START_DATE = "2005-06-01_00:00:00"
>>>
>>>
>>> You are done.
>>>
>>> Do a ncdump -h on the file.
>>>
>>> D
>>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 07 2006 - 15:57:54 MST

This archive was generated by hypermail 2.2.0 : Tue Mar 07 2006 - 16:44:45 MST