spacepy.poppy.PPro

class spacepy.poppy.PPro(process1, process2, lags=None, winhalf=None, verbose=False)[source]

PoPPy point process object

Initialize object with series1 and series2. These should be timeseries of events, given as lists, arrays, or lists of datetime objects. Includes method to perform association analysis of input series

Output can be nicely plotted with plot().

aa_ci(inter[, n_boots, seed])

Get bootstrap confidence intervals for association number

assoc([u, h])

Perform association analysis on input series

assoc_mult(windows[, inter, n_boots, seed])

Association analysis w/confidence interval on multiple windows

plot([figsize, dpi, asympt, show, norm, ...])

Create basic plot of association analysis.

plot_mult(windows, data[, min, max, ...])

Plots a 2D function of window size and lag

swap()

Swaps process 1 and process 2

aa_ci(inter, n_boots=1000, seed=None)[source]

Get bootstrap confidence intervals for association number

Requires input of desired confidence interval, e.g.:
>>> obj.aa_ci(95)

Upper and lower confidence limits are added to ci.

After calling, conf_above will contain the confidence (in percent) that the association number at that lag is above the asymptotic association number. (The confidence of being below is 100 - conf_above) For minor variations in conf_above to be meaningful, a large number of bootstraps is required. (Rougly, 1000 to be meaningful to the nearest percent; 10000 to be meaningful to a tenth of a percent.) A conf_above of 100 usually indicates an insufficient sample size to resolve, not perfect certainty.

Note also that a 95% chance of being above indicates an exclusion from the 90% confidence interval!

Parameters
interfloat

percentage confidence interval to calculate

n_bootsint, optional

number of bootstrap iterations to run

seedint, optional

seed for the random number generator. If not specified, Python code will use numpy’s RNG and its current seed; C code will seed from the clock.

Warning

If seed is specified, results may not be reproducible between systems with different sizes for C long type. Note that 64-bit Windows uses a 32-bit long and so results will be the same between 64 and 32-bit Windows, but not between 64-bit Windows and other 64-bit operating systems. If seed is not specified, results are not reproducible anyhow.

assoc(u=None, h=None)[source]

Perform association analysis on input series

Parameters
ulist, optional

the time lags to use

h

association window half-width, same type as process1

assoc_mult(windows, inter=95, n_boots=1000, seed=None)[source]

Association analysis w/confidence interval on multiple windows

Using the time sequence and lags stored in this object, perform full association analysis, including bootstrapping of confidence intervals, for every listed window half-size

Parameters
windowssequence

window half-size for each analysis

interfloat, optional

desired confidence interval, default 95

n_bootsint, optional

number of bootstrap iterations, default 1000

seedint, optional

Random number generator seed. It is STRONGLY recommended not to specify (i.e. leave None) to permit multithreading.

Returns
outthree numpy array

Three numpy arrays, (windows x lags), containing (in order) low values of confidence interval, high values of ci, percentage confidence above the asymptotic association number

Warning

This function is likely to take a LOT of time.

ci

Contains the upper and lower confidence limits for the association number as a function of lag. The first element is the array of lower limits; the second, the array of upper limits. Not available until after calling aa_ci().

conf_above

Contains the confidence that the association number, as a function of lag, is above the asymptotic association number. (The confidence of being below is 100 - conf_above.) Not available until after calling aa_ci().

plot(figsize=None, dpi=80, asympt=True, show=True, norm=True, xlabel='Time lag', xscale=None, ylabel=None, title=None, transparent=True)[source]

Create basic plot of association analysis.

Uses object attributes created by assoc() and, optionally, aa_ci().

Parameters
figsize, optional

passed through to matplotlib.pyplot.figure

dpiint, optional

passed through to matplotlib.pyplot.figure

asymptboolean, optional

True to overplot the line of asymptotic association number

showboolean, optional

Show the plot? (if false, will create without showing)

normboolean, optional

Normalize plot to the asymptotic association number

titlestring, optional

label/title for the plot

xlabelstring, optional

label to put on the X axis of the resulting plot

xscalefloat, optional

scale x-axis by this factor (e.g. 60.0 to convert seconds to minutes)

ylabelstring, optional

label to put on the Y axis of the resulting plot

transparentboolean, optional

make c.i. patch transparent (default)

plot_mult(windows, data, min=None, max=None, cbar_label=None, figsize=None, dpi=80, xlabel='Lag', ylabel='Window Size')[source]

Plots a 2D function of window size and lag

Parameters
windowslist

list of window sizes (y axis)

datalist

list of data, dimensioned (windows x lags)

minfloat, optional

clip L{data} to this minimum value

maxfloat, optional

clip L{data} to this maximum value

swap()[source]

Swaps process 1 and process 2