pycsa.data.cell

Grid and topography data classes.

Moved from pycsa.core.var and refactored to use @dataclass for explicit field declarations. Behavior is preserved including the grid.apply_f convenience, which is now driven by a ClassVar exclusion list instead of a runtime-set instance attribute.

topo_cell inherits its on-disk fields (lon, lat, topo, analysis) from topo and adds methods that set further runtime attributes (lon_grid, lat_grid, mask, topo_m, …) — these are not declared as dataclass fields because they’re side products of gen_mgrids / get_masked / get_grad_topo rather than construction arguments.

Classes

grid([clat, clat_vertices, clon, ...])

ICON triangular grid: cell centers + vertex coordinates + areas.

topo([lon, lat, topo, analysis])

Topography container: 1-D lat/lon arrays + 2-D elevation + analysis.

topo_cell([lon, lat, topo, analysis])

Cell-specific topography.

class pycsa.data.cell.grid(clat: ndarray | None = None, clat_vertices: ndarray | None = None, clon: ndarray | None = None, clon_vertices: ndarray | None = None, links: ndarray | None = None, cell_area: ndarray | None = None)

ICON triangular grid: cell centers + vertex coordinates + areas.

links is a lookup table mapping cells to their topography source file; cell_area is the per-cell area in m². Both are skipped by apply_f() because they are not (lat, lon)-style data needing unit conversion.

clat: ndarray | None = None
clat_vertices: ndarray | None = None
clon: ndarray | None = None
clon_vertices: ndarray | None = None
cell_area: ndarray | None = None
NON_CONVERTIBLES = ('links', 'cell_area')
apply_f(f)

Apply f to each (lat, lon)-style attribute.

Skips NON_CONVERTIBLES. Used in the wild as grid.apply_f(utils.rad2deg) to convert radians to degrees after loading from a NetCDF.

Parameters:

f (callable) – Function applied in-place to each non-skipped, non-None field.

__init__(clat: ndarray | None = None, clat_vertices: ndarray | None = None, clon: ndarray | None = None, clon_vertices: ndarray | None = None, links: ndarray | None = None, cell_area: ndarray | None = None) None
class pycsa.data.cell.topo(lon: ndarray | None = None, lat: ndarray | None = None, topo: ndarray | None = None, analysis: Any | None = None)

Topography container: 1-D lat/lon arrays + 2-D elevation + analysis.

The analysis field is left Any because it holds a pycsa.data.results.analysis instance, but importing that here would create a circular dependency.

lon: ndarray | None = None
lat: ndarray | None = None
topo: ndarray | None = None
analysis: Any = None
__init__(lon: ndarray | None = None, lat: ndarray | None = None, topo: ndarray | None = None, analysis: Any | None = None) None
class pycsa.data.cell.topo_cell(lon: ndarray | None = None, lat: ndarray | None = None, topo: ndarray | None = None, analysis: Any | None = None)

Cell-specific topography. Inherits lon / lat / topo / analysis from topo.

gen_mgrids(grad: bool = False) None

Generate meshgrids from the 1-D lat/lon arrays.

Sets self.lon_grid and self.lat_grid (and the gradient meshgrids when grad=True). These attributes are runtime artifacts; they’re not dataclass fields.

get_masked(triangle=None, mask=None) None

Populate self.{lon_m, lat_m, topo_m} from a triangle or explicit mask. Subtracts the mean from topo_m in place.

get_grad_topo(triangle) None

Compute the topographic gradient.

Deprecated since version 0.90.0.

__init__(lon: ndarray | None = None, lat: ndarray | None = None, topo: ndarray | None = None, analysis: Any | None = None) None