swvo.io.plasmasphere.read_plasmasphere#

Classes

PlasmasphereDensityCube(time, l, mlt, ...)

A structured container for plasmaspheric electron density data.

PlasmaspherePredictionReader([data_dir])

Reads one of the available PAGER plasmasphere density prediction.

class swvo.io.plasmasphere.read_plasmasphere.PlasmasphereDensityCube(time: ndarray[datetime], l: ndarray, mlt: ndarray, l_grid: ndarray, mlt_grid: ndarray, density_grid: list[ndarray], density_column: list[str])[source]#

Bases: object

A structured container for plasmaspheric electron density data.

time#

Array of Python datetime values.

Type:

np.ndarray[datetime]

l#

Array of L-values.

Type:

np.ndarray

mlt#

Array of MLT-values.

Type:

np.ndarray

l_grid#

Grid of L-values. L x MLT shape.

Type:

np.ndarray

mlt_grid#

Grid of MLT-values. L x MLT shape.

Type:

np.ndarray

density_grid#

List of arrays (n_time x n_L x n_MLT) containing electron density values for each time step.

Type:

list[np.ndarray]

density_column#

Name(s) of the column(s) containing electron density data.

Type:

list[str]

get_density_at_time(time: datetime) list[ndarray][source]#

Extract density grid for a specific time.

Parameters:
timedatetime

The specific time for which to extract the density grid.

Returns:
list[np.ndarray]

The list of ensemble density grid corresponding to the specified time.

Raises:
IndexError

If the specified time is not found in the density cube.

class swvo.io.plasmasphere.read_plasmasphere.PlasmaspherePredictionReader(data_dir: Path | None = None)[source]#

Bases: object

Reads one of the available PAGER plasmasphere density prediction.

Parameters:
folderstr

The folder where the plasmasphere prediction files are stored.

Raises:
FileNotFoundError

If the data folder does not exist.

RuntimeError

If the source of data requested is not among the available ones.

read(requested_date: datetime | None = None) DataFrame | None[source]#

Reads one of the available PAGER plasmasphere density prediction.

Parameters:
requested_datedatetime.datetime or None

Date of plasma density prediction thar we want to read up to hour precision.

Returns:
pd.DataFrame or None

pandas.DataFrame with L, MLT, density and date as columns

Raises:
RuntimeError

if the sources of data requested is not among the available ones.

build_density_cube(requested_date: datetime | None = None, density_column: str | None = None) PlasmasphereDensityCube | None[source]#

Build density tensor with shape time x L x MLT.

Parameters:
requested_datedatetime.datetime or None

Date of plasma density prediction that we want to read up to hour precision.

Returns:
PlasmasphereDensityCube or None

If density_column is provided, density_grid has shape (n_time, n_L, n_MLT). If density_column is None, density_grid is a list of arrays with that same shape (one per density column).

If no data is available for the requested date, returns None.