NASACDF (.cdf)
- Import supports the NASA CDF 3.1 and earlier versions.
- The Wolfram Language by default exports NASA CDF 2.7 files and can also generate 64-bit enhanced NASA CDF 3.1 files.
Background & Context
-
- 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 & 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 following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - 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",n nth dataset "Datasets",dataset named 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 single‐precision numbers "Real64" IEEE double‐precision 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:
-
None no data compression is used "AdaptiveHuffman" adaptive Huffman encoding "GZIP" GZIP compression "Huffman" Huffman encoding "RLE" run-length encoding
Options
- Export options:
-
"Append" False whether to append to an existing file "LargeFileSupport" False whether 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.
Examples
Basic Examples (7)
Show the import elements available in the example file:
Import the "LATITUDE" and "LONGITUD" datasets:
Importing the "EPOCH" dataset returns a date in the form given by DateList:
Read a data array from the example file and render it using MatrixPlot:
Rasterize the earlier graphics and export them as an array of color values to NASA CDF:
Export a list of integers to NASA CDF, explicitly specifying the dataset name: