pydsstools.core.gridinfo.base

Base classes and common utilities for grid metadata.

This module provides the abstract base class and shared functionality for all grid metadata types. It also includes type-checking utilities.

Functions

is_albers_grid(grid_type)

Check if grid type is Albers Equal Area Conic projection.

is_hrap_grid(grid_type)

Check if grid type is HRAP (Hydrologic Rainfall Analysis Project).

is_specified_grid(grid_type)

Check if grid type uses user-specified projection.

is_undefined_grid(grid_type)

Check if grid type is undefined.

Classes

GridInfoBase(**data)

Abstract base class for all DSS Version 7 grid metadata structures.

pydsstools.core.gridinfo.base.is_undefined_grid(grid_type)[source]

Check if grid type is undefined.

Variables:

grid_type (GridType) – The grid type enumeration value.

Returns:

True if grid type is undefined or undefined_time.

Return type:

bool

Examples

>>> is_undefined_grid(GridType.undefined)
True
>>> is_undefined_grid(GridType.hrap)
False
pydsstools.core.gridinfo.base.is_hrap_grid(grid_type)[source]

Check if grid type is HRAP (Hydrologic Rainfall Analysis Project).

HRAP uses a polar stereographic projection centered on the North Pole.

Parameters:

grid_type (GridType) – The grid type enumeration value.

Returns:

True if grid type is hrap or hrap_time.

Return type:

bool

Examples

>>> is_hrap_grid(GridType.hrap_time)
True
>>> is_hrap_grid(GridType.albers)
False
pydsstools.core.gridinfo.base.is_albers_grid(grid_type)[source]

Check if grid type is Albers Equal Area Conic projection.

Commonly used for Standard Hydrologic Grid (SHG) in HEC-HMS.

Parameters:

grid_type (GridType) – The grid type enumeration value.

Returns:

True if grid type is albers or albers_time.

Return type:

bool

Examples

>>> is_albers_grid(GridType.albers_time)
True
>>> is_albers_grid(GridType.specified)
False
pydsstools.core.gridinfo.base.is_specified_grid(grid_type)[source]

Check if grid type uses user-specified projection.

Specified grids use custom CRS definitions (WKT, PROJ, EPSG codes).

Parameters:

grid_type (GridType) – The grid type enumeration value.

Returns:

True if grid type is specified or specified_time.

Return type:

bool

Examples

>>> is_specified_grid(GridType.specified_time)
True
>>> is_specified_grid(GridType.hrap)
False
class pydsstools.core.gridinfo.base.GridInfoBase(**data)[source]

Bases: BaseModel

Abstract base class for all DSS Version 7 grid metadata structures.

This base class provides common functionality shared across all grid types: - Dynamic extra field handling - Coordinate system inference - Grid validation - DSS v6 compatibility

All concrete grid info classes (GridInfo, HrapInfo, AlbersInfo, SpecifiedInfo) inherit from this base.

Variables:

extra (dict[str, Any]) – Dictionary storing any additional fields not defined in the schema. Allows for extensibility without breaking validation.

Notes

This is an abstract base class. Use one of the concrete subclasses: - GridInfo (undefined grids) - HrapInfo (HRAP projection) - AlbersInfo (Albers projection) - SpecifiedInfo (user-defined projection)

Or use the GridInfoCreate factory function which automatically selects the appropriate subclass based on grid_type.

extra
property extra_info

Get dictionary of extra fields not in the schema.

Returns:

Dictionary containing all extra/unknown fields.

Return type:

dict[str, Any]

property all_info

Get complete dictionary of all fields including extras.

Returns:

Complete dictionary representation using Pydantic’s model_dump.

Return type:

dict[str, Any]

get_v6_grid_type()[source]

Get equivalent DSS Version 6 grid type.

Converts DSS v7 grid types to their v6 equivalents. All v6 grids include time information (time-varying grids).

Returns:

The equivalent DSS v6 grid type (always the *_time variant).

Return type:

GridType

has_time()[source]

Check if grid type includes time information.

Returns:

True if grid type is a *_time variant.

Return type:

bool

normalize(transform=None)[source]

Normalize coords_cell0 and/or lower_left_cell based on grid_type.

This is implemented in the concrete classes.

Parameters:

transform (Affine or None, optional) – Affine transform of grid or raster data. Default is None.