swvo.io.kp.swpc#
Module for handling SWPC Kp data.
Classes
|
A class for handling SWPC Kp data. |
- class swvo.io.kp.swpc.KpSWPC(data_dir: Path | None = None, prefer_env_var: bool = False)[source]#
Bases:
BaseIOA class for handling SWPC Kp data. In SWPC data, the file for current day always contains the forecast for the next 3 days. Keep this in mind when using the read and download_and_process methods.
- Parameters:
- data_dirPath | None
Data directory for the SWPC Kp data. If not provided, it will be read from the environment variable
Methods
download_and_process(target_date[, ...])Download and process SWPC Kp data file.
read(start_time[, end_time, download])Read Kp data for the specified time range.
- Raises:
- ValueError
Returns ValueError if necessary environment variable is not set
- download_and_process(target_date: datetime, reprocess_files: bool = False) None[source]#
Download and process SWPC Kp data file.
- Parameters:
- target_datedatetime
Target date for the Kp data,
- reprocess_filesbool, optional
Downloads and processes the files again, defaults to False, by default False
- Raises:
- ValueError
Raises ValueError if the target date is in the past.
- read(start_time: datetime, end_time: datetime | None = None, download: bool = False) DataFrame[source]#
Read Kp data for the specified time range.
- Parameters:
- start_timedatetime
Start time of the data to read.
- end_timedatetime, optional
End time of the data to read. If not provided, it will be set to 3 days after start_time.
- downloadbool, optional
Download data on the go, defaults to False.
- Returns:
- pd.DataFrame
SWPC Kp dataframe.
- Raises:
- ValueError
Raises ValueError if the time range is more than 3 days.