climate.rainfall

Provides classes for generating and analyzing complex climate networks.

class pyunicorn.climate.rainfall.RainfallClimateNetwork(data, threshold=None, link_density=None, non_local=False, node_weight_type='surface', event_threshold=(0, 1), scale_fac=37265, offset=1e-07, silence_level=0)[source]

Bases: ClimateNetwork

Encapsulate a Rainfall climate network.

The Rainfall climate network is constructed from the Spearman rank order correlation matrix (Spearman’s rho) but without considering “zeros” in the dataset, which represent the time at which there is no rainfall. Spearman’s rho is more robust with respect to outliers and non-gaussian data distributions than the Pearson correlation coefficient.

Rainfall climate networks are undirected due to the symmetry of the Spearman’s rho matrix.

Class RainfallClimateNetwork was created by Marc Wiedermann during an internship at PIK in March 2010.

__init__(data, threshold=None, link_density=None, non_local=False, node_weight_type='surface', event_threshold=(0, 1), scale_fac=37265, offset=1e-07, silence_level=0)[source]

Initialize an instance of RainfallClimateNetwork.

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.

  • event_threshold (list of two numbers between 0 and 1.) – The quantiles of the rainfall distribution at each location between which rainfall events should be considered for calculating correlations.

  • scale_fac (float) – Scale factor for rescaling data.

  • offset (float) – Offset for rescaling data.

  • silence_level (int) – The inverse level of verbosity of the object.

__str__()[source]

Returns a string representation of RainfallClimateNetwork.

_calculate_correlation(event_threshold, scale_fac, offset, time_cycle)[source]

Returns the Spearman Rho correlation matrix.

An event_threshold can be given to extract a percentage of the given dataset, i.e. [0.9,1] extracts the ten percent of heaviest rainfall events. [0,1] selects the whole dataset.

Parameters:
  • event_threshold (list of two numbers between 0 and 1.) – The quantiles of the rainfall distribution at each location between which rainfall events should be considered for calculating correlations.

  • scale_fac (number (float)) – Scale factor for rescaling data.

  • offset (number (float)) – Offset for rescaling data.

  • time_cycle (number (int)) – Length of annual cycle in given data (monthly: 12, daily: 365 etc.)

Return type:

2D Numpy array (index, index)

Returns:

the Spearman’s rho matrix at zero lag.

static calculate_rainfall(observable, scale_fac, offset)[source]

Returns the rainfall in mm on each measuring point.

Parameters:
  • observable (2D Numpy array (time, index)) – The observable time series from the data source.

  • scale_fac (number (float)) – Scale factor for rescaling data.

  • offset (number (float)) – Offset for rescaling data.

Return type:

2D Numpy array (time, index)

Returns:

the rainfall for each time and location

static calculate_top_events(rainfall, event_threshold)[source]

Returns a mask with boolean values. The entries are false, when the rainfall of one day is zero, or when the rainfall is not inside the event_treshold

Parameters:
  • rainfall (2D Numpy array (index, time)) – the rainfall time series for each measuring point

  • event_threshold (list of two numbers between 0 and 1.) – The quantiles of the rainfall distribution at each location between which rainfall events should be considered for calculating correlations.

Return type:

2D Numpy array (index, time)

Returns:

A bool array with False for every value in the rainfall data, which are zero or outside the top_event Interval.

data

(ClimateData) - The climate data used for network construction.

static rank_time_series(anomaly)[source]

Return rank time series.

Parameters:

anomaly (2D Numpy array (index, time)) – the rainfall anomaly time series for each measuring point

Return type:

2D Numpy array (index, time)

Returns:

The ranked time series for each gridpoint

spearman_corr(final_mask, anomaly)[source]

Return the Spearman Correlation Matrix at zero lag.

Parameters:
  • final_mask (2D Numpy array (index, time)) – A bool array with False for every value in the rainfall data, which are zero or outside the top_event interval.

  • anomaly (2D Numpy array (index, time)) – The rainfall anomaly time series for each measuring point.

Return type:

2D Numpy array (index, index)

Returns:

the Spearman correlation matrix.