CDM¶
Tools for mimicing the API of the Common Data Model (CDM).
The CDM is a data model for representing a wide array of data. The goal is to be a simple, universal interface to different datasets. This API is a Python implementation in the spirit of the original Java interface in netCDF-Java.
-
class
metpy.io.cdm.AttributeContainer¶ Handle maintaining a list of netCDF attributes.
Implements the attribute handling for other CDM classes.
Initialize an
AttributeContainer.-
__init__()¶ Initialize an
AttributeContainer.
-
ncattrs()¶ Get a list of the names of the netCDF attributes.
Returns: List[str]
-
-
class
metpy.io.cdm.Dataset¶ Represents a set of data using the Common Data Model (CDM).
This is currently only a wrapper around the root Group.
Initialize a Dataset.
-
__init__()¶ Initialize a Dataset.
-
-
class
metpy.io.cdm.Dimension(group, name, size=None)¶ Represent a shared dimension between different Variables.
For instance, variables that are dependent upon a common set of times.
Initialize a Dimension.
Instead of constructing a Dimension directly, you should use
Group.createDimension.Parameters: See also
-
__init__(group, name, size=None)¶ Initialize a Dimension.
Instead of constructing a Dimension directly, you should use
Group.createDimension.Parameters: See also
-
group()¶ Get the Group that owns this Dimension.
Returns: Group – The parent Group.
-
name= None¶ desc – The name of the Dimension :type: str
-
size= None¶ desc – The size of this Dimension :type: int
-
-
class
metpy.io.cdm.Group(parent, name)¶ Holds dimensions and variables.
Every CDM dataset has at least a root group.
Initialize this
Group.Instead of constructing a
Groupdirectly, you should usecreateGroup().Parameters: See also
-
__init__(parent, name)¶ Initialize this
Group.Instead of constructing a
Groupdirectly, you should usecreateGroup().Parameters: See also
-
createDimension(name, size)¶ Create a new
Dimensionin thisGroup.Parameters: Returns: Dimension – The newly created
Dimension
-
createGroup(name)¶ Create a new Group as a descendant of this one.
Parameters: name (str) – The name of the new Group. Returns: Group – The newly created Group
-
createVariable(name, datatype, dimensions=(), fill_value=None, wrap_array=None)¶ Create a new Variable in this Group.
Parameters: - name (str) – The name of the new Variable.
- datatype (str or numpy.dtype) – A valid Numpy dtype that describes the layout of the data within the Variable.
- dimensions (tuple[str], optional) – The dimensions of this Variable. Defaults to empty, which implies a scalar variable.
- fill_value (number, optional) – A scalar value that is used to fill the created storage. Defaults to None, which performs no filling, leaving the storage uninitialized.
- wrap_array (numpy.ndarray, optional) – Instead of creating an array, the Variable instance will assume ownership of the passed in array as its data storage. This is a performance optimization to avoid copying large data blocks. Defaults to None, which means a new array will be created.
Returns: Variable – The newly created
Variable
-
dimensions= None¶ desc – Dimensions contained within this group :type: dict[str, Dimension]
-
groups= None¶ desc – Any Groups nested within this one :type: dict[str, Group]
-
variables= None¶ desc – Variables contained within this group :type: dict[str, Variable]
-
-
class
metpy.io.cdm.Variable(group, name, datatype, dimensions, fill_value, wrap_array)¶ Holds typed data (using a
numpy.ndarray), as well as attributes (e.g. units).In addition to its various attributes, the Variable supports getting and setting data using the
[]operator and indices or slices. Getting data returnsnumpy.ndarrayinstances.Initialize a Variable.
Instead of constructing a Variable directly, you should use
Group.createVariable().Parameters: - group (Group) – The parent
Groupthat owns this Variable. - name (str) – The name of this Variable.
- datatype (str or numpy.dtype) – A valid Numpy dtype that describes the layout of each element of the data
- dimensions (tuple[str], optional) – The dimensions of this Variable. Defaults to empty, which implies a scalar variable.
- fill_value (scalar, optional) – A scalar value that is used to fill the created storage. Defaults to None, which performs no filling, leaving the storage uninitialized.
- wrap_array (numpy.ndarray, optional) – Instead of creating an array, the Variable instance will assume ownership of the passed in array as its data storage. This is a performance optimization to avoid copying large data blocks. Defaults to None, which means a new array will be created.
See also
-
__init__(group, name, datatype, dimensions, fill_value, wrap_array)¶ Initialize a Variable.
Instead of constructing a Variable directly, you should use
Group.createVariable().Parameters: - group (Group) – The parent
Groupthat owns this Variable. - name (str) – The name of this Variable.
- datatype (str or numpy.dtype) – A valid Numpy dtype that describes the layout of each element of the data
- dimensions (tuple[str], optional) – The dimensions of this Variable. Defaults to empty, which implies a scalar variable.
- fill_value (scalar, optional) – A scalar value that is used to fill the created storage. Defaults to None, which performs no filling, leaving the storage uninitialized.
- wrap_array (numpy.ndarray, optional) – Instead of creating an array, the Variable instance will assume ownership of the passed in array as its data storage. This is a performance optimization to avoid copying large data blocks. Defaults to None, which means a new array will be created.
See also
- group (Group) – The parent
-
datatype¶ numpy.dtype – Describes the layout of each element of the data.
-
dtype¶ numpy.dtype – Describes the layout of each element of the data.
-
group()¶ Get the Group that owns this Variable.
Returns: Group – The parent Group.
-
name¶ str – the name of the variable.
-
ndim¶ int – the number of dimensions used by this variable.
-
shape¶ tuple[int] – Describes the size of the Variable along each of its dimensions.
-
size¶ int – the total number of elements.
- group (Group) – The parent