DASPy-toolbox 1.1.1__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/DASPy_toolbox.egg-info/PKG-INFO +16 -6
- daspy_toolbox-1.1.2/DASPy_toolbox.egg-info/SOURCES.txt +28 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/PKG-INFO +16 -6
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/README.md +2 -3
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/channel.py +1 -1
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/basic_tools/visualization.py +17 -11
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/collection.py +22 -8
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/dasdatetime.py +24 -2
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/section.py +14 -7
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/setup.py +1 -1
- DASPy-toolbox-1.1.1/DASPy_toolbox.egg-info/SOURCES.txt +0 -53
- DASPy-toolbox-1.1.1/daspy/core/make_example.py +0 -32
- DASPy-toolbox-1.1.1/daspy/seismic_detection/__init__.py +0 -1
- DASPy-toolbox-1.1.1/daspy/seismic_detection/calc_travel_time.py +0 -23
- DASPy-toolbox-1.1.1/daspy/seismic_detection/core.py +0 -186
- DASPy-toolbox-1.1.1/daspy/seismic_detection/detection.py +0 -12
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/__init__.py +0 -13
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/_base.py +0 -549
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/_bayesian_mixture.py +0 -875
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/_gaussian_mixture.py +0 -866
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/app.py +0 -192
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/seismic_ops.py +0 -478
- DASPy-toolbox-1.1.1/daspy/seismic_detection/gamma/utils.py +0 -512
- DASPy-toolbox-1.1.1/daspy/seismic_detection/location.py +0 -266
- DASPy-toolbox-1.1.1/daspy/seismic_detection/magnitude.py +0 -43
- DASPy-toolbox-1.1.1/daspy/seismic_detection/phase_picking.py +0 -87
- DASPy-toolbox-1.1.1/daspy/structure_imaging/__init__.py +0 -0
- DASPy-toolbox-1.1.1/daspy/structure_imaging/ambient_noise.py +0 -4
- DASPy-toolbox-1.1.1/daspy/structure_imaging/core.py +0 -39
- DASPy-toolbox-1.1.1/daspy/structure_imaging/dispersion.py +0 -27
- DASPy-toolbox-1.1.1/daspy/structure_imaging/fault_zone.py +0 -90
- DASPy-toolbox-1.1.1/daspy/structure_imaging/inversion.py +0 -6
- DASPy-toolbox-1.1.1/daspy/traffic_monitoring/JamDetection.py +0 -6
- DASPy-toolbox-1.1.1/daspy/traffic_monitoring/SpeedMeasurement.py +0 -6
- DASPy-toolbox-1.1.1/daspy/traffic_monitoring/VehicleDetection.py +0 -6
- DASPy-toolbox-1.1.1/daspy/traffic_monitoring/__init__.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/DASPy_toolbox.egg-info/dependency_links.txt +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/DASPy_toolbox.egg-info/entry_points.txt +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/DASPy_toolbox.egg-info/requires.txt +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/DASPy_toolbox.egg-info/top_level.txt +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/LICENSE +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/__init__.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/__init__.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/decomposition.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/denoising.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/fdct.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/advanced_tools/strain2vel.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/basic_tools/__init__.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/basic_tools/filter.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/basic_tools/freqattributes.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/basic_tools/preprocessing.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/__init__.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/example.pkl +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/read.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/daspy/core/write.py +0 -0
- {DASPy-toolbox-1.1.1 → daspy_toolbox-1.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: DASPy-toolbox
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: DASPy is an open-source project dedicated to provide a python package for DAS (Distributed Acoustic Sensing) data processing, which comprises classic seismic data processing techniques and Specialized algorithms for DAS applications.
|
|
5
5
|
Home-page: https://github.com/HMZ-03/DASPy
|
|
6
6
|
Author: Minzhe Hu, Zefeng Li
|
|
@@ -22,14 +22,24 @@ Requires-Dist: h5py
|
|
|
22
22
|
Requires-Dist: segyio
|
|
23
23
|
Requires-Dist: nptdms
|
|
24
24
|
Requires-Dist: tqdm
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: license
|
|
31
|
+
Dynamic: maintainer
|
|
32
|
+
Dynamic: maintainer-email
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
<img src="https://raw.github.com/hmz-03/daspy/main/website/logo.png" height="200" />
|
|
29
38
|
|
|
30
39
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
31
40
|
[](https://opensource.org/license/mit)
|
|
32
41
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
42
|
+
|
|
33
43
|
[](https://doi.org/10.1785/0220240124)
|
|
34
44
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
35
45
|
[](https://anaconda.org/conda-forge/daspy-toolbox)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
DASPy_toolbox.egg-info/PKG-INFO
|
|
5
|
+
DASPy_toolbox.egg-info/SOURCES.txt
|
|
6
|
+
DASPy_toolbox.egg-info/dependency_links.txt
|
|
7
|
+
DASPy_toolbox.egg-info/entry_points.txt
|
|
8
|
+
DASPy_toolbox.egg-info/requires.txt
|
|
9
|
+
DASPy_toolbox.egg-info/top_level.txt
|
|
10
|
+
daspy/__init__.py
|
|
11
|
+
daspy/advanced_tools/__init__.py
|
|
12
|
+
daspy/advanced_tools/channel.py
|
|
13
|
+
daspy/advanced_tools/decomposition.py
|
|
14
|
+
daspy/advanced_tools/denoising.py
|
|
15
|
+
daspy/advanced_tools/fdct.py
|
|
16
|
+
daspy/advanced_tools/strain2vel.py
|
|
17
|
+
daspy/basic_tools/__init__.py
|
|
18
|
+
daspy/basic_tools/filter.py
|
|
19
|
+
daspy/basic_tools/freqattributes.py
|
|
20
|
+
daspy/basic_tools/preprocessing.py
|
|
21
|
+
daspy/basic_tools/visualization.py
|
|
22
|
+
daspy/core/__init__.py
|
|
23
|
+
daspy/core/collection.py
|
|
24
|
+
daspy/core/dasdatetime.py
|
|
25
|
+
daspy/core/example.pkl
|
|
26
|
+
daspy/core/read.py
|
|
27
|
+
daspy/core/section.py
|
|
28
|
+
daspy/core/write.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: DASPy-toolbox
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: DASPy is an open-source project dedicated to provide a python package for DAS (Distributed Acoustic Sensing) data processing, which comprises classic seismic data processing techniques and Specialized algorithms for DAS applications.
|
|
5
5
|
Home-page: https://github.com/HMZ-03/DASPy
|
|
6
6
|
Author: Minzhe Hu, Zefeng Li
|
|
@@ -22,14 +22,24 @@ Requires-Dist: h5py
|
|
|
22
22
|
Requires-Dist: segyio
|
|
23
23
|
Requires-Dist: nptdms
|
|
24
24
|
Requires-Dist: tqdm
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: license
|
|
31
|
+
Dynamic: maintainer
|
|
32
|
+
Dynamic: maintainer-email
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
<img src="https://raw.github.com/hmz-03/daspy/main/website/logo.png" height="200" />
|
|
29
38
|
|
|
30
39
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
31
40
|
[](https://opensource.org/license/mit)
|
|
32
41
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
42
|
+
|
|
33
43
|
[](https://doi.org/10.1785/0220240124)
|
|
34
44
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
35
45
|
[](https://anaconda.org/conda-forge/daspy-toolbox)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
<img src="
|
|
2
|
-
|
|
3
|
-
# DASPy
|
|
1
|
+
<img src="https://raw.github.com/hmz-03/daspy/main/website/logo.png" height="200" />
|
|
4
2
|
|
|
5
3
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
6
4
|
[](https://opensource.org/license/mit)
|
|
7
5
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
6
|
+
|
|
8
7
|
[](https://doi.org/10.1785/0220240124)
|
|
9
8
|
[](https://pypi.org/project/DASPy-toolbox/)
|
|
10
9
|
[](https://anaconda.org/conda-forge/daspy-toolbox)
|
|
@@ -84,7 +84,7 @@ def channel_checking(data, deg=10, thresh=5, continuity=True, adjacent=2,
|
|
|
84
84
|
bad_chn = np.argwhere(deviation < -thresh * mad).ravel().tolist()
|
|
85
85
|
elif mode == 'high':
|
|
86
86
|
bad_chn = np.argwhere(deviation > thresh * mad).ravel().tolist()
|
|
87
|
-
elif mode == '
|
|
87
|
+
elif mode == 'both':
|
|
88
88
|
bad_chn = np.argwhere(deviation < -thresh * mad).ravel().tolist() + \
|
|
89
89
|
np.argwhere(deviation > thresh * mad).ravel().tolist()
|
|
90
90
|
good_chn = list(set(range(nch)) - set(bad_chn))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Purpose: Plot data
|
|
2
2
|
# Author: Minzhe Hu
|
|
3
|
-
# Date:
|
|
3
|
+
# Date: 2025.1.6
|
|
4
4
|
# Email: hmz2018@mail.ustc.edu.cn
|
|
5
5
|
import numpy as np
|
|
6
6
|
import matplotlib.pyplot as plt
|
|
7
7
|
from collections.abc import Sequence
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def plot(data: np.ndarray, dx=None, fs=None, ax=None, obj='waveform', dpi=
|
|
10
|
+
def plot(data: np.ndarray, dx=None, fs=None, ax=None, obj='waveform', dpi=300,
|
|
11
11
|
title=None, transpose=False, t0=0, x0=0, pick=None, f=None, k=None,
|
|
12
12
|
t=None, c=None, cmap=None, vmin=None, vmax=None, dB=False,
|
|
13
13
|
xmode='distance', tmode='time', xlim=None, ylim=None, xlog=False,
|
|
@@ -29,7 +29,9 @@ def plot(data: np.ndarray, dx=None, fs=None, ax=None, obj='waveform', dpi=150,
|
|
|
29
29
|
:param title: str. The title of this axes.
|
|
30
30
|
:param transpose: bool. Transpose the figure or not.
|
|
31
31
|
:param t0, x0: The beginning of time and space.
|
|
32
|
-
:param pick:
|
|
32
|
+
:param pick: dictionary of sequence of picked phases. Key should be 'P' for
|
|
33
|
+
P phase, 'S' for S phase and 'N' for unknown phase type. Required if
|
|
34
|
+
obj=='phasepick'.
|
|
33
35
|
:param f: Sequence of frequency. Required if obj is one of 'spectrum',
|
|
34
36
|
'spectrogram', 'fk' or 'dispersion'.
|
|
35
37
|
:param k: Wavenumber sequence. Required if obj=='fk'.
|
|
@@ -82,14 +84,18 @@ def plot(data: np.ndarray, dx=None, fs=None, ax=None, obj='waveform', dpi=150,
|
|
|
82
84
|
extent = [x0 * 1e-3, (x0 + nch * dx) * 1e-3, t0 + nt / fs, t0]
|
|
83
85
|
|
|
84
86
|
if obj == 'phasepick' and len(pick):
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
pick_color = {'P': 'r', 'S': 'b', 'N': 'k'}
|
|
88
|
+
for phase, pck in pick.items():
|
|
89
|
+
if len(pck):
|
|
90
|
+
pck = np.array(pck).astype(float)
|
|
91
|
+
if xmode.lower() == 'distance':
|
|
92
|
+
pck[:, 0] = (x0 + pck[:, 0] * dx) * 1e-3
|
|
93
|
+
elif xmode.lower() == 'channel':
|
|
94
|
+
pck[:, 0] = x0 + pck[:, 0]
|
|
95
|
+
if tmode.lower() == 'sampling':
|
|
96
|
+
pck[:, 1] = pck[:, 1] / fs
|
|
97
|
+
ax.scatter(pck[:,0], t0 + pck[:,1], marker=',', s=0.1,
|
|
98
|
+
c=pick_color[phase])
|
|
93
99
|
|
|
94
100
|
elif obj in ['spectrum', 'spectrogram', 'fk', 'dispersion']:
|
|
95
101
|
if isinstance(data[0,0], (complex, np.complex64)):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Purpose: Module for handling Collection objects.
|
|
2
2
|
# Author: Minzhe Hu
|
|
3
|
-
# Date: 2025.1.
|
|
3
|
+
# Date: 2025.1.23
|
|
4
4
|
# Email: hmz2018@mail.ustc.edu.cn
|
|
5
5
|
import os
|
|
6
6
|
import warnings
|
|
@@ -63,7 +63,7 @@ class Collection(object):
|
|
|
63
63
|
sec.gauge_length = None
|
|
64
64
|
ftime.append(sec.start_time)
|
|
65
65
|
metadata_list.append((sec.nch, sec.nt, sec.dx, sec.fs,
|
|
66
|
-
sec.gauge_length))
|
|
66
|
+
sec.gauge_length, sec.duration))
|
|
67
67
|
|
|
68
68
|
if len(set(metadata_list)) > 1:
|
|
69
69
|
warnings.warn('More than one kind of setting detected.')
|
|
@@ -71,6 +71,8 @@ class Collection(object):
|
|
|
71
71
|
for i, key in enumerate(['nch', 'nt', 'dx', 'fs', 'gauge_length']):
|
|
72
72
|
if not hasattr(self, key):
|
|
73
73
|
setattr(self, key, metadata[i])
|
|
74
|
+
if flength is None:
|
|
75
|
+
flength = metadata[-1]
|
|
74
76
|
self.ftime = ftime
|
|
75
77
|
elif meta_from_file:
|
|
76
78
|
i = int(len(self.flist) > 1)
|
|
@@ -211,6 +213,9 @@ class Collection(object):
|
|
|
211
213
|
flist.append(self.flist[i])
|
|
212
214
|
ftime.append(self.ftime[i])
|
|
213
215
|
|
|
216
|
+
if len(flist) == 0:
|
|
217
|
+
warnings.warn('Out of collection time range.')
|
|
218
|
+
return None
|
|
214
219
|
if readsec:
|
|
215
220
|
sec = read(flist[0], **kwargs)
|
|
216
221
|
for f in flist[1:]:
|
|
@@ -218,10 +223,9 @@ class Collection(object):
|
|
|
218
223
|
sec.trimming(tmin=stime, tmax=etime)
|
|
219
224
|
return sec
|
|
220
225
|
else:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return coll
|
|
226
|
+
self.flist = flist
|
|
227
|
+
self.ftime = ftime
|
|
228
|
+
return self
|
|
225
229
|
|
|
226
230
|
def _optimize_for_continuity(self, operations):
|
|
227
231
|
method_list = []
|
|
@@ -231,8 +235,8 @@ class Collection(object):
|
|
|
231
235
|
for opera in operations:
|
|
232
236
|
method, kwargs = opera
|
|
233
237
|
if method == 'downsampling':
|
|
234
|
-
if hasattr(kwargs, 'lowpass_filter') and not\
|
|
235
|
-
|
|
238
|
+
if (hasattr(kwargs, 'lowpass_filter') and not\
|
|
239
|
+
kwargs['lowpass_filter']) or not hasattr(kwargs, 'tint'):
|
|
236
240
|
method_list.append('downsampling')
|
|
237
241
|
kwargs_list.append(kwargs)
|
|
238
242
|
else:
|
|
@@ -271,6 +275,16 @@ class Collection(object):
|
|
|
271
275
|
merge = len(self)
|
|
272
276
|
for i in tqdm(range(0, len(self))):
|
|
273
277
|
f = self[i]
|
|
278
|
+
if os.path.getsize(f) == 0:
|
|
279
|
+
for j, method in enumerate(method_list):
|
|
280
|
+
if method == 'time_integration':
|
|
281
|
+
kwargs_list[j]['c'] = 0
|
|
282
|
+
elif method == 'time_differential':
|
|
283
|
+
kwargs_list[j]['prepend'] = 0
|
|
284
|
+
elif method in ['bandpass', 'bandstop', 'lowpass',
|
|
285
|
+
'highpass', 'lowpass_cheby_2']:
|
|
286
|
+
kwargs_list[j]['zi'] = 0
|
|
287
|
+
continue
|
|
274
288
|
sec = read(f, ftype=self.ftype, **read_kwargs)
|
|
275
289
|
for j, method in enumerate(method_list):
|
|
276
290
|
if method in ['taper', 'cosine_taper']:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Purpose: Module for handling DASDateTime objects.
|
|
2
2
|
# Author: Minzhe Hu
|
|
3
|
-
# Date:
|
|
3
|
+
# Date: 2025.2.11
|
|
4
4
|
# Email: hmz2018@mail.ustc.edu.cn
|
|
5
5
|
import time
|
|
6
6
|
from typing import Iterable
|
|
@@ -77,4 +77,26 @@ class DASDateTime(datetime):
|
|
|
77
77
|
|
|
78
78
|
def to_obspy_UTCDateTime(self):
|
|
79
79
|
from obspy import UTCDateTime
|
|
80
|
-
return UTCDateTime(UTCDateTime(self.to_datetime()))
|
|
80
|
+
return UTCDateTime(UTCDateTime(self.to_datetime()))
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def strptime(cls, date_string, format):
|
|
84
|
+
"""
|
|
85
|
+
string, format -> new datetime parsed from a string
|
|
86
|
+
(like time.strptime()).
|
|
87
|
+
"""
|
|
88
|
+
from _strptime import _strptime
|
|
89
|
+
tt, fraction, gmtoff_fraction = _strptime(date_string, format)
|
|
90
|
+
tzname, gmtoff = tt[-2:]
|
|
91
|
+
args = tt[:6] + (fraction,)
|
|
92
|
+
if gmtoff is not None:
|
|
93
|
+
tzdelta = timedelta(seconds=gmtoff, microseconds=gmtoff_fraction)
|
|
94
|
+
if tzname:
|
|
95
|
+
tz = timezone(tzdelta, tzname)
|
|
96
|
+
else:
|
|
97
|
+
tz = timezone(tzdelta)
|
|
98
|
+
args += (tz,)
|
|
99
|
+
elif tt[-3] == 0:
|
|
100
|
+
args += (utc,)
|
|
101
|
+
|
|
102
|
+
return cls(*args)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Purpose: Module for handling Section objects.
|
|
2
2
|
# Author: Minzhe Hu
|
|
3
|
-
# Date:
|
|
3
|
+
# Date: 2025.2.25
|
|
4
4
|
# Email: hmz2018@mail.ustc.edu.cn
|
|
5
5
|
import warnings
|
|
6
6
|
import os
|
|
@@ -517,7 +517,7 @@ class Section(object):
|
|
|
517
517
|
it will be set to parameter obj.
|
|
518
518
|
"""
|
|
519
519
|
if 'data' not in kwargs.keys():
|
|
520
|
-
if obj == 'waveform':
|
|
520
|
+
if obj == 'waveform' or obj == 'phasepick':
|
|
521
521
|
data = deepcopy(self.data)
|
|
522
522
|
elif obj == 'spectrum':
|
|
523
523
|
data, f = self.spectrum(**kwargs_pro)
|
|
@@ -537,8 +537,13 @@ class Section(object):
|
|
|
537
537
|
|
|
538
538
|
if 'ax' not in kwargs.keys() and 'title' not in kwargs.keys():
|
|
539
539
|
kwargs['title'] = obj
|
|
540
|
-
|
|
541
|
-
|
|
540
|
+
|
|
541
|
+
if obj == 'phasepick':
|
|
542
|
+
for phase, pck in kwargs['pick'].items():
|
|
543
|
+
if len(pck) != 0:
|
|
544
|
+
pck = np.array(pck)
|
|
545
|
+
pck[:, 0] -= self.start_channel
|
|
546
|
+
kwargs['pick'][phase] = pck
|
|
542
547
|
|
|
543
548
|
if xmode == 'channel':
|
|
544
549
|
kwargs.setdefault('x0', self.start_channel)
|
|
@@ -611,8 +616,8 @@ class Section(object):
|
|
|
611
616
|
"""
|
|
612
617
|
Normalize for each individual channel using Z-score method.
|
|
613
618
|
|
|
614
|
-
:param method: str. Method for normalization, should be one of 'max'
|
|
615
|
-
'z-score'.
|
|
619
|
+
:param method: str. Method for normalization, should be one of 'max',
|
|
620
|
+
'z-score', or 'one-bit'.
|
|
616
621
|
"""
|
|
617
622
|
self.data = normalization(self.data, method=method)
|
|
618
623
|
if hasattr(self, 'data_type'):
|
|
@@ -1053,11 +1058,13 @@ class Section(object):
|
|
|
1053
1058
|
:return: self or Good channels and bad channels.
|
|
1054
1059
|
"""
|
|
1055
1060
|
good_chn, bad_chn = channel_checking(self.data, **kwargs)
|
|
1061
|
+
good_chn = good_chn + self.start_channel
|
|
1062
|
+
bad_chn = bad_chn + self.start_channel
|
|
1056
1063
|
if use:
|
|
1057
1064
|
self.channel_data(good_chn, replace=True)
|
|
1058
1065
|
return self
|
|
1059
1066
|
else:
|
|
1060
|
-
return good_chn
|
|
1067
|
+
return good_chn, bad_chn
|
|
1061
1068
|
|
|
1062
1069
|
def turning_points(self, data_type='default', **kwargs):
|
|
1063
1070
|
"""
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
|
-
name='DASPy-toolbox', version='1.1.
|
|
5
|
+
name='DASPy-toolbox', version='1.1.2',
|
|
6
6
|
description=(
|
|
7
7
|
'DASPy is an open-source project dedicated to provide a python package '
|
|
8
8
|
'for DAS (Distributed Acoustic Sensing) data processing, which '
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
setup.py
|
|
4
|
-
DASPy_toolbox.egg-info/PKG-INFO
|
|
5
|
-
DASPy_toolbox.egg-info/SOURCES.txt
|
|
6
|
-
DASPy_toolbox.egg-info/dependency_links.txt
|
|
7
|
-
DASPy_toolbox.egg-info/entry_points.txt
|
|
8
|
-
DASPy_toolbox.egg-info/requires.txt
|
|
9
|
-
DASPy_toolbox.egg-info/top_level.txt
|
|
10
|
-
daspy/__init__.py
|
|
11
|
-
daspy/advanced_tools/__init__.py
|
|
12
|
-
daspy/advanced_tools/channel.py
|
|
13
|
-
daspy/advanced_tools/decomposition.py
|
|
14
|
-
daspy/advanced_tools/denoising.py
|
|
15
|
-
daspy/advanced_tools/fdct.py
|
|
16
|
-
daspy/advanced_tools/strain2vel.py
|
|
17
|
-
daspy/basic_tools/__init__.py
|
|
18
|
-
daspy/basic_tools/filter.py
|
|
19
|
-
daspy/basic_tools/freqattributes.py
|
|
20
|
-
daspy/basic_tools/preprocessing.py
|
|
21
|
-
daspy/basic_tools/visualization.py
|
|
22
|
-
daspy/core/__init__.py
|
|
23
|
-
daspy/core/collection.py
|
|
24
|
-
daspy/core/dasdatetime.py
|
|
25
|
-
daspy/core/example.pkl
|
|
26
|
-
daspy/core/make_example.py
|
|
27
|
-
daspy/core/read.py
|
|
28
|
-
daspy/core/section.py
|
|
29
|
-
daspy/core/write.py
|
|
30
|
-
daspy/seismic_detection/__init__.py
|
|
31
|
-
daspy/seismic_detection/calc_travel_time.py
|
|
32
|
-
daspy/seismic_detection/core.py
|
|
33
|
-
daspy/seismic_detection/detection.py
|
|
34
|
-
daspy/seismic_detection/location.py
|
|
35
|
-
daspy/seismic_detection/magnitude.py
|
|
36
|
-
daspy/seismic_detection/phase_picking.py
|
|
37
|
-
daspy/seismic_detection/gamma/__init__.py
|
|
38
|
-
daspy/seismic_detection/gamma/_base.py
|
|
39
|
-
daspy/seismic_detection/gamma/_bayesian_mixture.py
|
|
40
|
-
daspy/seismic_detection/gamma/_gaussian_mixture.py
|
|
41
|
-
daspy/seismic_detection/gamma/app.py
|
|
42
|
-
daspy/seismic_detection/gamma/seismic_ops.py
|
|
43
|
-
daspy/seismic_detection/gamma/utils.py
|
|
44
|
-
daspy/structure_imaging/__init__.py
|
|
45
|
-
daspy/structure_imaging/ambient_noise.py
|
|
46
|
-
daspy/structure_imaging/core.py
|
|
47
|
-
daspy/structure_imaging/dispersion.py
|
|
48
|
-
daspy/structure_imaging/fault_zone.py
|
|
49
|
-
daspy/structure_imaging/inversion.py
|
|
50
|
-
daspy/traffic_monitoring/JamDetection.py
|
|
51
|
-
daspy/traffic_monitoring/SpeedMeasurement.py
|
|
52
|
-
daspy/traffic_monitoring/VehicleDetection.py
|
|
53
|
-
daspy/traffic_monitoring/__init__.py
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import h5py
|
|
2
|
-
import numpy as np
|
|
3
|
-
from daspy import read, Section, DASDateTime
|
|
4
|
-
from daspy.core.dasdatetime import utc
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
origin_time = DASDateTime(2016, 3, 21, 7, 37, 10, 535000, tzinfo=utc)
|
|
8
|
-
|
|
9
|
-
# read DAS data
|
|
10
|
-
dx, fs = 1, 1000
|
|
11
|
-
sec = Section(np.zeros((8721, 0)), dx, fs, data_type='Strain rate')
|
|
12
|
-
filename = ['PoroTomo_iDAS16043_160321073651.h5',
|
|
13
|
-
'PoroTomo_iDAS16043_160321073721.h5',
|
|
14
|
-
'PoroTomo_iDAS16043_160321073751.h5',
|
|
15
|
-
'PoroTomo_iDAS16043_160321073821.h5']
|
|
16
|
-
|
|
17
|
-
first = True
|
|
18
|
-
for fn in filename:
|
|
19
|
-
with h5py.File(fn,'r') as fp:
|
|
20
|
-
if first:
|
|
21
|
-
sec.start_time = DASDateTime.fromtimestamp(fp['t'][0]).astimezone(utc)
|
|
22
|
-
sec.start_channel = fp['channel'][0]
|
|
23
|
-
first = False
|
|
24
|
-
sec += fp['das'][()].T
|
|
25
|
-
|
|
26
|
-
sec.origin_time = origin_time
|
|
27
|
-
sec.trimming(mode=0, xmin=2500, xmax=3000)
|
|
28
|
-
sec.trimming(tmin=origin_time, tmax=origin_time+90)
|
|
29
|
-
sec.downsampling(tint=10)
|
|
30
|
-
sec.trimming(tmin=origin_time+20, tmax=origin_time+70)
|
|
31
|
-
|
|
32
|
-
sec.save('example.py')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from daspy.seismic_detection.core import DetectSection
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
import multiprocessing
|
|
4
|
-
import numpy as np
|
|
5
|
-
from obspy.taup.tau_model import TauModel
|
|
6
|
-
from obspy.taup import TauPyModel
|
|
7
|
-
from daspy.seismic_detection.location import calc_travel_time
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
cores = multiprocessing.cpu_count() - 1
|
|
11
|
-
pool = multiprocessing.Pool(processes=cores)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
filepath, elo, ela, edep, savefile = sys.argv[1:6]
|
|
15
|
-
|
|
16
|
-
elo, ela, edep = map(float, (elo, ela, edep))
|
|
17
|
-
model = TauPyModel()
|
|
18
|
-
model.model = TauModel.from_file(os.path.join(filepath, 'model.npz'))
|
|
19
|
-
geometry = np.load(os.path.join(filepath, 'geometry.npy'))
|
|
20
|
-
tasks = [(model, elo, ela, edep, *geo) for geo in geometry]
|
|
21
|
-
delay = pool.starmap(calc_travel_time, tasks)
|
|
22
|
-
delay = np.array(delay)
|
|
23
|
-
np.save(os.path.join(filepath, savefile), delay)
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from collections.abc import Iterable
|
|
3
|
-
from tqdm import tqdm
|
|
4
|
-
import daspy.basic_tools.visualization as DBV
|
|
5
|
-
from daspy.core import Section, DASDateTime
|
|
6
|
-
from daspy.seismic_detection.phase_picking import *
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def plot(data, obj='waveform', title=None, cmap=None, vmax=None, vmin=None,
|
|
10
|
-
**kwargs):
|
|
11
|
-
if obj == 'pickmap':
|
|
12
|
-
cmap = 'hot' if cmap is None else cmap
|
|
13
|
-
vmax = np.percentile(abs(data), 99) if vmax is None else vmax
|
|
14
|
-
vmin = np.percentile(abs(data), 80) if vmin is None else vmin
|
|
15
|
-
title = obj
|
|
16
|
-
obj = 'waveform'
|
|
17
|
-
|
|
18
|
-
return DBV.plot(data, title=title, cmap=cmap, vmin=vmin, vmax=vmax,
|
|
19
|
-
**kwargs)
|
|
20
|
-
|
|
21
|
-
class DetectSection(Section):
|
|
22
|
-
|
|
23
|
-
def __str__(self):
|
|
24
|
-
describe = ''
|
|
25
|
-
n = max(map(len, self.__dict__.keys()))
|
|
26
|
-
for key, value in self.__dict__.items():
|
|
27
|
-
if key in ['data', 'geometry', 'pickmap']:
|
|
28
|
-
describe = '{}: shape{}\n'.format(key.rjust(n), value.shape) \
|
|
29
|
-
+ describe
|
|
30
|
-
elif key in ['dx', 'start_distance', 'gauge_length']:
|
|
31
|
-
describe += '{}: {} m\n'.format(key.rjust(n), value)
|
|
32
|
-
elif key == 'fs':
|
|
33
|
-
describe += '{}: {} Hz\n'.format(key.rjust(n), value)
|
|
34
|
-
elif key == 'start_time':
|
|
35
|
-
if isinstance(value, DASDateTime):
|
|
36
|
-
describe += '{}: {}\n'.format(key.rjust(n), value)
|
|
37
|
-
else:
|
|
38
|
-
describe += '{}: {} s\n'.format(key.rjust(n), value)
|
|
39
|
-
elif key == 'pick':
|
|
40
|
-
describe += '{}: {}\n'.format(key.rjust(n), len(value))
|
|
41
|
-
else:
|
|
42
|
-
describe += '{}: {}\n'.format(key.rjust(n), value)
|
|
43
|
-
return describe
|
|
44
|
-
|
|
45
|
-
__repr__ = __str__
|
|
46
|
-
|
|
47
|
-
def plot(self, obj='waveform', kwargs_pro={}, **kwargs):
|
|
48
|
-
if obj == 'pickmap':
|
|
49
|
-
if 'data' not in kwargs.keys():
|
|
50
|
-
if not hasattr(self, 'pickmap') or len(kwargs_pro):
|
|
51
|
-
self.calc_pickmap(**kwargs_pro)
|
|
52
|
-
kwargs['data']= self.pickmap
|
|
53
|
-
kwargs.setdefault('cmap', 'hot')
|
|
54
|
-
kwargs.setdefault('vmax', np.percentile(abs(kwargs['data']), 99.9))
|
|
55
|
-
kwargs.setdefault('vmin', np.percentile(abs(kwargs['data']), 95))
|
|
56
|
-
kwargs.setdefault('title', obj)
|
|
57
|
-
obj = 'waveform'
|
|
58
|
-
elif obj == 'phasepick':
|
|
59
|
-
if 'data' not in kwargs.keys():
|
|
60
|
-
kwargs['data']= self.data
|
|
61
|
-
if 'pick' not in kwargs.keys():
|
|
62
|
-
if not hasattr(self, 'pick') or len(kwargs_pro):
|
|
63
|
-
self.map_picking(**kwargs_pro)
|
|
64
|
-
kwargs['pick'] = self.pick
|
|
65
|
-
if len(kwargs['pick']):
|
|
66
|
-
kwargs['pick'][:, 0] -= self.start_channel
|
|
67
|
-
|
|
68
|
-
super().plot(obj=obj, kwargs_pro=kwargs_pro, **kwargs)
|
|
69
|
-
|
|
70
|
-
def calc_pickmap(self, method='sta_lta', **kwargs):
|
|
71
|
-
if isinstance(method, str):
|
|
72
|
-
method = [method]
|
|
73
|
-
self.pickmap = np.zeros_like(self.data)
|
|
74
|
-
for m in method:
|
|
75
|
-
if m == 'sta_lta':
|
|
76
|
-
self.pickmap += sta_lta_map(self.data, self.fs, **kwargs)
|
|
77
|
-
elif m == 'kurto':
|
|
78
|
-
self.pickmap += kurto_map(self.data, self.fs, **kwargs)
|
|
79
|
-
elif m == 'skew':
|
|
80
|
-
self.pickmap += skew_map(self.data, self.fs, **kwargs)
|
|
81
|
-
|
|
82
|
-
return self.pickmap
|
|
83
|
-
|
|
84
|
-
def map_picking(self, thres1=5, thres2=5, choose_max=False, min_dt=0,
|
|
85
|
-
**kwargs):
|
|
86
|
-
if not hasattr(self, 'pickmap') or len(kwargs):
|
|
87
|
-
self.calc_pickmap(**kwargs)
|
|
88
|
-
|
|
89
|
-
pick, amp = map_picking(self.pickmap, thres1=thres1, thres2=thres2,
|
|
90
|
-
choose_max=choose_max,
|
|
91
|
-
min_dsp=min_dt*self.fs).astype(float)
|
|
92
|
-
if len(pick):
|
|
93
|
-
pick[:, 0] += self.start_channel
|
|
94
|
-
pick[:, 1] = pick[:, 1] / self.fs
|
|
95
|
-
|
|
96
|
-
self.pick = pick
|
|
97
|
-
self.pick_amp = amp
|
|
98
|
-
return pick
|
|
99
|
-
|
|
100
|
-
def symmetry_detection(self, win=5000):
|
|
101
|
-
sec = self.copy()
|
|
102
|
-
sec.normalization()
|
|
103
|
-
win_ch = round(win / self.dx)
|
|
104
|
-
cc = np.zeros(self.nch)
|
|
105
|
-
for sch in range(self.nch):
|
|
106
|
-
win_ch_use = min(win_ch, sch, sec.nch-sch-1)
|
|
107
|
-
if win_ch_use > 0:
|
|
108
|
-
panel1 = sec.data[sch-win_ch_use:sch]
|
|
109
|
-
panel1 = panel1[::-1]
|
|
110
|
-
panel2 = sec.data[sch+1:sch+win_ch_use+1]
|
|
111
|
-
cc[sch] = np.sum(panel1 * panel2) / win_ch
|
|
112
|
-
self.signal_channel = self.start_channel + np.argmax(cc)
|
|
113
|
-
return cc / sec.nt
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def trimming_pick(self, pick, t_win=0.5):
|
|
117
|
-
sp = round(t_win * self.fs)
|
|
118
|
-
if isinstance(pick, Iterable):
|
|
119
|
-
if len(pick) != self.nch:
|
|
120
|
-
raise ValueError('Length of pick should equals to channel '
|
|
121
|
-
'number.')
|
|
122
|
-
if isinstance(pick[0], DASDateTime):
|
|
123
|
-
pick = [p - self.start_time for p in pick]
|
|
124
|
-
pick = np.round(np.array(pick) * self.fs).astype(int)
|
|
125
|
-
data = np.zeros((self.nch, 2 * sp))
|
|
126
|
-
for i, p in enumerate(pick):
|
|
127
|
-
data[i] = self.data[i, p-sp:p+sp]
|
|
128
|
-
self.data = data
|
|
129
|
-
self.start_time = -t_win
|
|
130
|
-
else:
|
|
131
|
-
self.trimming(tmin=pick-t_win, tmax=pick+t_win)
|
|
132
|
-
return self
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def relative_arrival(self, pick, t_win=0.5, dch=30, dt_max=0.1, thresh=0,
|
|
136
|
-
positive=True, weight_pow=1):
|
|
137
|
-
dsp_max = round(dt_max * self.fs)
|
|
138
|
-
sec_win1 = self.copy()
|
|
139
|
-
sec_win2 = self.copy()
|
|
140
|
-
sec_win1.trimming_pick(pick, t_win=t_win)
|
|
141
|
-
sec_win2.trimming_pick(pick, t_win=t_win+dt_max)
|
|
142
|
-
G = []
|
|
143
|
-
d = []
|
|
144
|
-
for i in tqdm(range(self.nch)):
|
|
145
|
-
for j in range(1, dch+1):
|
|
146
|
-
if i+j >= self.nch:
|
|
147
|
-
continue
|
|
148
|
-
cc = xcorr(sec_win2.data[i], sec_win1.data[i+j])
|
|
149
|
-
if not positive:
|
|
150
|
-
cc = np.abs(cc)
|
|
151
|
-
w = max(cc)
|
|
152
|
-
if w < thresh:
|
|
153
|
-
continue
|
|
154
|
-
w = w ** weight_pow
|
|
155
|
-
d.append((np.argmax(cc) - dsp_max) * w)
|
|
156
|
-
Gl = np.zeros(self.nch-1)
|
|
157
|
-
Gl[i:i+j] = w
|
|
158
|
-
G.append(Gl)
|
|
159
|
-
|
|
160
|
-
G = np.array(G)
|
|
161
|
-
idx = np.where(np.sum(G, axis=0) > 0)[0]
|
|
162
|
-
print(len(idx))
|
|
163
|
-
G = np.mat(G[:, idx])
|
|
164
|
-
print(G.shape)
|
|
165
|
-
d = np.mat(d).T
|
|
166
|
-
try:
|
|
167
|
-
m = (G.T * G).I * G.T * d
|
|
168
|
-
except:
|
|
169
|
-
m = G.I * d
|
|
170
|
-
print('xxx')
|
|
171
|
-
time_shift_difference = np.zeros(self.nch - 1)
|
|
172
|
-
time_shift_difference[idx] = np.array(m)[:,0]
|
|
173
|
-
time_shift = np.cumsum(time_shift_difference) / self.fs
|
|
174
|
-
time_shift = np.insert(time_shift, 0, 0)
|
|
175
|
-
if isinstance(pick, Iterable):
|
|
176
|
-
if isinstance(pick[0], DASDateTime):
|
|
177
|
-
pick = [p - self.start_time for p in pick]
|
|
178
|
-
|
|
179
|
-
return - time_shift + np.array(pick)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
@classmethod
|
|
183
|
-
def from_section(clc, raw_sec):
|
|
184
|
-
raw_dict = raw_sec.__dict__
|
|
185
|
-
data = raw_dict.pop('data')
|
|
186
|
-
return clc(data, **raw_dict)
|