cfdm.DomainTopology.normalise¶
-
DomainTopology.
normalise
(start_index=0, remove_empty_columns=False, inplace=False)[source]¶ Normalise the data values.
Normalised data is in a form that is suitable for creating a CF-netCDF UGRID “edge_node_connectivity” or “face_node_connectivity” variable.
Normalisation does not change the logical content of the data. It converts the data so that the set of values comprises all of the integers in the range
[0, N-1]
(if the start_index parameter is0
), or[1, N]
(if start_index is1
), whereN
is the number of mesh nodes.New in version (cfdm): 1.11.0.0
- Parameters
- start_index:
int
, optional The start index for the data values in the normalised data. Must be
0
(the default) or1
for zero- or one-based indices respectively.- remove_empty_columns:
bool
, optional If True then remove any array columns that are entirely missing data. By default these are retained.
- inplace:
bool
, optional If True then do the operation in-place and return
None
.
- start_index:
- Returns
DomainTopology
orNone
The normalised domain topology construct, or
None
if the operation was in-place.
**Examples*
Face cells (similarly for edge cells):
>>> data = cfdm.Data( ... [[1, 4, 5, 2], [4, 10, 1, -99], [122, 123, 106, 105]], ... mask_value=-99 ... ) >>> d = cfdm.DomainTopology(cell='face', data=data) >>> print(d.array) [[1 4 5 2] [4 10 1 --] [122 123 106 105]] >>> d0 = d.normalise() >>> print(c.array) [[0 2 3 1] [2 4 0 --] [7 8 6 5]] >>> (d0.array == d.normalise().array).all() True >>> d1 = d.normalise(start_index=1) >>> print(d1.array) [[1 3 4 2] [3 5 1 --] [8 9 7 6]] >>> (d1.array == d0.array + 1).all() True
Point cells:
>>> data = cfdm.Data( ... [[4, 1, 10, 125], [1, 4, -99, -99], [125, 4, -99, -99]], ... mask_value=-99 ... ) >>> d = cfdm.DomainTopology(cell='point', data=data) >>> print(d.array) [[4 1 10 125] [1 4 -- --] [125 4 -- --]] >>> print(d.normalise().array) [[0 1 2] [1 0 --] [2 0 --]] >>> print(d.normalise(start_index=1).array) [[1 2 3] [2 1 --] [3 1 --]]