Main Content

ncinfo

Return information about netCDF data source

    Description

    example

    finfo = ncinfo(source) returns information about the entire netCDF data source specified by source.

    example

    vinfo = ncinfo(source,varname) returns information about the variable varname in source.

    example

    ginfo = ncinfo(source,groupname) returns information about the group groupname in source.

    Examples

    collapse all

    Get the file schema of the netCDF file example.nc.

    finfo = ncinfo("example.nc")
    finfo = 
    
      struct with fields:
    
          Filename: 'matlabroot\toolbox\matlab\demos\example.nc'
              Name: '/'
        Dimensions: [1×3 struct]
         Variables: [1×3 struct]
        Attributes: [1×1 struct]
            Groups: [1×2 struct]
            Format: 'netcdf4'
         Datatypes: []

    Find dimensions with names that begin with x.

    dimNames = {finfo.Dimensions.Name};
    dimMatch = strncmpi(dimNames,"x",1);
    disp(finfo.Dimensions(dimMatch))
             Name: 'x'
           Length: 50
        Unlimited: 0

    Get the variable schema of the peaks variable in the netCDF file example.nc.

    vinfo = ncinfo("example.nc","peaks")
    vinfo = 
    
      struct with fields:
    
            Filename: 'matlabroot\toolbox\matlab\demos\example.nc'
                Name: 'peaks'
          Dimensions: [1×2 struct]
                Size: [50 50]
            Datatype: 'int16'
          Attributes: [1×1 struct]
           ChunkSize: []
           FillValue: -32767
        DeflateLevel: []
             Shuffle: 0
              Format: 'netcdf4'

    Find the size of the peaks variable.

    varSize = vinfo.Size
    varSize =
    
        50    50

    Determine whether the peaks variable has any unlimited dimensions.

    hasUnlimDim = any([vinfo.Dimensions.Unlimited])
    hasUnlimDim =
    
      logical
    
       0

    Get the group schema of the /grid2 group in the netCDF file example.nc.

    ginfo = ncinfo("example.nc","/grid2")
    ginfo = 
    
      struct with fields:
    
          Filename: 'matlabroot\toolbox\matlab\demos\example.nc'
              Name: 'grid2'
        Dimensions: [1×3 struct]
         Variables: [1×1 struct]
        Attributes: [1×1 struct]
            Groups: []
            Format: 'netcdf4'

    Find unlimited dimensions in the group.

    unlimDims = [ginfo.Dimensions.Unlimited];
    disp(ginfo.Dimensions(unlimDims))
             Name: 'time'
           Length: 0
        Unlimited: 1

    Input Arguments

    collapse all

    Name of the netCDF data source, specified as a string scalar or character vector. The source argument can be one of these values:

    • The path of a local netCDF source

    • The OPeNDAP URL of a remote OPeNDAP netCDF data source

    • The HTTP URL of a remote netCDF source, with #mode=bytes appended to the end of the URL to enable byte-range reading

      Note

      Byte-range reading is slower than reading from other sources. For more details about byte-range reading, see the netCDF documentation.

    Example: "myNetCDFfile.nc"

    Example: "http://host_name/netcdf_filename#mode=bytes"

    Variable name, specified as a string scalar or character vector containing the name of a variable in the netCDF data source.

    If source specifies a file with format netcdf4, you can specify the location of the variable within the group hierarchy by specifying varname as a fully qualified name.

    Example: "myVar"

    Example: "/myGrp/mySubGrp/myNestedVar"

    Group name, specified as a string scalar or character vector containing the name of a group in the netCDF data source.

    Example: "myGrp"

    Example: "/myGrp/mySubGrp"

    Output Arguments

    collapse all

    NetCDF file schema, returned as a structure. This table describes the fields of the structure.

    FieldDescription
    FilenameNetCDF filename or OPeNDAP URL, returned as a character vector
    Name'/' (indicating the full file)
    Dimensions

    Dimension schema, returned as a structure vector containing these fields:

    • Name — Name of the dimension, returned as a character vector

    • Length — Length of the dimension, returned as a nonnegative integer (a value of 0 represents an unlimited dimension)

    • Unlimited — Whether the dimension is unlimited, returned as a logical scalar

    VariablesVariable schema, as described in the vinfo output argument, except without the Filename and Format fields
    Attributes

    Attribute schema, returned as a structure vector containing these fields:

    • Name — Name of the attribute, returned as a character vector

    • Value — Value of the attribute

    GroupsGroup schema, as described in the ginfo output argument, except without the Filename and Format fields, or an empty array ([]) if the file is not of format netcdf4
    FormatNetCDF file format, returned as a character vector
    Datatypes

    Structure vector of user-defined data types, containing these fields (or an empty array ([]) if there are no user-defined data types):

    • Name — Name of the data type, returned as a character vector

    • Class'NC_VLEN'

    • Type — MATLAB® type of the data type, returned as a character vector

    • ByteSize — Size of the type in bytes, returned as a positive integer

    NetCDF variable schema, returned as a structure. This table describes the fields of the structure.

    FieldDescription
    FilenameNetCDF filename or OPeNDAP URL, returned as a character vector
    NameName of the variable, returned as a character vector
    Dimensions

    Dimension schema for the variable, returned as a structure vector containing these fields:

    • Name — Name of the dimension, returned as a character vector

    • Length — Length of the dimension, returned as a nonnegative integer (a value of 0 represents an unlimited dimension)

    • Unlimited — Whether the dimension is unlimited, returned as a logical scalar

    SizeSize of the current variable, returned as a numeric scalar or vector
    DatatypeMATLAB data type of the variable or name of the user-defined type, returned as a character vector
    Attributes

    Attribute schema for the variable, returned as a structure vector containing these fields:

    • Name — Name of the attribute, returned as a character vector

    • Value — Value of the attribute

    ChunkSizeChunk size for the variable, returned as a numeric value, if defined; otherwise, an empty array ([])
    FillValueFill value for the variable, returned as a scalar, if defined; otherwise, an empty array ([])
    DeflateLevelDeflate compression level for the variable, returned as a nonnegative integer, if enabled; otherwise, an empty array ([])
    ShuffleWhether the shuffle filter is enabled for the variable, returned as a logical scalar
    FormatNetCDF file format, returned as a character vector

    NetCDF group schema, returned as a structure. This table describes the fields of the structure.

    FieldDescription
    FilenameNetCDF filename or OPeNDAP URL, returned as a character vector
    NameName of the group, returned as a character vector
    Dimensions

    Dimension schema for the group, returned as a structure vector containing these fields:

    • Name — Name of the dimension, returned as a character vector

    • Length — Length of the dimension, returned as a nonnegative integer (a value of 0 represents an unlimited dimension)

    • Unlimited — Whether the dimension is unlimited, returned as a logical scalar

    VariablesVariable schema for the group, as described in the vinfo output argument, except without the Filename and Format fields
    Attributes

    Attribute schema for the group, returned as a structure vector containing these fields:

    • Name — Name of the attribute, returned as a character vector

    • Value — Value of the attribute

    GroupsGroup schema for the group, as described in this output argument, except without the Filename and Format fields
    FormatNetCDF file format, returned as a character vector

    Tips

    • Use ncdisp for visual inspection of a netCDF source.

    Version History

    Introduced in R2011a

    expand all