[Thread Prev][Thread Next][Index]

[ferret_users] working with attributes in netCDF datasets



Hi all,

There have been a couple of questions lately about working with attributes in datasets.  Here's a note about some of the commands and options you may not know about. All of this is here in the documentation:

http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/SET#_VPID_474


SET ATTRIBUTE/LIKE= This command takes all of the attributes from var1 and copies them to attributes belonging to var2, so if you're defining a new variable based on a file variable, you'll be able to keep the units, title, and anything else that the file variable has.  (It doesn't inherit missing-value flags - those are defined as always when var2 is defined.)

yes? set attribute/like=fvar var2

(See also LET/LIKE= which applies the same setting when defining variables.)


SET ATTRIBUTE/OUTPUT  This marks attributes for writing out to netCDF files. By default Ferret/PyFerret only write the title, units and history, but this lets you set properties so they are written out.  To set a property so that one attribute or all attributes on a variable will be written out:

yes? set attribute/output fvar.comment 
yes? set attribute/output=all fvar

(See also DEFINE ATTRIBUTE/OUTPUT for setting the output property when defining a new attribute)


To work with global attributes, use a dot.  This acts as a virtual "global-attribute" variable name.  Global attributes are written when first creating a file, writing variables that belong to that file (writing user-variables based on file variables will also trigger writing the global attributes from that file.)  To write a couple of attributes:

yes? set attribute/output ..investigators
yes? set attribute/output ..project

Or set them all to be written out

yes? set attribute/output .

Finally, to add new global attributes to an existing dataset, uses  SAVE/ASGLOBAL which was new in version 7.3


Happy Ferreting,

Ansley


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement