arlmet.Grid#

class arlmet.Grid(projection, nx, ny)[source]#

Two-dimensional horizontal grid definition for ARL data.

Grids are immutable, hashable value objects (the derived crs and origin are computed once and cached). Use subset() or dataclasses.replace() to derive a new grid.

Parameters:
  • projection (Projection) – Grid projection metadata.

  • nx (int) – Number of grid points in the x-direction (columns).

  • ny (int) – Number of grid points in the y-direction (rows).

Examples

>>> from arlmet._grid import Grid, Projection
>>> proj = Projection(
...     pole_lat=90.0,
...     pole_lon=180.0,
...     tangent_lat=1.0,
...     tangent_lon=1.0,
...     grid_size=0.0,
...     orientation=0.0,
...     cone_angle=0.0,
...     sync_x=1.0,
...     sync_y=1.0,
...     sync_lat=40.0,
...     sync_lon=-120.0,
... )
>>> grid = Grid(projection=proj, nx=3, ny=2)
>>> tuple(grid.dims)
('lat', 'lon')

Attributes

crs

Coordinate reference system for this grid.

dims

Get the dimension names for this grid.

is_latlon

Check if this grid uses a lat-lon projection.

origin

Origin (lower-left corner) in the base CRS.

wraps_lon

Whether the grid is lat/lon and its columns span all 360 degrees of longitude.

Methods

calculate_coords()

Grid coordinates in both projected and geographic systems.

fractional_indices(lon, lat)

Convert geographic coordinates to zero-based fractional grid indices.

full_window()

Return a GridWindow spanning the full horizontal domain.

meridian_convergence(lon, lat)

Angle from true north to the grid's y-axis at each point, in degrees.

rotate_winds(u, v, lon, lat)

Rotate grid-relative wind components to earth-relative ones.

subset(window)

Build a new grid definition for a rectangular subset.

window_from_bbox(bbox, *[, bbox_crs])

Resolve a bounding box to grid indices.