NetCDFFile
A class for reading and writing to NetCDF files
Declaration
classdef NetCDFFile < handleOverview
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
NetCDFFileinitialize an from existing or create new file
- Accessing file properties
- Working with dimensions
addDimensionAdds a both a new dimension and its associated coordinate variable to the NetCDF file.dimensionWithNamekey-value Map to retrieve a NetCDFDimension object by namedimensionsarray of NetCDFDimension objectsdimensionsForDimIDsreturn the dimension IDs given the dimension names
- Working with variables
addVariableadd a new (real or complex) variable to the filecomplexVariableWithNamekey-value Map to retrieve a NetCDFComplexVariable object by namecomplexVariablesarray of NetCDFComplexVariable objectsconcatenateVariableAlongDimensionappend new data to an existing variableinitComplexVariableinitialize a complex-valued variableinitVariableinitialize a real-valued variablereadVariablesread variables from filereadVariablesAtIndexAlongDimensionread variables from file at a particular index (e.g., time)setVariableadd data for a variable with a given namevariableWithNamekey-value Map to retrieve a NetCDFVariable object by namevariablesarray of NetCDFVariable objects
- Working with global attributes
addAttributeadd a global attribute to the fileattributeskey-value Map of global attributes
- Schema keys
GLNetCDFSchemaUnitsKeyUnits of the variable or dimension- Dimensions
GLNetCDFSchemaBasisFunctionKeyWhat basis function describe this dimensionGLNetCDFSchemaDomainLengthKeyThe length of the domainGLNetCDFSchemaDomainMinimumKeyThe minimum value of the domainGLNetCDFSchemaGridTypeKeytype of gridGLNetCDFSchemaIsCoordinateVariableKeyA Boolean value that indicates whether the dimension is associated with a coordinate variableGLNetCDFSchemaIsEvenlySampledKeyA Boolean value that indicates whether the dimension has even samplingGLNetCDFSchemaIsFrequencyDomainKeyA Boolean value that indicates whether the dimension is considered in the frequency (spectral) domainGLNetCDFSchemaIsPeridiocKeyA Boolean value that indicates whether the dimension is periodicGLNetCDFSchemaMutableKeyA Boolean value that indicates whether the dimension is mutableGLNetCDFSchemaSampleIntervalKeysample interval of the domain, if it is evenly sampled
- Variables
GLNetCDFSchemaIsComplexKeyA Boolean value that indicates whether the variable is complex valuedGLNetCDFSchemaIsImaginaryPartKeyA Boolean value that indicates whether this is the complex part of the variableGLNetCDFSchemaIsRealPartKeyA Boolean value that indicates whether this is the real part of the variableGLNetCDFSchemaIsRowVectorKeyA Boolean value that indicates whether the variable was defined as a row vectorGLNetCDFSchemaProperNameKeyHuman readable name of the variableGLNetCDFSchemaUniqueVariableIDKeyA custom unique variable ID
- Other
GLNetCDFSchemaVersionKey- Topic: Schema keysInitializeFromExistingFileaddMutableDimensionclose- Topic: Accessing file propertiescreateNewFiledumpnetCDF3TypeForDatanetCDFTypeForDataopen- Topic: Accessing file propertiessync- Topic: Accessing file propertiestypeStringForTypeID