NetCDFFile
A class for reading and writing to NetCDF files
Declaration
classdef NetCDFFile < handle
Overview
NetCDF files are a standard file format for reading and writing data.
This class is designed to simplify the task of adding new dimensions,
variables, and attributes to a NetCDF file compared to using the
built-in ncread
and ncwrite
functions.
ncfile = NetCDFFile('myfile.nc')
% create two new dimensions and add them to the file
x = linspace(0,10,11);
y = linspace(-10,0,11);
ncfile.addDimension('x',x);
ncfile.addDimension('y',y);
% Create new multi-dimensional variables, and add those to the file
[X,Y] = ncgrid(x,y);
ncfile.addVariable(X,{'x','y'});
ncfile.addVariable(Y,{'x','y'});
Topics
- Initializing
NetCDFFile
initialize an from existing or create new file
- Accessing file properties
- Working with dimensions
addDimension
Adds a both a new dimension and its associated coordinate variable to the NetCDF file.dimensionWithName
key-value Map to retrieve a NetCDFDimension object by namedimensions
array of NetCDFDimension objectsdimensionsForDimIDs
return the dimension IDs given the dimension names
- Working with variables
addVariable
add a new (real or complex) variable to the filecomplexVariableWithName
key-value Map to retrieve a NetCDFComplexVariable object by namecomplexVariables
array of NetCDFComplexVariable objectsconcatenateVariableAlongDimension
append new data to an existing variableinitComplexVariable
initialize a complex-valued variableinitVariable
initialize a real-valued variablereadVariables
read variables from filereadVariablesAtIndexAlongDimension
read variables from file at a particular index (e.g., time)setVariable
add data for a variable with a given namevariableWithName
key-value Map to retrieve a NetCDFVariable object by namevariables
array of NetCDFVariable objects
- Working with global attributes
addAttribute
add a global attribute to the fileattributes
key-value Map of global attributes
- Schema keys
GLNetCDFSchemaUnitsKey
Units of the variable or dimension- Dimensions
GLNetCDFSchemaBasisFunctionKey
What basis function describe this dimensionGLNetCDFSchemaDomainLengthKey
The length of the domainGLNetCDFSchemaDomainMinimumKey
The minimum value of the domainGLNetCDFSchemaGridTypeKey
type of gridGLNetCDFSchemaIsCoordinateVariableKey
A Boolean value that indicates whether the dimension is associated with a coordinate variableGLNetCDFSchemaIsEvenlySampledKey
A Boolean value that indicates whether the dimension has even samplingGLNetCDFSchemaIsFrequencyDomainKey
A Boolean value that indicates whether the dimension is considered in the frequency (spectral) domainGLNetCDFSchemaIsPeridiocKey
A Boolean value that indicates whether the dimension is periodicGLNetCDFSchemaMutableKey
A Boolean value that indicates whether the dimension is mutableGLNetCDFSchemaSampleIntervalKey
sample interval of the domain, if it is evenly sampled
- Variables
GLNetCDFSchemaIsComplexKey
A Boolean value that indicates whether the variable is complex valuedGLNetCDFSchemaIsImaginaryPartKey
A Boolean value that indicates whether this is the complex part of the variableGLNetCDFSchemaIsRealPartKey
A Boolean value that indicates whether this is the real part of the variableGLNetCDFSchemaIsRowVectorKey
A Boolean value that indicates whether the variable was defined as a row vectorGLNetCDFSchemaProperNameKey
Human readable name of the variableGLNetCDFSchemaUniqueVariableIDKey
A custom unique variable ID
- Other
GLNetCDFSchemaVersionKey
- Topic: Schema keysInitializeFromExistingFile
addMutableDimension
close
- Topic: Accessing file propertiescreateNewFile
dump
netCDF3TypeForData
netCDFTypeForData
open
- Topic: Accessing file propertiessync
- Topic: Accessing file propertiestypeStringForTypeID