Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Sep 5, 2023
1 parent 4250b11 commit 229e383
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 48 deletions.
77 changes: 54 additions & 23 deletions cf/cellconnectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,57 @@
class CellConnectivity(mixin.PropertiesData, cfdm.CellConnectivity):
"""A cell connectivity construct of the CF data model.
TODOUGRID
A cell measure construct provides information that is needed about
the size or shape of the cells and that depends on a subset of the
domain axis constructs. Cell measure constructs have to be used
when the size or shape of the cells cannot be deduced from the
dimension or auxiliary coordinate constructs without special
knowledge that a generic application cannot be expected to have.
The connectivity measure construct consists of a numeric array of the
metric data which spans a subset of the domain axis constructs,
and properties to describe the data. The connectivity measure construct
specifies a "measure" to indicate which metric of the space it
supplies, e.g. connectivity horizontal areas, and must have a units
property consistent with the measure, e.g. square metres. It is
assumed that the metric does not depend on axes of the domain
which are not spanned by the array, along which the values are
implicitly propagated. CF-netCDF connectivity measure variables correspond
to connectivity measure constructs.
A cell connectivity construct defines explicitly how cells
arranged in two or three dimensions in real space but indexed by a
single domain (discrete) axis are connected. Connectivity can only
be provided when the domain axis construct also has a domain
topology construct, and two cells can only be connected if they
also have a topological relationship. For instance, the
connectivity of two-dimensional face cells could be characterised
by whether or not they have shared edges, where the edges are
defined by connected nodes of the domain topology construct.
The cell connectivity construct consists of an array recording the
connectivity, and properties to describe the data. There must be a
property indicating the condition by which the connectivity is
derived from the domain topology. The array spans the domain axis
construct with the addition of a ragged dimension that indexes a
unique identity for the cell as well as the identities of all
other cells to which it is connected. The cell identity must be
recorded in the first element of the ragged dimension, otherwise
the order is arbitrary. Note that the connectivity array for point
cells is, by definition, equivalent to the array of the domain
topology construct.
When cell connectivity constructs are present they are considered
to be definitive and must be used in preference to the
connectivities implied by inspection of any other constructs,
apart from the domain topology construct, which are not guaranteed
to be the same.
In CF-netCDF a cell topology construct can only be provided by a
UGRID mesh topology variable. The construct array is supplied
either indirectly by any of the UGRID variables that are used to
define a domain topology construct, or directly by the UGRID
"edge_edge_connectivity" variable (for edge cells) or
"face_face_connectivity" variable (for face cells). In the direct
case, the integer indices contained in the UGRID variable may be
used as the cell identities, although the CF data model attaches
no significance to the values other than the fact that some values
are the same as others.
Restricting the types of connectivity to those implied by the
geospatial topology of the cells precludes connectivity derived
from any other sources, but is consistent with UGRID encoding
within CF-netCDF.
See CF Appendix I "The CF Data Model".
**NetCDF interface**
{{netCDF variable}}
.. versionadded:: TODOUGRIDVER
.. versionadded:: UGRIDVER
"""

Expand All @@ -44,9 +70,14 @@ def __repr__(self):

@property
def connectivity(self):
"""TODOUGRID Measure which indicates the metric of space supplied.
"""The connectivity type.
.. versionadded:: TODOUGRIDVER
{{cell connectivity type}}
.. versionadded:: UGRIDVER
.. seealso:: `del_connectivity`, `get_connectivity`,
`has_connectivity`, `set_connectivity`
"""
return self.get_connectivity(default=AttributeError())
Expand Down Expand Up @@ -78,7 +109,7 @@ def identity(
* The netCDF variable name, preceded by ``'ncvar%'``.
* The value of the *default* parameter.
.. versionadded:: TODOUGRIDVER
.. versionadded:: UGRIDVER
.. seealso:: `id`, `identities`, `long_name`, `connectivity`,
`nc_get_variable`, `standard_name`
Expand Down
107 changes: 82 additions & 25 deletions cf/domaintopology.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,84 @@
class DomainTopology(mixin.PropertiesData, cfdm.DomainTopology):
"""A domain topology construct of the CF data model.
TODOUGRID
A cell measure construct provides information that is needed about
the size or shape of the cells and that depends on a subset of the
domain axis constructs. Cell measure constructs have to be used
when the size or shape of the cells cannot be deduced from the
dimension or auxiliary coordinate constructs without special
knowledge that a generic application cannot be expected to have.
The cell measure construct consists of a numeric array of the
metric data which spans a subset of the domain axis constructs,
and properties to describe the data. The cell measure construct
specifies a "measure" to indicate which metric of the space it
supplies, e.g. cell horizontal areas, and must have a units
property consistent with the measure, e.g. square metres. It is
assumed that the metric does not depend on axes of the domain
which are not spanned by the array, along which the values are
implicitly propagated. CF-netCDF cell measure variables correspond
to cell measure constructs.
A domain topology construct defines the geospatial topology of
cells arranged in two or three dimensions in real space but
indexed by a single (discrete) domain axis construct, and at most
one domain topology construct may be associated with any such
domain axis. The topology describes topological relationships
between the cells - spatial relationships which do not depend on
the cell locations - and is represented by an undirected graph,
i.e. a mesh in which pairs of nodes are connected by links. Each
node has a unique arbitrary identity that is independent of its
spatial location, and different nodes may be spatially co-located.
The topology may only describe cells that have a common spatial
dimensionality, one of:
* Point: A point is zero-dimensional and has no boundary vertices.
* Edge: An edge is one-dimensional and corresponds to a line
connecting two boundary vertices.
* Face: A face is two-dimensional and corresponds to a surface
enclosed by a set of edges.
Each type of cell implies a restricted topology for which only
some kinds of mesh are allowed. For point cells, every node
corresponds to exactly one cell; and two cells have a topological
relationship if and only if their nodes are connected by a mesh
link. For edge and face cells, every node corresponds to a
boundary vertex of a cell; the same node can represent vertices in
multiple cells; every link in the mesh connects two cell boundary
vertices; and two cells have a topological relationship if and
only if they share at least one node.
A domain topology construct contains an array defining the mesh,
and properties to describe it. There must be a property indicating
the spatial dimensionality of the cells. The array values comprise
the node identities, and all array elements that refer to the same
node must contain the same value, which must differ from any other
value in the array. The array spans the domain axis construct and
also has a ragged dimension, whose function depends on the spatial
dimensionality of the cells.
For point cells, the array's ragged dimension values are composed
of the node identity of each cell in the first element, followed
in arbitrary order by the identity of each node to which it is
connected by a mesh link.
For edge and face cells, the array's ragged dimension values are
the node identities of the boundary vertices of each cell, in the
same order that the boundary vertices are stored by the auxiliary
coordinate constructs. Each boundary vertex except the last is
connected by a mesh link to the next vertex along the ragged
dimension, and the last vertex is connected to the first.
When a domain topology construct is present it is considered to be
definitive and must be used in preference to the topology implied
by inspection of any other constructs, which is not guaranteed to
be the same.
In CF-netCDF a domain topology construct can only be provided for
a UGRID mesh topology variable. The information in the construct
array is supplied by the UGRID "edge_nodes_connectivity" variable
(for edge cells) or "face_nodes_connectivity" variable (for face
cells). The topology for node cells may be provided by any of
these three UGRID variables. The integer indices contained in the
UGRID variable may be used as the mesh node identities, although
the CF data model attaches no significance to the values other
than the fact that some values are the same as others. The spatial
dimensionality property is provided by the "location" attribute of
a variable that references the UGRID mesh topology variable,
i.e. a data variable or a UGRID location index set variable.
See CF Appendix I "The CF Data Model".
**NetCDF interface**
{{netCDF variable}}
The netCDF variable name of the UGRID mesh topology variable may
be accessed with the `nc_set_variable`, `nc_get_variable`,
`nc_del_variable`, and `nc_has_variable` methods.
.. versionadded:: TODOUGRIDVER
.. versionadded:: UGRIDVER
"""

Expand All @@ -44,15 +97,19 @@ def __repr__(self):

@property
def cell(self):
"""TODOUGRID Measure which indicates the metric of space supplied.
"""The cell type.
.. versionadded:: TODOUGRIDVER
{{cell type}}
.. versionadded:: UGRIDVER
.. seealso:: `del_cell`, `get_cell`, `has_cell`, `set_cell`
"""
return self.get_cell(default=AttributeError())

@cell.setter
def cell(self, value):
def cell(self, value):
self.set_cell(value)

@cell.deleter
Expand All @@ -78,7 +135,7 @@ def identity(
* The netCDF variable name, preceded by ``'ncvar%'``.
* The value of the *default* parameter.
.. versionadded:: TODOUGRIDVER
.. versionadded:: UGRIDVER
.. seealso:: `id`, `identities`, `long_name`, `cell`,
`nc_get_variable`, `standard_name`
Expand Down

0 comments on commit 229e383

Please sign in to comment.