href¶
Parse Met Office deterministic forecast hrefs into structured objects.
Href
dataclass
¶
Href(
href: str,
model: Model,
theme: Theme,
parameter: str,
reference_datetime: str,
forecast_horizon: str,
)
collection_id
property
¶
Gets the STAC collection ID for this href.
Returns:
| Type | Description |
|---|---|
str
|
The collection ID string. |
datetime
property
¶
Gets the datetime from the valid time string.
Returns:
| Type | Description |
|---|---|
datetime
|
A datetime object parsed from the valid time. |
duration
property
¶
Extracts the duration from the parameter if present.
Returns:
| Type | Description |
|---|---|
str | None
|
The duration string (ISO 8601 format) if the parameter includes one, |
str | None
|
None otherwise. |
item_id
property
¶
Gets the STAC item ID for this href.
Returns:
| Type | Description |
|---|---|
str
|
The item ID string combining valid time and forecast horizon. |
__str__ ¶
parse
classmethod
¶
Parses a Met Office deterministic forecast href into an Href object.
Parses hrefs in the format: [scheme://bucket/]collection/reference_datetime/reference_datetime-forecast_horizon-parameter.nc
The model and theme are automatically extracted from the collection name and parameter, but can be overridden with the optional parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
href
|
str
|
The href string to parse. Can be a full S3 URL or a relative path. |
required |
model
|
Model | None
|
Optional model to override automatic detection. If None, inferred from the collection name (global-deterministic-10km or uk-deterministic-2km). |
None
|
theme
|
Theme | None
|
Optional theme to override automatic detection. If None, inferred from the parameter name. |
None
|
Returns:
| Type | Description |
|---|---|
Href
|
An Href object containing parsed components including model, theme, |
Href
|
parameter, reference_datetime, valid_time, and forecast_horizon. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the href format is invalid, contains an unknown collection, or contains an unknown parameter (when theme inference is required). |