<< ncwriteatt sciNetCDF ncdisp >>

sciNetCDF >> sciNetCDF > ncreadatt

ncreadatt

Reads an attribute from a NetCDF source.

Calling Sequence

attvalue = ncreadatt(source, location, attname)

Arguments

source

Path to a NetCDF file or URL of an OpenNDAP source (string).

attname

Name of the attribute (string).

location

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 '/'.

attvalue

Attribute value (vector of double/integer or string).

Description

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.

Examples

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')

See Also


Report an issue
<< ncwriteatt sciNetCDF ncdisp >>