DASPy-toolbox 1.2.2__tar.gz → 1.2.3__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.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/PKG-INFO +1 -1
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/PKG-INFO +1 -1
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/channel.py +3 -2
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/basic_tools/preprocessing.py +2 -2
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/basic_tools/visualization.py +10 -9
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/collection.py +31 -9
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/dasdatetime.py +2 -2
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/read.py +26 -2
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/section.py +12 -9
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/write.py +3 -1
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/setup.py +1 -1
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/SOURCES.txt +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/dependency_links.txt +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/entry_points.txt +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/requires.txt +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/DASPy_toolbox.egg-info/top_level.txt +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/LICENSE +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/README.md +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/__init__.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/__init__.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/decomposition.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/denoising.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/fdct.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/advanced_tools/strain2vel.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/basic_tools/__init__.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/basic_tools/filter.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/basic_tools/freqattributes.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/__init__.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/example.pkl +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/make_example.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/daspy/core/util.py +0 -0
- {daspy_toolbox-1.2.2 → daspy_toolbox-1.2.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DASPy-toolbox
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DASPy-toolbox
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
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
|
|
@@ -181,7 +181,7 @@ def _channel_location(track_pt):
|
|
|
181
181
|
return np.array(seg_interval), np.array(interp_ch)
|
|
182
182
|
|
|
183
183
|
|
|
184
|
-
def location_interpolation(known_pt, track_pt=None, dx=
|
|
184
|
+
def location_interpolation(known_pt, track_pt=None, dx=1, data_type='lonlat',
|
|
185
185
|
verbose=False):
|
|
186
186
|
"""
|
|
187
187
|
Interpolate to obtain the positions of all channels.
|
|
@@ -209,7 +209,8 @@ def location_interpolation(known_pt, track_pt=None, dx=2, data_type='lonlat',
|
|
|
209
209
|
.astype(int) + 31
|
|
210
210
|
DASProj = Proj(proj='utm', zone=zone, ellps='WGS84',
|
|
211
211
|
preserve_units=False)
|
|
212
|
-
known_pt[:, 0], known_pt[:, 1] = DASProj(known_pt[:, 0],
|
|
212
|
+
known_pt[:, 0], known_pt[:, 1] = DASProj(known_pt[:, 0],
|
|
213
|
+
known_pt[:, 1])
|
|
213
214
|
else:
|
|
214
215
|
assert 'xy' in data_type, ('data_type should be \'lonlat\',\''
|
|
215
216
|
'lonlatheight\', \'xy\' or \'xyz\'')
|
|
@@ -121,9 +121,9 @@ def cosine_taper(data, p=0.1, side='both'):
|
|
|
121
121
|
if not isinstance(p, (tuple, list, np.ndarray)):
|
|
122
122
|
win = tukey(nsp, p)
|
|
123
123
|
if side == 'left':
|
|
124
|
-
win[round(
|
|
124
|
+
win[round(nsp/2):] = 1
|
|
125
125
|
elif side == 'right':
|
|
126
|
-
win[:round(
|
|
126
|
+
win[:round(nsp/2)] = 1
|
|
127
127
|
return data * np.tile(win, (nch, 1))
|
|
128
128
|
else:
|
|
129
129
|
if p[0] > 0:
|
|
@@ -11,9 +11,9 @@ 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, vmin_per=None, vmax=None,
|
|
13
13
|
vmax_per=None, dB=False, xmode='distance', tmode='time', xlim=None,
|
|
14
|
-
ylim=None, xlog=False, ylog=False, xinv=False, yinv=False,
|
|
15
|
-
|
|
16
|
-
colorbar_label=None, savefig=None):
|
|
14
|
+
ylim=None, xlog=False, ylog=False, xinv=False, yinv=False,
|
|
15
|
+
xlabel=True, ylabel=True, xticklabels=True, yticklabels=True,
|
|
16
|
+
colorbar=True, colorbar_label=None, savefig=None):
|
|
17
17
|
"""
|
|
18
18
|
Plot several types of 2-D seismological data.
|
|
19
19
|
|
|
@@ -42,19 +42,20 @@ def plot(data: np.ndarray, dx=None, fs=None, ax=None, obj='waveform', dpi=300,
|
|
|
42
42
|
:param vmin, vmax: Define the data range that the colormap covers.
|
|
43
43
|
:param vmin_per, vmax_per: float. Define the data range that the colormap
|
|
44
44
|
covers by percentile.
|
|
45
|
-
:param dB: bool. Transfer data unit to dB and take 1 as the reference
|
|
45
|
+
:param dB: bool. Transfer data unit to dB and take 1 as the reference
|
|
46
|
+
value.
|
|
46
47
|
:param xmode: str. 'distance' or 'channel'.
|
|
47
48
|
:param tmode: str. 'time' or 'sampling'.
|
|
48
49
|
:param xlim, ylim: Set the x-axis and y-axis view limits.
|
|
49
50
|
:param xlog, ylog: bool. If True, set the x-axis' or y-axis' scale as log.
|
|
50
51
|
:param xlabel, yinv: bool. If True, invert x-axis or y-axis.
|
|
51
|
-
:param xlabel, ylabel: bool or str. Whether to plot a label or what label
|
|
52
|
-
plot for x-axis or y-axis.
|
|
52
|
+
:param xlabel, ylabel: bool or str. Whether to plot a label or what label
|
|
53
|
+
to plot for x-axis or y-axis.
|
|
53
54
|
:param xticklabels, yticklabels: bool or sequence of str. Whether to plot
|
|
54
55
|
ticklabels or what ticklabels to plot for x-axis or y-axis.
|
|
55
|
-
:param colorbar: bool, str or Matplotlib.axes.Axes. Bool means plot
|
|
56
|
-
or not. Str means the location of colorbar. Axes means the
|
|
57
|
-
which the colorbar will be drawn.
|
|
56
|
+
:param colorbar: bool, str or Matplotlib.axes.Axes. Bool means plot
|
|
57
|
+
colorbar or not. Str means the location of colorbar. Axes means the
|
|
58
|
+
Axes into which the colorbar will be drawn.
|
|
58
59
|
:param savefig: str or bool. Figure name to save if needed. If True,
|
|
59
60
|
it will be set to parameter obj.
|
|
60
61
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Purpose: Module for handling Collection objects.
|
|
2
2
|
# Author: Minzhe Hu
|
|
3
|
-
# Date: 2025.
|
|
3
|
+
# Date: 2025.11.26
|
|
4
4
|
# Email: hmz2018@mail.ustc.edu.cn
|
|
5
5
|
import os
|
|
6
6
|
import warnings
|
|
@@ -228,6 +228,8 @@ class Collection(object):
|
|
|
228
228
|
:param spmin, spmax: int. Sampling point range. Only used when
|
|
229
229
|
readsec=True.
|
|
230
230
|
"""
|
|
231
|
+
if start is None:
|
|
232
|
+
start = 0
|
|
231
233
|
if end is None:
|
|
232
234
|
end = len(self.flist)
|
|
233
235
|
if 'stime' in kwargs.keys():
|
|
@@ -239,10 +241,16 @@ class Collection(object):
|
|
|
239
241
|
warnings.warn('In future versions, the parameter \'etime\' will be '
|
|
240
242
|
'replaced by \'end\'.')
|
|
241
243
|
|
|
242
|
-
if start is None
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
if start is None:
|
|
245
|
+
if 'tmin' in kwargs.keys():
|
|
246
|
+
start = kwargs['tmin']
|
|
247
|
+
else:
|
|
248
|
+
start = 0
|
|
249
|
+
if end is None:
|
|
250
|
+
if 'tmax' in kwargs.keys():
|
|
251
|
+
end = kwargs['tmax']
|
|
252
|
+
else:
|
|
253
|
+
end = len(self)
|
|
246
254
|
|
|
247
255
|
if isinstance(start, datetime):
|
|
248
256
|
for i, ftime in enumerate(self.ftime):
|
|
@@ -288,6 +296,18 @@ class Collection(object):
|
|
|
288
296
|
self.ftime = self.ftime[s:e]
|
|
289
297
|
return self
|
|
290
298
|
|
|
299
|
+
def read(self, **kwargs):
|
|
300
|
+
return self.select(readsec=True, **kwargs)
|
|
301
|
+
|
|
302
|
+
def continuous_acquisition(self):
|
|
303
|
+
index = self.file_interruption()
|
|
304
|
+
index = [-1] + index.tolist() + [len(self)-1]
|
|
305
|
+
coll_list = []
|
|
306
|
+
for i in range(len(index) - 1):
|
|
307
|
+
coll = self.copy().select(start=index[i]+1, end=index[i+1]+1)
|
|
308
|
+
coll_list.append(coll)
|
|
309
|
+
return coll_list
|
|
310
|
+
|
|
291
311
|
def _optimize_for_continuity(self, operations):
|
|
292
312
|
method_list = []
|
|
293
313
|
kwargs_list = []
|
|
@@ -296,8 +316,10 @@ class Collection(object):
|
|
|
296
316
|
for opera in operations:
|
|
297
317
|
method, kwargs = opera
|
|
298
318
|
if method == 'downsampling':
|
|
299
|
-
|
|
300
|
-
kwargs
|
|
319
|
+
if_filter = ('tint' not in kwargs.keys() and 'fs' not in
|
|
320
|
+
kwargs.keys()) or ('lowpass_filter' in kwargs.keys() and
|
|
321
|
+
not kwargs['lowpass_filter'])
|
|
322
|
+
if if_filter:
|
|
301
323
|
method_list.append('downsampling')
|
|
302
324
|
kwargs_list.append(kwargs)
|
|
303
325
|
else:
|
|
@@ -356,9 +378,9 @@ class Collection(object):
|
|
|
356
378
|
(not os.path.exists(kwargs_file)):
|
|
357
379
|
raise ValueError('No operations input and no method_list.pkl '
|
|
358
380
|
'and kwargs_list.pkl found in savepath.')
|
|
359
|
-
with open(os.path.join(savepath, 'method_list.pkl'), '
|
|
381
|
+
with open(os.path.join(savepath, 'method_list.pkl'), 'rb') as f:
|
|
360
382
|
method_list = pickle.load(f)
|
|
361
|
-
with open(os.path.join(savepath, 'kwargs_list.pkl'), '
|
|
383
|
+
with open(os.path.join(savepath, 'kwargs_list.pkl'), 'rb') as f:
|
|
362
384
|
kwargs_list = pickle.load(f)
|
|
363
385
|
else:
|
|
364
386
|
method_list, kwargs_list = self._optimize_for_continuity(operations)
|
|
@@ -9,7 +9,7 @@ from datetime import datetime, timedelta, timezone
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
utc = timezone.utc
|
|
12
|
-
local_tz = timezone(timedelta(seconds=-time.
|
|
12
|
+
local_tz = timezone(timedelta(seconds=-time.timezone))
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class DASDateTime(datetime):
|
|
@@ -69,7 +69,7 @@ class DASDateTime(datetime):
|
|
|
69
69
|
|
|
70
70
|
@classmethod
|
|
71
71
|
def from_obspy_UTCDateTime(cls, dt):
|
|
72
|
-
return cls.from_datetime(dt.datetime)
|
|
72
|
+
return cls.from_datetime(dt.datetime).replace(tzinfo=utc)
|
|
73
73
|
|
|
74
74
|
def to_datetime(self):
|
|
75
75
|
return datetime.fromtimestamp(self.timestamp(), tz=self.tzinfo)
|
|
@@ -131,6 +131,23 @@ def with_trimming(func):
|
|
|
131
131
|
return wrapper
|
|
132
132
|
|
|
133
133
|
|
|
134
|
+
class DummyObject:
|
|
135
|
+
def __init__(self, *args, **kwargs):
|
|
136
|
+
pass
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class SafeUnpickler(pickle.Unpickler):
|
|
140
|
+
def find_class(self, module, name):
|
|
141
|
+
try:
|
|
142
|
+
return super().find_class(module, name)
|
|
143
|
+
except ModuleNotFoundError:
|
|
144
|
+
print(f"Skip missing module: {module}.{name}")
|
|
145
|
+
return DummyObject
|
|
146
|
+
except AttributeError:
|
|
147
|
+
print(f"Skip missing class: {module}.{name}")
|
|
148
|
+
return DummyObject
|
|
149
|
+
|
|
150
|
+
|
|
134
151
|
def _read_pkl(fname, headonly=False, file_format='auto', chmin=None, chmax=None,
|
|
135
152
|
dch=1, xmin=None, xmax=None, tmin=None, tmax=None, spmin=None,
|
|
136
153
|
spmax=None):
|
|
@@ -138,7 +155,8 @@ def _read_pkl(fname, headonly=False, file_format='auto', chmin=None, chmax=None,
|
|
|
138
155
|
Read data and metadata from a pickle file.
|
|
139
156
|
"""
|
|
140
157
|
with open(fname, 'rb') as f:
|
|
141
|
-
pkl_data = pickle.load(f)
|
|
158
|
+
# pkl_data = pickle.load(f)
|
|
159
|
+
pkl_data = SafeUnpickler(f).load()
|
|
142
160
|
if isinstance(pkl_data, np.ndarray):
|
|
143
161
|
warnings.warn('This data format doesn\'t include channel interval'
|
|
144
162
|
'and sampling rate. Please set manually')
|
|
@@ -484,7 +502,13 @@ def _read_h5(fname, headonly=False, file_format='auto', chmin=None, chmax=None,
|
|
|
484
502
|
metadata['headers'] = _read_h5_headers(h5_file)
|
|
485
503
|
shape = dataset.shape
|
|
486
504
|
if len(shape) == 3:
|
|
487
|
-
|
|
505
|
+
if headonly:
|
|
506
|
+
fs = int(metadata['fs'])
|
|
507
|
+
fs_b = attrs.get('BlockRate', [1000])[0] / 1e3
|
|
508
|
+
nsp_b = round(fs/fs_b)
|
|
509
|
+
shape = (shape[0] * nsp_b, shape[2])
|
|
510
|
+
else:
|
|
511
|
+
shape = (shape[0] * shape[1], shape[2])
|
|
488
512
|
if transpose:
|
|
489
513
|
shape = shape[::-1]
|
|
490
514
|
si, sj, metadata = _trimming_slice_metadata(shape, metadata=metadata,
|
|
@@ -196,7 +196,7 @@ class Section(object):
|
|
|
196
196
|
|
|
197
197
|
@property
|
|
198
198
|
def end_channel(self):
|
|
199
|
-
return self.start_channel + self.nch
|
|
199
|
+
return self.start_channel + self.nch
|
|
200
200
|
|
|
201
201
|
@property
|
|
202
202
|
def distance(self):
|
|
@@ -463,8 +463,8 @@ class Section(object):
|
|
|
463
463
|
:param ftype: None or str. None for automatic detection), or 'pkl',
|
|
464
464
|
'pickle', 'tdms', 'h5', 'hdf5', 'segy', 'sgy', 'npy'.
|
|
465
465
|
:param keep_format: bool. If True, we will make a copy of the
|
|
466
|
-
self.source file and make changes to it. This will strictly
|
|
467
|
-
the original format, but will cost more IO resources.
|
|
466
|
+
self.source file and make changes to it. This will strictly
|
|
467
|
+
preserve the original format, but will cost more IO resources.
|
|
468
468
|
:param dtype: str. The data type of the saved data.
|
|
469
469
|
:param file_format: Format in which the file is saved. Only works when
|
|
470
470
|
keep_format == False. 'auto' for raw file format or the most common
|
|
@@ -647,9 +647,11 @@ class Section(object):
|
|
|
647
647
|
if hasattr(self, 'origin_time'):
|
|
648
648
|
kwargs['t0'] -= self.origin_time
|
|
649
649
|
if ('transpose' in kwargs.keys()) and kwargs['transpose']:
|
|
650
|
-
kwargs.setdefault('xlabel',
|
|
650
|
+
kwargs.setdefault('xlabel',
|
|
651
|
+
'Times after occurance (s)')
|
|
651
652
|
else:
|
|
652
|
-
kwargs.setdefault('ylabel',
|
|
653
|
+
kwargs.setdefault('ylabel',
|
|
654
|
+
'Times after occurance (s)')
|
|
653
655
|
else:
|
|
654
656
|
tmode == 'start'
|
|
655
657
|
if tmode == 'start':
|
|
@@ -1097,12 +1099,13 @@ class Section(object):
|
|
|
1097
1099
|
if ('ch1' in kwargs.keys()) or ('ch2' in kwargs.keys()):
|
|
1098
1100
|
kwargs['chmin'] = kwargs.pop('ch1', 0)
|
|
1099
1101
|
kwargs['chmax'] = kwargs.pop('ch2', self.nch)
|
|
1100
|
-
warnings.warn("'ch1' and 'ch2' attribute will be renamed to
|
|
1101
|
-
" and 'chmax' in a future release.",
|
|
1102
|
+
warnings.warn("'ch1' and 'ch2' attribute will be renamed to "
|
|
1103
|
+
"'chmin' and 'chmax' in a future release.",
|
|
1104
|
+
FutureWarning)
|
|
1102
1105
|
if 'nch' in kwargs.keys():
|
|
1103
1106
|
kwargs['dch'] = kwargs.pop('nch', 1)
|
|
1104
|
-
warnings.warn("'nch' attribute will be renamed to 'dch' in a
|
|
1105
|
-
" release.", FutureWarning)
|
|
1107
|
+
warnings.warn("'nch' attribute will be renamed to 'dch' in a "
|
|
1108
|
+
"future release.", FutureWarning)
|
|
1106
1109
|
|
|
1107
1110
|
if 'chmin' in kwargs.keys():
|
|
1108
1111
|
chmin = int(kwargs.pop('chmin') - self.start_channel)
|
|
@@ -35,8 +35,10 @@ def write(sec, fname, ftype=None, raw_fname=None, dtype=None,
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def write_pkl(sec, fname):
|
|
38
|
+
save_dict = sec.__dict__
|
|
39
|
+
save_dict.pop('source', None)
|
|
38
40
|
with open(fname, 'wb') as f:
|
|
39
|
-
pickle.dump(
|
|
41
|
+
pickle.dump(save_dict, f)
|
|
40
42
|
return None
|
|
41
43
|
|
|
42
44
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
|
-
name='DASPy-toolbox', version='1.2.
|
|
5
|
+
name='DASPy-toolbox', version='1.2.3',
|
|
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 '
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|