NASACDF (.cdf)


    MIME type: application/x-cdf
    CDF data file format.
    General-purpose, self-describing format for storing multidimensional datasets.
    Used for storage, management, and exchange of scientific data and images.
    CDF is an acronym for Common Data Format.
    Developed since 1985 by the National Space Science Data Center at NASA.
    Binary file format.
    Related to, but incompatible with, netCDF.

Import and Export

  • Import["file.cdf"] imports a CDF file, returning the names of the datasets stored in the file.
  • Export["file.cdf",expr] exports an array or a Graphics object to a CDF file.
  • Import["file.cdf"] returns a list of strings representing the names of all datasets contained in the file.
  • Export["file.cdf",{expr1,},{"Datasets",{"/dataset1",}}] creates a CDF file, storing the arrays or Graphics objects {expr1,} as separate datasets.
  • Import["file.cdf",elem] imports the specified element from a CDF file.
  • Import["file.cdf",{elem,suba,subb,}] imports a subelement.
  • Import["file.cdf",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","NASACDF"] or Import["file",{"NASACDF",elem,}].
  • Export["file.cdf",expr, elem] creates a NASA CDF file by treating expr as specifying element elem.
  • Export["file.cdf",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["file.cdf",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.cdf",{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 NASA CDF format.


  • 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 CDF format.
  • Specifying and selecting datasets:
  • "Datasets",nnth dataset
    "Datasets",datasetnamed dataset
  • The following values can be given for "DataFormat":
  • "Date"dates, given as DateList specifications
    "Integer8"8-bit integers
    "Integer16"16-bit integers
    "Integer32"32-bit integers
    "UnsignedInteger8"unsigned 8-bit integers
    "UnsignedInteger16"unsigned 16-bit integers
    "UnsignedInteger32"unsigned 32-bit integers
    "Real32"IEEE singleprecision numbers
    "Real64"IEEE doubleprecision numbers
    "String"strings of ASCII characters
  • Meta-information elements:
  • "Annotations"meta-information for each dataset
    "DataEncoding"specifies how each dataset is compressed
    "DataFormat"type used to represent each dataset
    "Dimensions"data dimensions of each dataset
    "Metadata"general meta-information as a list of rules
  • "DataEncoding" can take the following values:
  • Noneno data compression is used
    "AdaptiveHuffman"adaptive Huffman encoding
    "GZIP"GZIP compression
    "Huffman"Huffman encoding
    "RLE"run-length encoding


  • Export options:
  • "Append"Falsewhether to append to an existing file
    "LargeFileSupport"Falsewhether to export a 64-bit NASA CDF file
  • With the default setting "LargeFileSupport"->False, the exported file uses a 32-bit data representation conforming to Version 2.7 of the CDF format.
  • 64-bit enhanced CDF 3.1 files can be created with "LargeFileSupport"->True.


Basic Examples  (7)

Get the dataset names:

Click for copyable input

Show the import elements available in the example file:

Click for copyable input

Read all meta-information:

Click for copyable input

Import the "LATITUDE" and "LONGITUD" datasets:

Click for copyable input

Importing the "EPOCH" dataset returns a date in the form given by DateList:

Click for copyable input

Read a data array from the example file and render it using MatrixPlot:

Click for copyable input

Rasterize the earlier graphics and export them as an array of color values to NASA CDF:

Click for copyable input

Export a list of integers to NASA CDF, explicitly specifying the dataset name:

Click for copyable input

This imports the generated NASA CDF file:

Click for copyable input

See Also

"FITS"  "HDF"  "HDF5"  "NetCDF"

Introduced in 2007
| Updated in 2010