Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code on "Example: Modeling Seismic Activity" seems broken #19

Open
titsuki opened this issue Jan 16, 2022 · 1 comment
Open

Comments

@titsuki
Copy link

titsuki commented Jan 16, 2022

Hi,

See: https://hawkeslib.readthedocs.io/en/latest/example.html#example-modeling-seismic-activity

In this example, for generating the input, an external resource is downloaded and parsed by a xpath handler.
At the end of this pre-process, it generates a list which represents a time series.
But I found that the resulting list just contains one element.
This example seems broken to me since the Hawkes Process isn't designed to model this kind of time series and the time series is totally different from the figure in the next section.

code:

import requests
from lxml import html
from datetime import datetime as dt
import numpy as np

res = requests.get("http://www.koeri.boun.edu.tr/scripts/lst9.asp")
tx = html.fromstring(res.content).xpath("//pre/text()")[0]
lines = tx.splitlines()[7:]  # get rid of the headers                                                                                          

# take out timestamps and convert them to "hours since first event"                                                                            
timestamps = [dt.strptime(l[:19], "%Y.%m.%d %H:%M:%S") for l in lines if "ISTANBUL" in l]
print(timestamps)
print(timestamps[-1])
t = np.array([(x - timestamps[-1]).total_seconds() / 3600 for x in timestamps])[::-1]
print(t)

(In this code the original ts[-1] is replaced with timestamps[-1] since I couldn't find ts)

output:

[datetime.datetime(2022, 1, 8, 19, 7, 1)]
2022-01-08 19:07:01
[0.]
  • environment
    • python 3.6.5
@longway-png01
Copy link

Hi. I see you've done a lot of research on timing. As a beginner, I would like to ask you for a simple Hawkes process data and code package, do you have it? Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants