pyspi.data.Data

class pyspi.data.Data(data=None, dim_order='ps', detrend=False, normalise=True, name=None, procnames=None, n_processes=None, n_observations=None)

Store data for dependency analysis.

Data takes a 2-dimensional array representing measurements in two dimensions: processes (p) and observations (s). The order of the dimensions in the provided array are specified using a two-character string, either 'ps' for an array with realisations over (dim 1) processes, and (dim 2) observations in time, or 'sp', denoting an array over (dim 1) observations in time, and (dim 2) processes.

Example

# Initialise empty data object
data = Data()

# Load a prefilled financial dataset
data_forex = Data().load_dataset(forex)

# Create data objects with data of various sizes
d = np.arange(3000).reshape((3, 1000))  # 3 procs.,
data_2 = Data(d, dim_order='ps')        # 1000 observations

# Overwrite data in existing object with random data
d = np.arange(5000)
data_2.set_data(data_new, 's')

Parameters:
Description

  • data (array_like, optional) – 2-dimensional array with raw data, default=None.

  • dim_order (str, optional) – Order of dimensions, accepts two combinations of the characters ‘p’, and ‘s’ for processes and observations, default=ps’ (process along the first axis and observation along the second axis).

  • detrend (bool, optional) - If True, detrend the dataset along the time axis before normalising (if enabled), default=True.

  • normalise (bool, optional) – If True, z-score normalise the dataset along the time axis before computing SPIs, default=True.

  • name (str, optional) – Name of the dataset

  • procnames (list, optional) – List of process names with length the number of processes, default=None.

  • n_processes (int, optional) – Truncates data to this many processes, default=None.

  • n_observations (int, optional) – Truncates data to this many observations, default=None.

__init__(data=None, dim_order='ps', detrend=False, normalise=True, name=None, procnames=None, n_processes=None, n_observations=None)

Methods

Method
Description

__init__([data, dim_order, normalise, name, ...])

-

add_process(proc[, verbose])

Appends a univariate process to an existing dataset.

convert_to_numpy(data)

Converts other data instances to default numpy format.

remove_process(procs)

Remove a univariate process from an existing dataset.

set_data(data[, dim_order, name, ...])

Overwrite data in an existing Calculator instance with new data.

to_numpy([realisation, squeeze])

Return the dataset as a numpy array.

Attributes

Attribute
Description

name

Name of the data object.

procnames

List of process names.

Last updated