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: 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.

__cache_state__() Tuple[Hashable, ...][source]

Hashable tuple of mutable object attributes, which will determine the instance identity for ALL cached method lookups in this class, in addition to the built-in object id(). Returning an empty tuple amounts to declaring the object immutable in general. Mutable dependencies that are specific to a method should instead be declared via @Cached.method(attrs=(…)).

NOTE: A subclass is responsible for the consistency and cost of this state descriptor. For example, hashing a large array attribute may be circumvented by declaring it as a property, with a custom setter method that increments a dedicated mutation counter.

__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.

__rec_cache_state__() Tuple[object, ...][source]

Similar to __cache_state__(), but lists attributes which are themselves instances of Cached. Empty by default.

__str__()[source]

Return a string representation of MutualInfoClimateNetwork.

_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.

data: ClimateData

The climate data used for network construction.

local_mutual_information_weighted_vulnerability()[source]

Return mutual information weighted vulnerability.

Return type:

1D Numpy array [index]

Returns:

the mutual information weighted vulnerability sequence.

mi_file

(string) - The name of the file for storing the mutual information matrix.

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.

winter_only()[source]

Indicate, if only winter months were used for network generation.

Return bool:

whether only winter months were used for network generation.