Skip to content

constants

Constant values and string enums.

Model

Bases: StrEnum

bbox property

bbox: tuple[float, float, float, float]

Gets the bounding box for the model.

Returns:

Type Description
tuple[float, float, float, float]

A tuple of (min_lon, min_lat, max_lon, max_lat).

Raises:

Type Description
ValueError

If the model is unexpected.

extent property

extent: Extent

Gets the STAC extent for the model.

Returns:

Type Description
Extent

A STAC Extent object with spatial and temporal extents.

geometry property

geometry: dict[str, Any]

Gets the GeoJSON geometry for the model coverage area.

Returns:

Type Description
dict[str, Any]

A GeoJSON geometry dictionary.

Raises:

Type Description
ValueError

If the model is unexpected.

proj_wkt2 property

proj_wkt2: str

Returns the WKT2 coordinate reference system.

get_collection_id

get_collection_id(theme: Theme) -> str

Generates the collection ID for a model and theme combination.

Parameters:

Name Type Description Default
theme Theme

The theme to combine with this model.

required

Returns:

Type Description
str

The collection ID string.

Source code in src/stactools/met_office_deterministic/constants.py
def get_collection_id(self, theme: Theme) -> str:
    """Generates the collection ID for a model and theme combination.

    Args:
        theme: The theme to combine with this model.

    Returns:
        The collection ID string.
    """
    return f"met-office-{self}-deterministic-{theme}"

Theme

Bases: StrEnum

from_parameter classmethod

from_parameter(parameter: str) -> Theme

Determines the theme from a parameter name.

Parameters:

Name Type Description Default
parameter str

The parameter name to classify.

required

Returns:

Type Description
Theme

The Theme corresponding to the parameter.

Raises:

Type Description
ValueError

If the parameter is unknown.

Source code in src/stactools/met_office_deterministic/constants.py
@classmethod
def from_parameter(cls, parameter: str) -> Theme:
    """Determines the theme from a parameter name.

    Args:
        parameter: The parameter name to classify.

    Returns:
        The Theme corresponding to the parameter.

    Raises:
        ValueError: If the parameter is unknown.
    """
    match parameter:
        case (
            "cloud_amount_on_height_levels"
            | "temperature_on_height_levels"
            | "wind_direction_on_height_levels"
            | "wind_speed_on_height_levels"
        ):
            return Theme.height
        case (
            "fog_fraction_at_screen_level"
            | "visibility_at_screen_level"
            | "pressure_at_mean_sea_level"
            | "pressure_at_surface"
            | "precipitation_rate"
            | "precipitation_accumulation-PT01H"
            | "precipitation_accumulation-PT03H"
            | "precipitation_accumulation-PT06H"
            | "rainfall_accumulation-PT01H"
            | "rainfall_accumulation-PT03H"
            | "rainfall_accumulation-PT06H"
            | "rainfall_rate"
            | "rainfall_rate_from_convection"
            | "rainfall_rate_from_convection_max-PT01H"
            | "rainfall_rate_from_convection_max-PT03H"
            | "rainfall_rate_from_convection_max-PT06H"
            | "radiation_flux_in_uv_downward_at_surface"
            | "radiation_flux_in_longwave_downward_at_surface"
            | "radiation_flux_in_shortwave_direct_downward_at_surface"
            | "radiation_flux_in_shortwave_total_downward_at_surface"
            | "radiation_flux_in_shortwave_diffuse_downward_at_surface"
            | "snow_depth_water_equivalent"
            | "snowfall_rate"
            | "snowfall_accumulation-PT01H"
            | "snowfall_accumulation-PT03H"
            | "snowfall_rate_from_convection"
            | "snowfall_rate_from_convection_mean-PT01H"
            | "snowfall_rate_from_convection_mean-PT03H"
            | "snowfall_rate_from_convection_mean-PT06H"
            | "snowfall_rate_from_convection_max-PT01H"
            | "snowfall_rate_from_convection_max-PT03H"
            | "snowfall_rate_from_convection_max-PT06H"
            | "hail_fall_rate"
            | "hail_fall_accumulation-PT01H"
            | "height_of_orography"
            | "temperature_at_screen_level"
            | "temperature_at_surface"
            | "temperature_at_screen_level_max-PT01H"
            | "temperature_at_screen_level_max-PT03H"
            | "temperature_at_screen_level_max-PT06H"
            | "temperature_at_screen_level_min-PT01H"
            | "temperature_at_screen_level_min-PT03H"
            | "temperature_at_screen_level_min-PT06H"
            | "temperature_of_dew_point_at_screen_level"
            | "wind_direction_at_10m"
            | "wind_speed_at_10m"
            | "wind_gust_at_10m"
            | "wind_gust_at_10m_max-PT01H"
            | "wind_gust_at_10m_max-PT03H"
            | "wind_gust_at_10m_max-PT06H"
            | "sensible_heat_flux_at_surface"
            | "latent_heat_flux_at_surface_mean-PT01H"
            | "latent_heat_flux_at_surface_mean-PT03H"
            | "latent_heat_flux_at_surface_mean-PT06H"
            | "relative_humidity_at_screen_level"
            | "landsea_mask"
        ):
            return Theme.near_surface
        case (
            "height_ASL_on_pressure_levels"
            | "temperature_on_pressure_levels"
            | "wet_bulb_potential_temperature_on_pressure_levels"
            | "wind_speed_on_pressure_levels"
            | "wind_direction_on_pressure_levels"
            | "wind_vertical_velocity_on_pressure_levels"
            | "relative_humidity_on_pressure_levels"
            | "geopotential_height_on_pressure_levels"
        ):
            return Theme.pressure_level

        case (
            "cloud_amount_of_total_cloud"
            | "cloud_amount_of_high_cloud"
            | "cloud_amount_of_medium_cloud"
            | "cloud_amount_of_low_cloud"
            | "cloud_amount_below_1000ft_ASL"
            | "height_AGL_at_cloud_base_where_cloud_cover_2p5_oktas"
            | "cloud_amount_of_total_convective_cloud"
            | "pressure_at_tropopause"
            | "lightning_flash_accumulation-PT01H"
            | "temperature_at_tropopause"
            | "CAPE_most_unstable_below_500hPa"
            | "CAPE_surface"
            | "CAPE_mixed_layer_lowest_500m"
            | "CIN_surface"
            | "CIN_mixed_layer_lowest_500m"
            | "CIN_most_unstable_below_500hPa"
            | "height_AGL_at_wet_bulb_freezing_level"
            | "height_AGL_at_freezing_level"
        ):
            return Theme.whole_atmosphere
        case _:
            raise ValueError(f"Unknown parameter: {parameter}")