climate.havlin

Provides classes for generating and analyzing complex climate networks.

class pyunicorn.climate.havlin.HavlinClimateNetwork(data, max_delay, threshold=None, link_density=None, non_local=False, node_weight_type='surface', silence_level=0)[source]

Bases: ClimateNetwork

Encapsulates a Havlin climate network.

The similarity matrix associated with a Havlin climate network is the maximum-lag correlation matrix with each entry normalized by the cross-correlation function’s standard deviation.

Havlin climate networks are undirected so far.

Havlin climate networks were studied for daily data in [Yamasaki2008], [Gozolchiani2008], [Yamasaki2009].

Note

So far, the cross-correlation functions are estimated using convolution in Fourier space (FFT). This may not be reliable for larger delays.

__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, max_delay, threshold=None, link_density=None, non_local=False, node_weight_type='surface', silence_level=0)[source]

Initialize an instance of HavlinClimateNetwork.

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.

  • max_delay (int) – Maximum delay for cross-correlation functions.

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

  • 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 version of the instance of HavlinClimateNetwork.

_calculate_correlation_strength(anomaly, max_delay, gamma=0.2)[source]

Calculate correlation strength and maximum lag matrices.

Follows the method described in [Yamasaki2008].

Also returns the time lag at maximum correlation for each link.

Parameters:
  • anomaly (2D array [time, index]) – The anomaly data for network construction.

  • max_delay (int) – The maximum delay for cross-correlation functions.

  • gamma (float) – The width of decay region in cosine shaped window used for FFT cross-correlation estimation.

Return type:

tuple of two 2D arrays [index, index]

Returns:

the correlation strength and maximum lag matrices.

_set_max_delay(max_delay)[source]

Set the maximum lag time used for cross-correlation estimation.

Parameters:

max_delay (int) – The maximum delay for cross-correlation functions.

clear_cache()[source]

Clean up cache.

correlation_lag()[source]

Return the lag at maximum cross-correlation matrix.

Return type:

2D array [index, index]

Returns:

the lag at maximum cross-correlation matrix.

correlation_lag_weighted_average_path_length()[source]

Return correlation lag weighted average path length.

Return float:

the correlation lag weighted average path length.

correlation_lag_weighted_closeness()[source]

Return correlation lag weighted closeness.

Return type:

1D array [index]

Returns:

the correlation lag weighted closeness sequence.

correlation_strength()[source]

Return the correlation strength matrix.

Return type:

2D array [index, index]

Returns:

the correlation strength matrix.

correlation_strength_weighted_average_path_length()[source]

Return correlation strength weighted average path length.

Return float:

the correlation strength weighted average path length.

correlation_strength_weighted_closeness()[source]

Return correlation strength weighted closeness.

Return type:

1D array [index]

Returns:

the correlation strength weighted closeness sequence.

data: ClimateData

The climate data used for network construction.

get_max_delay()[source]

Return the maximum delay used for cross-correlation estimation.

Return float:

the maximum delay used for cross-correlation estimation.

local_correlation_lag_weighted_vulnerability()[source]

Return correlation lag weighted vulnerability.

Return type:

1D array [index]

Returns:

the correlation lag weighted vulnerability sequence.

local_correlation_strength_weighted_vulnerability()[source]

Return correlation strength weighted vulnerability.

Return type:

1D array [index]

Returns:

the correlation strength weighted vulnerability sequence.

set_max_delay(max_delay)[source]

Set the maximum lag time used for cross-correlation estimation.

(Re)generates the current Havlin climate network accordingly.

Parameters:

max_delay (int) – The maximum delay for cross-correlation functions.