swvo.io.kp.bgs#

Module for handling BGS Kp data.

Classes

KpBGS([data_dir, prefer_env_var])

A class to handle BGS Kp data.

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

Bases: BaseIO

A class to handle BGS Kp data.

Parameters:
data_dirPath | None

Data directory for the BGS Kp data. If not provided, it will be read from the environment variable

Methods

download_and_process([request_time, ...])

Download and process BGS Kp data file for a specific month.

read([start_time, end_time, download])

Read BGS Kp data for the specified time range.

Raises:
ValueError

Returns ValueError if necessary environment variable is not set.

download_and_process(request_time: datetime | None = None, reprocess_files: bool = False) None[source]#

Download and process BGS Kp data file for a specific month.

Parameters:
request_timeOptional[datetime]

Time for which to download and process data (month and year are extracted).

reprocess_filesbool, optional

Downloads and processes the files again, defaults to False, by default False

Raises:
FileNotFoundError

Raise FileNotFoundError if the file is not downloaded successfully.

read(start_time: datetime | None = None, end_time: datetime | None = None, download: bool = False) DataFrame[source]#

Read BGS Kp data for the specified time range.

Parameters:
start_timeOptional[datetime]

Start time of the data to read.

end_timeOptional[datetime]

End time of the data to read.

downloadbool, optional

Download data on the go, defaults to False.

Returns:
pandas.DataFrame

BGS Kp dataframe.