swvo.io.kp.ensemble#

Module for handling SWIFT Kp ensemble data.

Classes

KpEnsemble([data_dir, prefer_env_var])

This is a class for Kp ensemble data.

class swvo.io.kp.ensemble.KpEnsemble(data_dir: Path | None = None, prefer_env_var: bool = False)[source]#

Bases: object

This is a class for Kp ensemble data.

Parameters:
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 Kp 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 Kp ensemble data for the requested period.

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.

Returns:
list[pandas.DataFrame]

A list of data frames containing ensemble data for the requested period.

Raises:
FileNotFoundError

Raises FileNotFoundError if no ensemble files are found for the requested date.

ensemble_file_list(str_date: str) list[Path][source]#

Check for the existence of ensemble files for a given date.

Parameters:
str_datestr

Date string in the format YYYYMMDDTHH0000.

Returns:
list[Path]

A list of file paths for the ensemble files.

Warning

DeprecationWarning

Warns if deprecated file naming convention is used.

read_with_horizon(start_time: datetime, end_time: datetime, horizon: int) list[DataFrame][source]#

Read Ensemble Kp 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.

Raises:
ValueError

Raises ValueError if the horizon is not between 0 and 72 hours.