Reads an attribute from a NetCDF source.
attvalue = ncreadatt(source, location, attname)
Path to a NetCDF file or URL of an OpenNDAP source (string).
Name of the attribute (string).
Path of group or/and variable containing the attribute (string). Full form is /grp/subgrp/.../varname
. For a group attribute, the path must end with a '/'. For a global attribute use '/'.
Attribute value (vector of double/integer or string).
ncreadatt
reads the attribute specified by attname in the location specified by location from a source (NetCDF file or OpenNDAP source).
The location location> is a path to a variable attribute, or a group attribute or a global attribute.
The returned attribute value attvalue is either a numeric vector or a string.
scinetcdf_path = getSciNetCDFPath(); source = fullfile(scinetcdf_path, 'tests/examples/atts.nc'); // Reads the global attributes 'version' and 'date' ncreadatt(source, '/', 'version') ncreadatt(source, '/', 'date') // Reads the attribute 'name' of group 'grp' ncreadatt(source, 'grp/', 'name') // Reads the attribute 't' of variable 'grp/precip' ncreadatt(source, 'grp/precip', 't') // Read the variable 'grp/precip' ncread(source, 'grp/precip') // Reads the attribute 'unit' of variable 'grp/precip' ncreadatt(source, 'grp/precip', 'unit') | ![]() | ![]() |