swvo.io.hp.ensemble#
Classes
|
A class to handle Hp30 ensemble data. |
|
A class to handle Hp60 ensemble data. |
|
This is a base class for Hp ensemble data. |
- class swvo.io.hp.ensemble.HpEnsemble(index: str, data_dir: Path | None = None, prefer_env_var: bool = False)[source]#
Bases:
objectThis is a base class for Hp ensemble data.
- Parameters:
- indexstr
Hp index Possible options are: hp30, hp60.
- data_dirPath | None
Data directory for the Hp data. If not provided, it will be read from the environment variable
- prefer_env_varbool, optional
If True, the environment variable takes precedence over the passed data_dir argument. If False (default), the passed data_dir is used if provided, otherwise the environment variable is used.
Methods
read(start_time, end_time)Read Hp ensemble data for the requested period.
- Raises:
- ValueError
Returns ValueError if necessary environment variable is not set.
- FileNotFoundError
Returns FileNotFoundError if the data directory does not exist.
- read(start_time: datetime, end_time: datetime) list[DataFrame][source]#
Read Hp ensemble data for the requested period.
- Parameters:
- start_timedatetime
Start time of the data to read. Must be timezone-aware.
- end_timedatetime
End time of the data to read. Must be timezone-aware.
- Returns:
- list[
pandas.DataFrame] List of ensemble data frames containing data for the requested period.
- list[
- Raises:
- FileNotFoundError
Returns FileNotFoundError if no ensemble file is found for the requested date.
- class swvo.io.hp.ensemble.Hp30Ensemble(data_dir: Path | None = None, prefer_env_var: bool = False)[source]#
Bases:
HpEnsembleA class to handle Hp30 ensemble data.
- Parameters:
- data_dirstr | Path, optional
Data directory for the Hp30 ensemble data. If not provided, it will be read from the environment variable
- read_with_horizon(start_time: datetime, end_time: datetime, horizon: float) list[DataFrame][source]#
Read Ensemble Hp30 forecast data for a given time range and forecast horizon.
- Parameters:
- start_timedatetime
Start time of the period for which to read the data.
- end_timedatetime
End time of the period for which to read the data.
- horizonfloat
Forecast horizon (in hours).
- Returns:
- list[
pandas.DataFrame] A list of data frames containing ensemble data for the requested period.
- list[
- Raises:
- ValueError
Raises ValueError if the horizon is not between 0 and 72 hours.
- ValueError
Raises ValueError if the horizon is not in 0.5 hour increments.
- read(start_time: datetime, end_time: datetime) list[DataFrame]#
Read Hp ensemble data for the requested period.
- Parameters:
- start_timedatetime
Start time of the data to read. Must be timezone-aware.
- end_timedatetime
End time of the data to read. Must be timezone-aware.
- Returns:
- list[
pandas.DataFrame] List of ensemble data frames containing data for the requested period.
- list[
- Raises:
- FileNotFoundError
Returns FileNotFoundError if no ensemble file is found for the requested date.
- class swvo.io.hp.ensemble.Hp60Ensemble(data_dir: Path | None = None, prefer_env_var: bool = False)[source]#
Bases:
HpEnsembleA class to handle Hp60 ensemble data.
- Parameters:
- data_dirstr | Path, optional
Data directory for the Hp60 ensemble data. If not provided, it will be read from the environment variable
- read_with_horizon(start_time: datetime, end_time: datetime, horizon: int) list[DataFrame][source]#
Read Ensemble Hp60 forecast data for a given time range and forecast horizon.
- Parameters:
- start_timedatetime
Start time of the period for which to read the data.
- end_timedatetime
End time of the period for which to read the data.
- horizonint
Forecast horizon (in hours).
- Returns:
- list[
pandas.DataFrame] A list of data frames containing ensemble data for the requested period.
- list[
- Raises:
- ValueError
Raises ValueError if the horizon is not between 0 and 72 hours.
- ValueError
Raises ValueError if the horizon is not in 1 hour increments.
- read(start_time: datetime, end_time: datetime) list[DataFrame]#
Read Hp ensemble data for the requested period.
- Parameters:
- start_timedatetime
Start time of the data to read. Must be timezone-aware.
- end_timedatetime
End time of the data to read. Must be timezone-aware.
- Returns:
- list[
pandas.DataFrame] List of ensemble data frames containing data for the requested period.
- list[
- Raises:
- FileNotFoundError
Returns FileNotFoundError if no ensemble file is found for the requested date.