Event Analysis
Library for Event Synchronization and Event Coincidence Analysis
This Python library facilitates the calculation of Event Synchronization (ES) and Event Coincidence Analysis (ECA) for event series.
Understanding ECA and ES
To learn about ECA, read this 1 To learn about ES, read this 2
Installation
To install the library, execute the following command:
pip install event-analysis
Additional Requirement
To utilize the CUDA method, please install PyCuda separately.
Usage
Refer to the Example.ipnby Jupyter notebook for detailed usage instructions.
from EventAnalysis import EventAnalysis
# Initialize the Event Analysis object with your event dataframe
EA = EventAnalysis(event_dataframe)
# Perform Event Synchronization
Q = EA.ES()
# Calculate Event Coincidence Analysis
p_max, p_mean, t_max, t_mean = EA.ECA(time_delta)
# Calculate ECA with p-values
p_max, p_mean, t_max, t_mean, pval_p, pval_t = EA.ECA(time_delta, return_p_values=True)
# Important: Read the documentation for the EA constructor parameter time_normalization_factor before using the library.
Please read the notes for the EventAnalysis class before you use this library.
Documentation
EventAnalysis Class
Constructor:
EventAnalysis(self, event_df, device_Id=None, time_normalization_factor=3600)
Arguments
- event_df:
pandas.DataFrame- This DataFrame must have the following properties:
- The index must be a
pandas.DatetimeIndex. - The data type inside the DataFrame must be boolean.
- Each column represents an event series.
- The index must be a
- This DataFrame must have the following properties:
- device_Id: Optional int
- Specify the ID of the NVIDIA GPU for computation. Defaults to 0 if not provided.
- time_normalization_factor: Optional int
- The library quantizes time to hours, ignoring minutes and seconds. This behavior can be overridden by changing this argument. Possible values include:
1: Quantizes to seconds (allows for 69 years of data).60: Quantizes to minutes (allows for 4000 years of data).3600: (default) Quantizes to hours (allows for 250 centuries of data).
- The library quantizes time to hours, ignoring minutes and seconds. This behavior can be overridden by changing this argument. Possible values include:
Returns:
- An EventAnalysis object on which you can call the ES and ECA methods.
ES Method
ES(self, tauMax=np.Inf)
Arguments
- tauMax: Optional, default is np.Inf
- Currently not utilized; future functionality will be added. Please open an issue if needed.
Return
- A DataFrame Q of shape N x N, where N is the number of event series. Use Q[event_series_1_name][event_series_2_name] to get the Event Synchronization between two series.
ECA Method
ECA(self, Delta_T_obj, tau=0, return_p_values=False, pValFillNA=True)
Arguments
- Delta_T_obj: Required
- Must be a
datetime.timedeltaobject. It is quantized using the same time_normalization_factor as passed to the constructor.
- Must be a
- tau: Optional, default is 0
- A parameter of the ECA algorithm. Refer to the associated paper for details.
- return_p_values: Optional, default is False
- If set to True, it calculates the p-values for each combination of event series and returns them.
- pValFillNA: Optional, default is True
- Replaces NaN p-values with 1.
Return
EC_p_maxEC_p_meanEC_t_maxEC_t_meanpval_precursor(optional): Corresponds to the p-value ofEC_p_maxandEC_p_mean.pval_trigger(optional): Corresponds to the p-value ofEC_t_maxandEC_t_mean.
Notes: The paper outlines the conditions for calculating p-values for ECA results:
-
Na >> 1 and Nb >> 1
-
ΔT << T/Na
Here, Na and Nb represent the number of events in series A and B, respectively. Δ𝑇 should be sufficiently less than the overall time.
ECA_vec
ECA_vec(self, Delta_T_objs, taus=0, return_p_values=False, pValFillNA=True)
Arguments
- Delta_T_objs: Required
- A list of datetime.timedelta objects.
- taus: Optional, default is 0
- Can be an integer, list, or numpy array of integers, matching the length of Delta_T_objs. If an integer is provided, all ECAs use that value.
- return_p_values: Same as ECA.
- pValFillNA: Same as ECA.
Returns
- A generator that yields the ECA result for each corresponding pair of
Delta_T_objs[i]andtaus[i].
CUDA Support
All three methods can be executed on an NVIDIA GPU by appending _Cuda to their names: ES_Cuda, ECA_Cuda, ECA_vec_Cuda. Each requires an additional named parameter, block.
- ES_Cuda(..., block=None)
- Defaults to
(16, 8, 1). Any tuple of the form (x, y, 1) where 𝑥 × 𝑦 is a multiple of the GPU's warp size is valid.
- Defaults to
- ECA_Cuda(..., block=None)
- ECA_vec_Cuda(..., block=None)
- Defaults to (32, 1, 1). Similar to ES_Cuda.
Notes: The p-values returned by the GPU may differ slightly from those calculated by the CPU due to floating-point precision. Setting epsilon to 10−2 should minimize these discrepancies.
References
-
Event coincidence analysis for quantifying statistical interrelationships between event time series - Jonathan F. Donges, Carl-Friedrich Schleussner, Jonatan F. Siegmund, and Reik V. Donner
-
Frederik Wolf, Jurek Bauer, Niklas Boers, and Reik V. Donner , "Event synchrony measures for functional climate network analysis: A case study on South American rainfall dynamics", Chaos 30, 033102 (2020) https://doi.org/10.1063/1.5134012
Metadata
Release files for event-analysis 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| event_analysis-1.1.3.tar.gz | 13.2 kB | Without provenance | Details for event_analysis-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| event_analysis-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for event_analysis-1.1.3-py3-none-any.whl |
Total release size: 28.7 kB
Release files / event_analysis-1.1.3.tar.gz
| Download URL | event_analysis-1.1.3.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c2bdc21a136b5d485131fbb575deb81893a7152af9bdf744b9c39963bbcbad9
|
|
BLAKE2b-256 checksum How to use checksums |
22047ba2bca3800b5f3c04c997b903cf7f7e6e8b09ce884cf200dfe2e2d0f21e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.0
|
Release files / event_analysis-1.1.3-py3-none-any.whl
| Download URL | event_analysis-1.1.3-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b852911c1e3da1be9a72c5fe5107f73c47644389a1112c33ec0c7831a8f4480d
|
|
BLAKE2b-256 checksum How to use checksums |
bc877084f1531e215bdacf021bb5e468754736e33db6ee34d9af9eb8432e08b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.0
|
Security for event-analysis 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.