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" ;
}
