CDM¶
The Common Data Model (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
¶ A class to 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
¶ A 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)¶ A Dimension is used to 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)¶ A Group holds dimensions and variables. Every CDM dataset has at least a root group.
Initialize this
Group
. Instead of constructing aGroup
directly, you should usecreateGroup()
.Parameters: See also
-
__init__
(parent, name)¶ Initialize this
Group
. Instead of constructing aGroup
directly, you should usecreateGroup()
.Parameters: See also
-
createDimension
(name, size)¶ Create a new
Dimension
in 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)¶ A Variable holds typed data (using a
numpy.ndarray
), as well as any relevant 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.ndarray
instances.Initialize a Variable. Instead of constructing a Variable directly, you should use
Group.createVariable()
.Parameters: - group (Group) – The parent
Group
that 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
Group
that 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
-
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] – a tuple of integers describing the size of the Variable along each of its dimensions
-
size
¶ int – the total number of elements
- group (Group) – The parent