Events detection¶
This tutorial shows how to detect and event.
STA/LTA ratio¶
[1]:
# specific das_ice function
import das_ice.io as di_io
import das_ice.signal.filter as di_filter
import das_ice.signal.picker as di_picker
import das_ice.processes as di_p
import das_ice.plot as di_plt
# classic librairy
import xarray as xr
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from tqdm import trange
%matplotlib inline
[2]:
from dask.distributed import Client,LocalCluster
cluster = LocalCluster(n_workers=8)
client = Client(cluster)
client.dashboard_link
[2]:
'http://127.0.0.1:8787/status'
Loading data¶
[3]:
ds=xr.Dataset()
ds['velocity']=di_io.dask_Terra15('*.hdf5', chunks="auto")
d_optic_bottom=2505 #m
depth_bh=97 #m
ds['distance']=-1*(np.abs(ds.distance-d_optic_bottom)-depth_bh)
ds = ds.sortby('distance')
[4]:
dvel_decimated=di_filter.decimate(ds.velocity,9)
[10]:
dvel_decimated
[10]:
<xarray.DataArray 'velocity' (time: 137414, distance: 618)> Size: 340MB dask.array<getitem, shape=(137414, 618), dtype=float32, chunksize=(6012, 618), chunktype=numpy.ndarray> Coordinates: * distance (distance) float64 5kB -1.733e+03 -1.729e+03 ... 93.72 96.19 * time (time) datetime64[ns] 1MB 2024-08-29T05:04:48.597790 ... 2024-0... Attributes: client_fn_applied: dT: 0.000147915811144255 dx: 4.083809535485629 frame_shape: [1082 618] nT: 1082 nx: 618 recorder_id: T311542 trigger_start_time: -1.0
[5]:
dsf=di_filter.bandpass(dvel_decimated,100,200)
STA/LTA¶
[6]:
start_date = pd.to_datetime('2024-08-29T05:05:30.00')
end_date = pd.to_datetime('2024-08-29T05:06:30.00')
dsf_crop=dsf.sel(time=slice(start_date,end_date))
[7]:
len_sta=0.2 #second
len_lta=2 #second
sta_lta=di_picker.sta_lta(dsf_crop,len_sta,len_lta)
Find event in sta/lta signal
[8]:
event=di_picker.find_event(sta_lta,10,5)
Show STA/LTA event pick
[9]:
id=10
fig=di_plt.viz_two_time_series(dsf_crop[:,id],event[:,id])
start_date_fig = pd.to_datetime('2024-08-29T05:05:33.80')
end_date_fig = pd.to_datetime('2024-08-29T05:05:34.30')
# Update the x-axis range
fig.update_xaxes(range=[start_date_fig, end_date_fig])
fig.show("png")

[ ]: