arlmet.Grid#

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

Two-dimensional horizontal grid definition for ARL data.

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).

crs#

Coordinate reference system for the grid.

Type:

pyproj.CRS

dims#

Dimension names for the grid (“lat”, “lon”) or (“y”, “x”).

Type:

tuple

is_latlon#

True if the grid uses a lat-lon projection.

Type:

bool

origin#

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

Type:

tuple[float, float]

calculate_coords() dict[str, Any][source]#

Calculate grid coordinates in both projected and geographic systems.

fractional_indices(lon, lat)[source]#

Convert lon/lat positions to fractional grid indices.

window_from_bbox(bbox)[source]#

Resolve a geographic bounding box to an inclusive grid window.

subset(window)[source]#

Build a new Grid describing a rectangular subset.

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')

Methods

Grid.__init__(projection, nx, ny)

Grid.calculate_coords()

Grid coordinates in both projected and geographic systems.

Grid.fractional_indices(lon, lat)

Convert geographic coordinates to zero-based fractional grid indices.

Grid.full_window()

Return a GridWindow spanning the full horizontal domain.

Grid.subset(window)

Build a new grid definition for a rectangular subset.

Grid.window_from_bbox(bbox)

Resolve a geographic bounding box to grid indices.

Attributes

Grid.coords

Return the calculated coordinate variables for this grid.

Grid.crs

Coordinate reference system for this grid.

Grid.dims

Get the dimension names for this grid.

Grid.is_latlon

Check if this grid uses a lat-lon projection.

Grid.origin

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