Connectivity#
Wrapper for UGRID connectivity arrays that handles start_index
normalization (always 0-indexed internally) and _FillValue
masking for mixed-element meshes.
pyramids.netcdf.ugrid.Connectivity
dataclass
#
Wrapper for UGRID connectivity arrays.
Handles start_index normalization (always 0-indexed internally) and fill_value masking for mixed-element meshes. Connectivity arrays map between mesh elements (e.g., face-to-node, edge-to-node).
Attributes:
| Name | Type | Description |
|---|---|---|
data |
ndarray
|
Index array, always 0-indexed internally. Shape is (n_elements, max_nodes_per_element). |
fill_value |
int
|
Value used to pad rows for elements with fewer nodes than max_nodes_per_element. Default: -1. |
cf_role |
str
|
UGRID cf_role string (e.g., "face_node_connectivity"). |
original_start_index |
int
|
Original start_index from the file (0 or 1). |
Source code in src/pyramids/netcdf/ugrid/connectivity.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
n_elements
property
#
Number of elements (rows in the connectivity array).
max_nodes_per_element
property
#
Maximum number of nodes per element (columns).
from_gdal_array(md_arr, cf_role)
classmethod
#
Read connectivity from a GDAL MDArray, normalizing start_index.
Reads the raw index array, subtracts start_index if it is 1, and replaces the original fill value with -1 for internal use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
md_arr
|
MDArray
|
GDAL MDArray containing the connectivity data. |
required |
cf_role
|
str
|
The cf_role attribute value for this connectivity. |
required |
Returns:
| Type | Description |
|---|---|
Connectivity
|
Connectivity instance with 0-indexed data. |
Source code in src/pyramids/netcdf/ugrid/connectivity.py
get_element(idx)
#
Return valid node indices for a single element.
Excludes fill values, returning only the actual node indices that define this element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Element index (row in the connectivity array). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
1D array of valid node indices for the element. |
Source code in src/pyramids/netcdf/ugrid/connectivity.py
nodes_per_element()
#
Return the number of valid nodes per element.
Returns:
| Type | Description |
|---|---|
ndarray
|
1D integer array of length n_elements with the count |
ndarray
|
of valid (non-fill) nodes for each element. |
Source code in src/pyramids/netcdf/ugrid/connectivity.py
is_triangular()
#
Check if all elements have exactly 3 nodes.
Returns:
| Type | Description |
|---|---|
bool
|
True if every element has exactly 3 valid nodes. |
Source code in src/pyramids/netcdf/ugrid/connectivity.py
as_masked()
#
Return a masked array with fill values masked.
Returns:
| Type | Description |
|---|---|
MaskedArray
|
MaskedArray where positions with fill_value are masked. |