hawkeslib icon indicating copy to clipboard operation
hawkeslib copied to clipboard

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

Open titsuki opened this issue 2 years ago • 1 comments

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

titsuki avatar Jan 16 '22 09:01 titsuki

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.

longway-png01 avatar Jul 02 '22 04:07 longway-png01