Skip to main content
  • Home
  • Documentation
  • FAQ
  • Downloads
  • Support
  • Current Release Notes
  • Ferret Users Guide
    • Users Guide Index
    • Commands Reference
    • 1. Introduction
    • 2. Data Set Basics
    • 3. Variables & Expressions
    • 4. Grids & Regions
    • 5. Animations & Gif Images
    • 6. Customizing Plots
    • 7. Handling String Data Symbols
    • 8. Working with Special Data Sets
    • 9. Computing Environment
    • 10. Converting to NetCDF
    • 11. Writing External Functions
    • Glossary
    • Appendix A: Functions
    • Appendix B: PPLUS Guide
    • Appendix C: Ferret-Specific PPLUS Enhancements
  • Previous Release Notes
  • Tutorials and Demos
    • Ferret Tour
    • DSG files: Discrete Sampling Geometries Demo
    • Ferret sorting demo
    • Fast Fourier Transforms demo
    • Empirical Orthogonal Functions demo
    • Ferret objective analysis demo
    • Ferret Palette Demo
    • Map projections
    • Ferret polygon vector demo
    • Ferret Graticules demo
    • Ferret Polytube Demo
    • Ferret Polymark Demo
    • Ferret Constant-Array demo
    • Ferret land_detail demo
    • COADS Tour
    • Levitus Tour
    • Use OPeNDAP
    • Ferret binary read demo
  • PyFerret
    • PyFerret Downloads and Install ../../faq/ferret-faqs.html
    • What is PyFerret?
    • Why use PyFerret?
    • PyFerret for the Ferret user
    • PyFerret command syntax: quick-start notes
    • PyFerret for the Python user
    • Graphics in PyFerret ?
    • New Ferret functionality
    • PyFerret Python functions and constants
    • PyFerret Python objects and methods
    • Ferret external functions in Python
    • Ferret Fortran external functions
    • PyFerret metadata-and-data dictionaries
  • OPeNDAP
    • OPeNDAP usage in Ferret
    • Use OPeNDAP Demo
    • Test OPeNDAP

NCO_ATTR

Call the NCO attribute editing utility

NCO_ATTR

NCO_ATTR (FileName, VariableName, AttributeName, AttributeType, EditMode, AttributeValue), execute the NCO operator ncatted to edit a netCDF file attribute. The function requires that NCO be installed on your system.

Arguments:

FileName

File name (string)
  VariableName Variable (string)
  AttributeName Attribute (string)
  AttributeType Valid data types are "c"=char, "f"=float, "d"=double,"s"=short, "l"=long, "b"=byte (string)
  Mode Mode: "o"=edit, "a"=append, "d"=delete (string)
 

AttributeValue

value, input as a string which will be converted to the type given in argument 4 (string)

Result Axes:

X

Abstract

 

Y

NORMAL

 

Z

NORMAL

 

T

NORMAL

 

Execute the ncatted operator to edit netCDF file attributes. The result is always 1. See https://nco.sourceforge.net//nco.html#ncatted for documentation on this operator, and https://nco.sourceforge.net/nco.html for a discussion of the nco operators in general.

Note: You do not need to open the file in Ferret before running the nco_attr function, and if you have opened the file in Ferret before issuing these commands, you will NOT see the results of any changes you make to a file, until you close and reopen it. It is recommended that you close the file in Ferret before editing it with nco_attr.

For example:

yes? ! Create a simple file
yes? let A = {1,2,3,4,5}
yes? let B = {1,2,3,4,5}
yes? save/clobber/file=xfile.nc A, B
yes? can var/all
yes? use xfile
 
yes? ! Add the cartesian_axis attribute to an axis
yes? let status = nco_attr("xfile.nc", "`A,return=xaxis`", "cartesian_axis", "c", "o", "X")
yes? load status
 
yes? ! Add the units attribute to a variable
let status = nco_attr("xfile.nc", "B", "units", "c", "o", "tons")
load status
 
yes? ! Add to the history attribute of the file
yes? let status = nco_attr("xfile.nc", "global", "history", "c", "a"," Add text to history attribute")
yes? load status
 
yes? ! Add another line to the history attribute
yes? let status = nco_attr("xfile.nc", "global", "history", "c","a","\nAdd a new line to the history")
yes? load status
 
yes? ! Add a new floating point attribute to a variable
yes? let status = nco_attr("xfile.nc", "B", "upper_bound", "f", "a", "10")
yes? load status
 
yes? ! Edit an attribute
yes? let status = nco_attr("xfile.nc", "B", "long_name", "c", "o", "wheat exports")
yes? load status
 
yes? ! Add a new double precision attribute to a variable
yes? let status = nco_attr("xfile.nc", "B", "factor", "d", "a", "100.987654321")
yes? load status
 
 
yes? ! list what we have done
yes? sp ncdump -h xfile.nc
netcdf xfile {
dimensions:
XAX1_5 = 5 ;
variables:
double XAX1_5(XAX1_5) ;
XAX1_5:point_spacing = "even" ;
XAX1_5:axis = "X" ;
XAX1_5:cartesian_axis = "X" ;
float A(XAX1_5) ;
A:missing_value = -1.e+34f ;
A:_FillValue = -1.e+34f ;
A:long_name = "{1,2,3,4,5}" ;
float B(XAX1_5) ;
B:missing_value = -1.e+34f ;
B:_FillValue = -1.e+34f ;
B:long_name = "wheat exports" ;
B:units = "tons" ;
B:upper_bound = 10.f ;
B:factor = 100.987654321 ;
 
// global attributes:
:history = "FERRET V6.1 9-Sep-08 Add text to history attribute\000\n",
"Add a new line to the history" ;
:Conventions = "CF-1.0" ;
}