Skip to content

NctoolboxClasses

drf5n edited this page May 6, 2014 · 8 revisions

##The Big Picture UML Diagram of nctoolbox classes

For those who don't read UML, this means that cfdataset is a subclass of ncdataset. (I'll get to what a subclass is in a minute). In turn, ncgeodataset is a subclass of cfdataset. Also, cfdataset references ncvariable, while ncgeodataset references ncgeovariable.

So, you may be wondering what that means. In a nutshell, a subclass can do everything the parent class does but it also may do more things and/or do things slightly differently than the parent. (Got that?).

###Methods that ncdataset, cfdataset and ncgeodataset have in common

All 3 classes (ncdataset, cfdataset and ncgeodataset) have the following methods that act exactly the same:

  • attribute - Returns the value a global attribute specified by its key or the variable attribute specified by key and variable.
  • attributes - Returns the value a global attribute specified by its key or the variable attribute specified by key and variable.
  • axes - Returns a cell array containing the variable names of coordinate axes for the given variable.
  • data - Fetch the data for a given variable. This method also allows you to fetch subsets of the data by specifying the index of the first and last points as well as a stride (or spacing)
  • mdata - (develop branch only) Fetch the data for a given variable. This method also allows you to fetch subsets of the data by specifying hyperslabs using matlab-like syntax.
  • save - Save the data to a local netcdf file
  • size - Returns the size of the variable in the persistent store without fetching the data. Helps to know what you're getting yourself into. ;-)
  • time - Attempts to convert data to Matlab's native time format

###Methods that ncgeodataset, cfdataset have in common. (But ncdataset doesn't do) ===

cfdataset adds some methods that are aware of CF and COARDS conventions; ncgeodataset inherits these so it has the same methods too. These methods make it a little more convient to use datasets that follow these conventions. The new methods are:

  • grid - Retrieve all or a subset of the coordinate data for the variable. The data is returned as a structure containing a variable for each dimension of the data. The data for the variable is NOT returned ONLY the coordinate data for the variable is returned!!!
  • standard_name - Returns a standard_name for a variable, if it exists (usually this is a 'standard_name' attribute on a variable)
  • struct - Retrieve all or a subset of the data for the given variable. The data is returned as a structure containing a variable for the data as well as for each dimension of the data.

####Q:

The UML shows that cfdataset references ncvariable objects. What are those for?

####A:

You can use those directly, but honestly, I wouldn't. cfdataset use ncvariables internally to group data for the grid and struct functions.

###Methods unique to ncgeodataset

ncgeodataset adds features that make it easier to work with datasets based around a geographic coordinate system. It also supports Matlab-style matrix indexing, which ncdataset and cfdataset do not have. The additional methods it supports are:

  • metadata - Function to grab all of the attributes (global and variables) all at once.
  • timextent - Function to calculate the start and stop times of for a variable.

Pardon our dust, we're working hard on updating the documentation

Clone this wiki locally