climate.mutual_info¶
Provides classes for generating and analyzing complex climate networks.
-
class
pyunicorn.climate.mutual_info.
MutualInfoClimateNetwork
(data, threshold=None, link_density=None, non_local=False, node_weight_type='surface', winter_only=True, silence_level=0)[source]¶ Bases:
pyunicorn.climate.climate_network.ClimateNetwork
Represents a mutual information climate network.
Constructs a static climate network based on mutual information at zero lag, as in [Ueoka2008].
Mutual information climate networks are undirected, since mutual information is a symmetrical measure. In contrast to Pearson correlation used in
TsonisClimateNetwork
, mutual information has the potential to detect nonlinear statistical interdependencies.-
__init__
(data, threshold=None, link_density=None, non_local=False, node_weight_type='surface', winter_only=True, silence_level=0)[source]¶ Initialize an instance of MutualInfoClimateNework.
Note
Either threshold OR link_density have to be given!
- Possible choices for
node_weight_type
: - None (constant unit weights)
- “surface” (cos lat)
- “irrigation” (cos**2 lat)
Parameters: - data (
ClimateData
) – The climate data used for network construction. - threshold (float) – The threshold of similarity measure, above which two nodes are linked in the network.
- link_density (float) – The networks’s desired link density.
- non_local (bool) – Determines, whether links between spatially close nodes should be suppressed.
- node_weight_type (str) – The type of geographical node weight to be used.
- winter_only (bool) – Determines, whether only data points from the winter months (December, January and February) should be used for analysis. Possibly, this further suppresses the annual cycle in the time series.
- silence_level (int) – The inverse level of verbosity of the object.
- Possible choices for
-
_calculate_mutual_information
(anomaly, n_bins=32)[source]¶ Calculate the mutual information matrix at zero lag.
Note
Slow since solely based on Python and Numpy!
Parameters: - anomaly (2D array (time, index)) – The anomaly time series.
- n_bins (int) – The number of bins for estimating probability distributions.
Return type: 2D array (index, index)
Returns: the mutual information matrix at zero lag.
-
_cython_calculate_mutual_information
(anomaly, n_bins=32)[source]¶ Calculate the mutual information matrix at zero lag.
The cython code is adopted from the Tisean 3.0.1 mutual.c module.
Parameters: - anomaly (2D Numpy array (time, index)) – The anomaly time series.
- n_bins (int) – The number of bins for estimating probability distributions.
- fast (bool) – Indicates, whether fast or slow algorithm should be used.
Return type: 2D array (index, index)
Returns: the mutual information matrix at zero lag.
-
_set_winter_only
(winter_only, dump=False)[source]¶ Toggle use of exclusively winter data points for network generation.
Parameters: - winter_only (bool) – Indicates whether only winter months were used for network generation.
- dump (bool) – Store MI in data file.
-
calculate_similarity_measure
(anomaly)[source]¶ Calculate the mutual information matrix.
Encapsulates calculation of mutual information with standard parameters.
Parameters: anomaly (2D Numpy array (time, index)) – The anomaly time series. Return type: 2D Numpy array (index, index) Returns: the mutual information matrix at zero lag.
-
local_mutual_information_weighted_vulnerability
()[source]¶ Return mutual information weighted vulnerability.
Return type: 1D Numpy array [index] Returns: the mutual information weighted vulnerability sequence.
-
mutual_information
(anomaly=None, dump=True)[source]¶ Return mutual information matrix at zero lag.
- Check if mutual information matrix (MI) was already calculated before:
- If yes, return MI from a data file.
- If not, return MI from calculation and store in file.
Parameters: - anomaly (2D Numpy array (time, index)) – The anomaly time series.
- dump (bool) – Store MI in data file.
Return type: 2D Numpy array (index, index)
Returns: the mutual information matrix at zero lag.
-
mutual_information_weighted_average_path_length
()[source]¶ Return mutual information weighted average path length.
Return float: the mutual information weighted average path length.
-
mutual_information_weighted_closeness
()[source]¶ Return mutual information weighted closeness.
Return type: 1D Numpy array [index] Returns: the mutual information weighted closeness sequence.
-
set_winter_only
(winter_only, dump=True)[source]¶ Toggle use of exclusively winter data points for network generation.
Also explicitly regenerates the instance of MutualInfoClimateNetwork.
Parameters: - winter_only (bool) – Indicates whether only winter months were used for network generation.
- dump (bool) – Store MI in data file.
-