solarwindpy.solar_activity.base
Base classes for solar activity indicators.
Classes
|
Abstract base class providing a logger interface. |
|
|
|
Container for identifying a particular data product. |
|
Base class for objects describing indicator extrema. |
- class Base[source]
Bases:
ABCAbstract base class providing a logger interface.
- property logger
logging.Loggerattached to the instance.
- class ID(key: str)[source]
Bases:
BaseContainer 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.Loggerattached to the instance.
- class DataLoader(key, url)[source]
Bases:
Base- __init__(key, url)[source]
Initialize a data loader.
- abstract property data_path
- abstractmethod static convert_nans(data)[source]
- abstractmethod download_data()[source]
- abstractmethod load_data()[source]
- property logger
logging.Loggerattached 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-01if no prior data are found.- Return type:
- 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_dataontotarget_index.- Parameters:
source_data (pandas.Series or pandas.DataFrame) – Data with a
DatetimeIndexto interpolate.target_index (pandas.DatetimeIndex) – Target time axis for the interpolation.
- Returns:
Data interpolated onto
target_index.- Return type:
- 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:
- property logger
logging.Loggerattached to the instance.
- class IndicatorExtrema(*args, **kwargs)[source]
Bases:
BaseBase class for objects describing indicator extrema.
- __init__(*args, **kwargs)[source]
- property data
- property cycle_intervals
pd.Intervalfor 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
Nfollowed by MaxN. 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.Intervalobjects labeling each epoch.- Return type:
- 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
MinandMaxintervals 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:
- property logger
logging.Loggerattached to the instance.