solarwindpy.solar_activity.base

Base classes for solar activity indicators.

Classes

ActivityIndicator()

Base()

Abstract base class providing a logger interface.

DataLoader(key, url)

ID(key)

Container for identifying a particular data product.

IndicatorExtrema(*args, **kwargs)

Base class for objects describing indicator extrema.

class Base[source]

Bases: ABC

Abstract base class providing a logger interface.

property logger

logging.Logger attached to the instance.

class ID(key: str)[source]

Bases: Base

Container for identifying a particular data product.

__init__(key: str) None[source]

Instantiate the identifier and set the corresponding URL.

Parameters:

key (str) – Key that maps to a URL fragment in _trans_url.

property key
property url

URL specifying location from which data was downloaded.

set_key(key)[source]

Set the identifier key and construct the download URL.

property logger

logging.Logger attached to the instance.

class DataLoader(key, url)[source]

Bases: Base

__init__(key, url)[source]

Initialize a data loader.

Parameters:
  • key (str) – Unique data identifier, typically from something like SIDC_ID.

  • url (str) – Full download URL for the data source.

abstract property data_path
abstractmethod static convert_nans(data)[source]
abstractmethod download_data()[source]
abstractmethod load_data()[source]
property logger

logging.Logger attached to the instance.

property data
property key
property url
property ctime
property age
set_key(key)[source]
set_url(new)[source]
get_data_ctime()[source]

Determine when the current data set was created.

Returns:

Creation time inferred from the file name, or 1970-01-01 if no prior data are found.

Return type:

pandas.Timestamp

get_data_age()[source]
maybe_update_stale_data()[source]

Download new data if the existing cache is stale.

class ActivityIndicator[source]

Bases: Base

property id
property loader
property data

Shortcut to self.loader.data.

property extrema
property norm_by
property interpolated
set_id(new)[source]
abstractmethod interpolate_data(source_data, target_index)[source]

Interpolate source_data onto target_index.

Parameters:
Returns:

Data interpolated onto target_index.

Return type:

pandas.DataFrame

abstract property normalized
abstractmethod set_extrema()[source]
abstractmethod run_normalization()[source]

Normalize the indicator within each solar cycle.

Parameters:

norm_by ({{"max", "zscore", "feature-scale"}}) – Normalization algorithm to apply.

Returns:

Normalized values indexed by time.

Return type:

pandas.Series

property logger

logging.Logger attached to the instance.

class IndicatorExtrema(*args, **kwargs)[source]

Bases: Base

Base class for objects describing indicator extrema.

__init__(*args, **kwargs)[source]
property data
property cycle_intervals

pd.Interval for rising and falling edges and full cycle.

property extrema_bands

Bands of time (\(\Delta t\)) about indicator extrema.

Parameters:

dt (str or pandas.Timedelta) – Window half-width used in calculate_extrema_bands().

abstractmethod load_or_set_data()[source]
calculate_intervals()[source]

Compute rising, falling, and full-cycle time intervals.

Notes

The rising edge comes before the falling edge in time, i.e. it’s Min N followed by Max N. Also calculate intervals for a full SSN cycle.

cut_spec_by_interval(epoch, kind=None, tk_cycles=None)[source]

Assign epochs to solar-cycle intervals.

Parameters:
  • epoch (pandas.Series or pandas.DatetimeIndex) – Data to cut.

  • kind (str, optional) –

    If provided, restricts the cut to a subset of interval types.

    Key

    Description

    None

    Cut by all available options.

    ”Cycle”

    Cut by solar cycle

    ”Rise”

    Cut by rising edge

    ”Fall”

    Cut by falling edge

    ”Edges”

    Cut by [“Fall”, “Rise”]. Exclusive option.

    Note that "Edges" is exclusive and will specify ["Fall", "Rise"] alone.

  • tk_cycles (list or slice, optional) – If not None, a selector used to choose target solar cycles.

Returns:

Series of pandas.Interval objects labeling each epoch.

Return type:

pandas.Series

calculate_extrema_bands(dt='365d')[source]

Return time windows around indicator extrema.

Parameters:
dtstr or pandas.Timedelta, optional

Half-width of the window around each extremum. Defaults to "365d".

Returns:
pandas.DataFrame

Min and Max intervals for each cycle.

cut_about_extrema_bands(epoch, tk_cycles=None, kind=None)[source]

Bin epochs relative to extrema bands.

Computed with calculate_extrema_bands().

Parameters:
  • epoch (pandas.DatetimeIndex) – Times to classify.

  • tk_cycles (slice, optional) – Subset of cycles to use when cutting.

  • kind ({{"Min", "Max"}}, optional) – Restrict the classification to minima or maxima.

Returns:

A series of intervals and a mapped series of the form "N-Min" or "N-Max".

Return type:

tuple[pandas.Series, pandas.Series]

property logger

logging.Logger attached to the instance.