rolodex.forecast.forecast_index

Module Contents

rolodex.forecast.forecast_index.Timestamp[source]
rolodex.forecast.forecast_index.Timedelta[source]
rolodex.forecast.forecast_index.create_lazy_valid_time_variable(*, reference_time, period)[source]
class rolodex.forecast.forecast_index.Model[source]

Bases: enum.StrEnum

Enum where members are also (and must be) strings

HRRR[source]
class rolodex.forecast.forecast_index.ModelRun(time)[source]

The complete results for a single run is a model run dataset.

Parameters:
time: Timestamp-like

Initialization time for model run

time: pandas.Timestamp[source]
get_indexer(model, time_index, period_index)[source]
class rolodex.forecast.forecast_index.ConstantOffset(step)[source]

A constant offset dataset is created from all the data that have the same offset time. Offset here refers to a variable usually named step or lead or with CF standard name forecast_period.

step: pandas.Timedelta[source]
get_indexer(model, time_index, period_index)[source]
class rolodex.forecast.forecast_index.ConstantForecast(time)[source]

A constant forecast dataset is created from all the data that have the same forecast/valid time.

Parameters:
time: Timestamp-like
time: pandas.Timestamp[source]
get_indexer(model, time_index, period_index)[source]
class rolodex.forecast.forecast_index.BestEstimate[source]

For each forecast time in the collection, the best estimate for that hour is used to create a best estimate dataset, which covers the entire time range of the collection.

asof: pandas.Timestamp | None = None[source]
offset: int = 0[source]
__post_init__()[source]
get_indexer(model, time_index, period_index)[source]
class rolodex.forecast.forecast_index.Indexes[source]
reference_time: xarray.indexes.PandasIndex[source]
period: xarray.indexes.PandasIndex[source]
get_names()[source]
class rolodex.forecast.forecast_index.ForecastIndex(variables, valid_time_name, model=None)[source]

Bases: xarray.Index

An Xarray custom Index that allows indexing a forecast data-cube with forecast_reference_time (commonly init) and forecast_period (commonly step or lead) dimensions as _Forecast Model Run Collections_.

Examples

To do FMRC-style indexing, you’ll need to first add a “valid time” variable.

>>> from rolodex.forecast import (
...     BestEstimate,
...     ConstantForecast,
...     ConstantOffset,
...     ForecastIndex,
...     ModelRun,
...     Model,
...     create_lazy_valid_time_variable,
... )
>>> ds.coords["valid_time"] = create_lazy_valid_time_variable(
...     reference_time=ds.time, period=ds.step
... )

Create the new index where time is the forecast_reference_time dimension, and step is the forecast_period dimension. >>> newds = ds.drop_indexes([“time”, “step”]).set_xindex(

[“time”, “step”, “valid_time”], ForecastIndex, model=Model.HRRR )

>>> newds

Use valid_time to indicate FMRC-style indexing

>>> newds.sel(valid_time=BestEstimate())
>>> newds.sel(valid_time=ConstantForecast("2024-05-20"))
>>> newds.sel(valid_time=ConstantOffset("32h"))
>>> newds.sel(valid_time=ModelRun("2024-05-20 13:00"))
valid_time_name[source]
model = None[source]
names[source]
classmethod from_variables(variables, options)[source]

Must be created from three variables: 1. A dummy scalar forecast variable. 2. A variable with the CF attribute`standard_name: “forecast_reference_time”. 3. A variable with the CF attribute`standard_name: “forecast_period”.

sel(labels, **kwargs)[source]

Allows three kinds of indexing 1. Along the dummy “forecast” variable: enable specialized methods using

ConstantOffset, ModelRun, ConstantForecast, BestEstimate

  1. Along the forecast_reference_time dimension, identical to ModelRun

  2. Along the forecast_period dimension, identical to ConstantOffset

You cannot mix (1) with (2) or (3), but (2) and (3) can be combined in a single statement.

__repr__()[source]