ugrid
Working with UGRID standard for unstrctured grids.
Functions:
as_ugrid
as_ugrid(ds: Dataset | DataArray) -> ux.UxDataset
Convert dataset DYNAMICO icosahedral grid to UGRID standard.
The conversion assumes several variable, dimension, and coordinate names are present. The result is an uxarray dataset holding the orginal data with the UGRID grid.
Example:
from ipsl_common.ugrid import as_ugrid
import xarray as xa
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ds = xa.open_dataset("start0.nc")
uxds = as_ugrid(ds)
fig, ax = plt.subplots(
subplot_kw={"projection": ccrs.EqualEarth()},
figsize=(9, 6),
constrained_layout=True,
)
ax.set_global()
raster = uxds["tracer001"][0].to_raster(ax=ax)
img = ax.imshow(
raster, cmap="viridis", origin="lower", extent=ax.get_xlim() + ax.get_ylim()
)
ax.coastlines()
cbar = fig.colorbar(img, ax=ax, fraction=0.03)
plt.show()
Parameters:
-
(dsDataset | DataArray) –input xarray dataset
Returns:
-
UxDataset–ux.UxDataset: dataset with original data redefined on the UGRID grid
Source code in ipsl_common/ugrid.py
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
match_dynamico_icosahedral_grid
match_dynamico_icosahedral_grid(
ds: Dataset | DataArray,
) -> dict | None
Match dataset variables, dimensions and coordinates to a specific DYNAMICO icosahedral grid.
The same DYNAMICO grid might be expressed by different variables, dimensions and coordinates. This function tries to match the grid to known, predefined names.
Parameters:
-
(dsDataset | DataArray) –input xarray dataset
Returns:
-
dict | None–dict | None: mapping of element names to UGRID names, or None if not a DYNAMICO grid
Source code in ipsl_common/ugrid.py
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 | |