{"id":30284414,"url":"https://github.com/professorcode1/event-analysis","last_synced_at":"2025-10-24T20:22:15.899Z","repository":{"id":104535034,"uuid":"566983612","full_name":"professorcode1/Event-Analysis","owner":"professorcode1","description":"Library for Event Synchronization and Event Coincidence Analysis","archived":false,"fork":false,"pushed_at":"2024-01-22T12:04:25.000Z","size":1045,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-24T02:01:27.953Z","etag":null,"topics":["cuda","cuda-kernels","cuda-library","cuda-programming","event-analysis","event-coincidence","event-coincidence-analysis","event-series","event-series-analysis","event-synchronization","time-series-analysis"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/professorcode1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-16T20:34:20.000Z","updated_at":"2023-04-12T06:12:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"dad5c0ed-faa7-44a4-8033-27785236cbc4","html_url":"https://github.com/professorcode1/Event-Analysis","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":0.4,"last_synced_commit":"72f19503eed1bdf54c04fa17832ae15863cb904f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/professorcode1/Event-Analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/professorcode1%2FEvent-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/professorcode1%2FEvent-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/professorcode1%2FEvent-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/professorcode1%2FEvent-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/professorcode1","download_url":"https://codeload.github.com/professorcode1/Event-Analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/professorcode1%2FEvent-Analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270756353,"owners_count":24639867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","cuda-kernels","cuda-library","cuda-programming","event-analysis","event-coincidence","event-coincidence-analysis","event-series","event-series-analysis","event-synchronization","time-series-analysis"],"created_at":"2025-08-16T19:01:45.699Z","updated_at":"2025-10-16T00:08:59.272Z","avatar_url":"https://github.com/professorcode1.png","language":"Jupyter Notebook","readme":"# Event Analysis\n\n### Library for Event Synchronization and Event Coincidence Analysis\n\nThis Python library facilitates the calculation of Event Synchronization (ES) and Event Coincidence Analysis (ECA) for event series.\n\n## Understanding ECA and ES\nTo learn about ECA, read [this](https://arxiv.org/abs/1508.03534) \u003csup\u003e1\u003c/sup\u003e\nTo learn about ES, read [this](https://aip.scitation.org/doi/10.1063/1.5134012) \u003csup\u003e2\u003c/sup\u003e\n\n## Installation\n\nTo install the library, execute the following command:\n\n```\npip install event-analysis\n```\n\n### Additional Requirement\n\nTo utilize the CUDA method, please install PyCuda separately.\n\n### Usage\n\nRefer to the [Example.ipnby](https://github.com/professorcode1/Event-Analysis/blob/main/Example.ipynb) Jupyter notebook for detailed usage instructions.\n\n```\nfrom EventAnalysis import EventAnalysis\n\n# Initialize the Event Analysis object with your event dataframe\nEA = EventAnalysis(event_dataframe)\n\n# Perform Event Synchronization\nQ = EA.ES()\n\n# Calculate Event Coincidence Analysis\np_max, p_mean, t_max, t_mean = EA.ECA(time_delta)\n\n# Calculate ECA with p-values\np_max, p_mean, t_max, t_mean, pval_p, pval_t = EA.ECA(time_delta, return_p_values=True)\n\n# Important: Read the documentation for the EA constructor parameter time_normalization_factor before using the library.\n```\n\nPlease read the notes for the EventAnalysis class before you use this library.\n\n## Documentation\n\n#### EventAnalysis Class\n##### Constructor:\n```\nEventAnalysis(self, event_df, device_Id=None, time_normalization_factor=3600)\n```\n\n##### Arguments\n\n+ **event_df**: `pandas.DataFrame`\n  + This DataFrame must have the following properties:\n    + The index must be a `pandas.DatetimeIndex`.\n    + The data type inside the DataFrame must be boolean.\n    + Each column represents an event series.\n+ **device_Id**: Optional int\n  + Specify the ID of the NVIDIA GPU for computation. Defaults to 0 if not provided.\n+ **time_normalization_factor**: Optional int\n  + The library quantizes time to hours, ignoring minutes and seconds. This behavior can be overridden by changing this argument. Possible values include:\n    + `1`: Quantizes to seconds (allows for 69 years of data).\n    + `60`: Quantizes to minutes (allows for 4000 years of data).\n    + `3600`: (default) Quantizes to hours (allows for 250 centuries of data).\n##### Returns:\n\n+ An EventAnalysis object on which you can call the ES and ECA methods.\n\n#### ES Method\n\n```\nES(self, tauMax=np.Inf)\n```\n\n##### Arguments\n\n+ **tauMax**: Optional, default is np.Inf\n  + Currently not utilized; future functionality will be added. Please open an issue if needed.\n\n##### Return\n\n+ 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.\n\n#### ECA Method\n```\nECA(self, Delta_T_obj, tau=0, return_p_values=False, pValFillNA=True)\n```\n\n##### Arguments\n\n+ **Delta_T_obj**: Required\n  + Must be a `datetime.timedelta` object. It is quantized using the same time_normalization_factor as passed to the constructor.\n+ **tau**: Optional, default is 0\n  + A parameter of the ECA algorithm. Refer to the associated paper for details.\n+ **return_p_values**: Optional, default is False\n  + If set to True, it calculates the p-values for each combination of event series and returns them.\n+ **pValFillNA**: Optional, default is True\n  + Replaces NaN p-values with 1.\n\n#### Return\n\n+ `EC_p_max`\n+ `EC_p_mean`\n+ `EC_t_max`\n+ `EC_t_mean`\n+ `pval_precursor` (optional): Corresponds to the p-value of `EC_p_max` and `EC_p_mean`.\n+ `pval_trigger` (optional): Corresponds to the p-value of `EC_t_max` and `EC_t_mean`.\n\n**Notes**: The paper outlines the conditions for calculating p-values for ECA results:\n\n1) N\u003csub\u003ea\u003c/sub\u003e \u003e\u003e 1 and N\u003csub\u003eb\u003c/sub\u003e \u003e\u003e 1\n\n2) ΔT \u003c\u003c T/N\u003csub\u003ea\u003c/sub\u003e\n\nHere, N\u003csub\u003ea\u003c/sub\u003e and N\u003csub\u003eb\u003c/sub\u003e represent the number of events in series A and B, respectively. Δ𝑇 should be sufficiently less than the overall time.\n\n#### ECA_vec\n\n```\nECA_vec(self, Delta_T_objs, taus=0, return_p_values=False, pValFillNA=True)\n```\n\n##### Arguments\n\n+ **Delta_T_objs**: Required\n  + A list of datetime.timedelta objects.\n+ **taus**: Optional, default is 0\n  + 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.\n+ **return_p_values**: Same as ECA.\n+ **pValFillNA**: Same as ECA.\n\n##### Returns\n\n+ A generator that yields the ECA result for each corresponding pair of `Delta_T_objs[i]` and `taus[i]`.\n\n## CUDA Support\n\nAll 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.\n\n+ **ES_Cuda(..., block=None)**\n  + 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.\n+ **ECA_Cuda(..., block=None)**\n+ **ECA_vec_Cuda(..., block=None)**\n  + Defaults to (32, 1, 1). Similar to ES_Cuda.\n\n**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\u003csup\u003e−2\u003c/sup\u003e should minimize these discrepancies.\n\n### References\n\n1. Event coincidence analysis for quantifying statistical interrelationships between event time series - Jonathan F. Donges, Carl-Friedrich Schleussner, Jonatan F. Siegmund, and Reik V. Donner\n\n2. 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\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessorcode1%2Fevent-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofessorcode1%2Fevent-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessorcode1%2Fevent-analysis/lists"}