NetCDF (.nc)

  • Import and Export support Version 3 of the netCDF format.
  • Background & Context

      MIME type: application/x-netcdf
      NetCDF data file format.
      Self-describing format for exchanging scientific data.
      Used in atmospheric research, GIS, and related fields.
      NetCDF is an acronym derived from network Common Data Form.
      Binary file format.
      Conceptually based on NASA's Common Data Format, but incompatible with this format.
      Developed by the Unidata center at the University Corporation for Atmospheric Research (UCAR).

    Import and Export

    • Import["file.nc"] imports a netCDF file, returning the names of the datasets stored in the file.
    • Export["file.nc",expr] exports a data array to a netCDF file.
    • Import["file.nc"] returns a list of strings representing the names of all datasets contained in the file.
    • Export["file.nc",{expr1,}, {"Datasets",{"/dataset1",}}] creates a netCDF file, storing the data arrays {expr1,} as separate datasets.
    • Import["file.nc",elem] imports the specified element from a netCDF file.
    • Import["file.nc",{elem,suba,subb,}] imports a subelement.
    • Import["file.nc",{{elem1,elem2,}}] imports multiple elements.
    • The import format can be specified with Import["file","NetCDF"] or Import["file",{"NetCDF",elem,}].
    • Export["file.nc",expr,elem] creates a netCDF file by treating expr as specifying element elem.
    • Export["file.nc",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
    • Export["file.nc",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
    • See the reference pages for full general information on Import and Export.
    • ImportString and ExportString support the netCDF format.

    Elements

    • General Import elements:
    • "Elements"list of elements and options available in this file
      "Rules"full list of rules for each element and option
      "Options"list of rules for options, properties, and settings
    • Data representation elements:
    • "Data"all datasets imported as a list of arrays
      "Datasets"names of all datasets
    • Import by default uses the "Datasets" element for the netCDF format.
    • Specifying and selecting datasets:
    • "Datasets", nn^(th) dataset
      "Datasets", datasetnamed dataset
    • Meta-information elements:
    • "Annotations"meta-information for each dataset
      "DataFormat"type used to represent each dataset
      "Dimensions"data dimensions of each dataset
      "Metadata"general meta-information as a list of rules
    • The following values can be given for "DataFormat":
    • "Integer8"8-bit integers
      "Integer16"16-bit integers
      "Integer32"32-bit integers
      "UnsignedInteger8"unsigned 8-bit integers (Export only)
      "Real32"IEEE single-precision numbers
      "Real64"IEEE double-precision numbers
      "String"strings of ASCII characters

    Examples

    Basic Examples  (4)

    Get the names of datasets stored in a netCDF file:

    In[1]:=
    Click for copyable input
    Out[1]=

    Import a dataset:

    In[1]:=
    Click for copyable input

    Render the imported data as graphics:

    In[2]:=
    Click for copyable input
    Out[2]=

    Read meta-information from a netCDF file:

    In[1]:=
    Click for copyable input
    Out[1]=

    Export raster image data to the netCDF format:

    In[1]:=
    Click for copyable input
    Out[1]=

    This gives the names of the datasets stored in this file:

    In[2]:=
    Click for copyable input
    Out[2]=

    See Also

    "NASACDF"  "HDF"  "HDF5"

    Introduced in 2007
    (6.0)
    | Updated in 2008
    (7.0)