solarwindpy.core.base

Contains in situ data Base and Core classes.

This module provides abstract base classes for handling in situ data in solar wind physics applications.

Classes

Base(data)

Base class for objects backed by a pandas.DataFrame.

Core()

Base class for all solarwindpy objects.

class Core[source]

Bases: ABC

Base class for all solarwindpy objects.

The class sets up logging, unit definitions, and physical constants. It provides a common interface that all other core objects inherit from.

logger

Logger instance associated with the object.

Type:

logging.Logger

units

Conversion factors used throughout the package.

Type:

Units

constants

Collection of physical constants.

Type:

Constants

data

Container for the underlying data.

Type:

pandas.DataFrame

__init__() None[source]
property logger: Logger

Logger instance for this object.

Returns:

Logger instance.

Return type:

logging.Logger

property units: Units

Units conversion factors.

Returns:

Units conversion instance.

Return type:

uc.Units

property constants: Constants

Physical constants.

Returns:

Physical constants instance.

Return type:

uc.Constants

property data: DataFrame

Underlying DataFrame containing the data.

Returns:

Data with MultiIndex columns.

Return type:

pd.DataFrame

class Base(data: DataFrame)[source]

Bases: Core

Base class for objects backed by a pandas.DataFrame.

Parameters:

data (pandas.DataFrame) – Data used to initialise the object.

Notes

Subclasses override set_data() to validate the underlying DataFrame structure.

__init__(data: DataFrame) None[source]
static mi_tuples(x: Tuple[Tuple[str, ...], ...]) MultiIndex[source]

Create a MultiIndex from tuples with appropriate names.

Parameters:

x (Tuple[Tuple[str, ...], ...]) – Tuples to create MultiIndex from.

Returns:

MultiIndex created from tuples.

Return type:

MI

abstractmethod set_data(new: DataFrame) None[source]

Set new data for the class.

Parameters:

new (pd.DataFrame) – New data to set.

Raises:

ValueError – If the new data is empty.

head()[source]

Return the first few rows of the data.

Returns:

First few rows of the data.

Return type:

pd.DataFrame

tail()[source]

Return the last few rows of the data.

Returns:

Last few rows of the data.

Return type:

pd.DataFrame

property constants: Constants

Physical constants.

Returns:

Physical constants instance.

Return type:

uc.Constants

property data: DataFrame

Underlying DataFrame containing the data.

Returns:

Data with MultiIndex columns.

Return type:

pd.DataFrame

property logger: Logger

Logger instance for this object.

Returns:

Logger instance.

Return type:

logging.Logger

property units: Units

Units conversion factors.

Returns:

Units conversion instance.

Return type:

uc.Units