sigmt 2.1.4__tar.gz → 2.2.1__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.
- sigmt-2.2.1/PKG-INFO +59 -0
- sigmt-2.2.1/README.md +44 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/setup.py +3 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/__version__.py +1 -1
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/band_averaging.py +107 -50
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/robust_estimation.py +17 -9
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/sigproc.py +23 -7
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/statistics.py +5 -1
- {sigmt-2.1.4/sigmt/gui → sigmt-2.2.1/sigmt/gui/metronix}/metronix.py +47 -35
- {sigmt-2.1.4/sigmt/gui → sigmt-2.2.1/sigmt/gui/metronix}/metronix_dialogs.py +34 -17
- sigmt-2.2.1/sigmt/gui/phoenix/__init__.py +0 -0
- sigmt-2.2.1/sigmt/gui/phoenix/phoenix.py +1552 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/gui/project_related/create_project.py +7 -3
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/gui/project_related/edit_project.py +8 -4
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/main.py +25 -4
- sigmt-2.2.1/sigmt/utils/__init__.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/edi/edi_ops.py +12 -2
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/metronix/calibration.py +11 -4
- sigmt-2.2.1/sigmt/utils/phoenix/__init__.py +0 -0
- sigmt-2.2.1/sigmt/utils/phoenix/calibration.py +52 -0
- sigmt-2.2.1/sigmt/utils/phoenix/phoenix_readers.py +98 -0
- sigmt-2.2.1/sigmt/utils/phoenix/phoenix_utils.py +846 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/utils.py +31 -18
- sigmt-2.2.1/sigmt.egg-info/PKG-INFO +59 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt.egg-info/SOURCES.txt +10 -3
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt.egg-info/requires.txt +1 -0
- sigmt-2.1.4/PKG-INFO +0 -67
- sigmt-2.1.4/README.md +0 -41
- sigmt-2.1.4/sigmt.egg-info/PKG-INFO +0 -67
- {sigmt-2.1.4 → sigmt-2.2.1}/LICENSE +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/MANIFEST.in +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/setup.cfg +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/__init__.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/data_selection_tools.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/perform_data_selection.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/core/plots.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/gui/__init__.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/gui/about_dialog.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/gui/edi_merger.py +0 -0
- {sigmt-2.1.4/sigmt/utils → sigmt-2.2.1/sigmt/gui/metronix}/__init__.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/images/sigmt.ico +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/frequency_table.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/metronix/cal_from_metronix_txt.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/metronix/cal_from_xml.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt/utils/metronix/metronix_utils.py +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt.egg-info/dependency_links.txt +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt.egg-info/entry_points.txt +0 -0
- {sigmt-2.1.4 → sigmt-2.2.1}/sigmt.egg-info/top_level.txt +0 -0
sigmt-2.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sigmt
|
|
3
|
+
Version: 2.2.1
|
|
4
|
+
Summary: A tool for magnetotelluric time series processing
|
|
5
|
+
Home-page: https://github.com/ajithabhks/sigmt
|
|
6
|
+
Author: Ajithabh K.S.
|
|
7
|
+
Author-email: ajithabhks@gmail.com
|
|
8
|
+
License: GPL
|
|
9
|
+
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
|
|
16
|
+
[](https://pypi.org/project/sigmt/)
|
|
17
|
+
|
|
18
|
+
# SigMT: An open-source Python package for magnetotelluric data processing
|
|
19
|
+
|
|
20
|
+
SigMT is an open-source Python package developed for the processing of magnetotelluric (MT) time series data to estimate MT impedance and tipper responses. The package enables data processing with minimal manual intervention by utilizing a Mahalanobis distance–based data selection tool. Final estimation is performed using a robust statistical approach. In addition, SigMT includes noise rejection tools such as coherency thresholding and polarization direction analysis to enhance the reliability of the estimated MT responses.
|
|
21
|
+
|
|
22
|
+
The package currently supports Metronix and Phoenix (MTU-5C) time series formats through a graphical user interface.
|
|
23
|
+
|
|
24
|
+
## How to install?
|
|
25
|
+
|
|
26
|
+
Open anaconda prompt and type:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install sigmt
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After installation, type:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
sigmt
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
* <a href="https://ajithabh.com/projects/sigmt/sigmt_metronix_user_guide.html" target="_blank">Read Metronix User Guide</a>
|
|
40
|
+
* <a href="https://ajithabh.com/projects/sigmt/sigmt_phoenix_user_guide.html" target="_blank">Read Phoenix User Guide</a>
|
|
41
|
+
|
|
42
|
+
## How to cite?
|
|
43
|
+
If you use SigMT for publication, please cite the following paper:
|
|
44
|
+
|
|
45
|
+
Ajithabh, K.S., Patro, P.K., 2023. SigMT: An open-source Python package for magnetotelluric data processing. Computers & Geosciences, 171, 105270. https://doi.org/10.1016/j.cageo.2022.105270
|
|
46
|
+
|
|
47
|
+
## Issues
|
|
48
|
+
If you have any questions, feedback, or suggestions regarding SigMT, feel free to open an issue.
|
|
49
|
+
|
|
50
|
+
## Downloads
|
|
51
|
+
* <a href="https://cloud.geo-metronix.de/s/GcigJA3Zp8zTAif" target="_blank">Metronix Test Data Link</a>
|
|
52
|
+
Download Northern_Mining.zip, use Sarıçam site in the ts folder.
|
|
53
|
+
|
|
54
|
+
## Contact details
|
|
55
|
+
* K. S. Ajithabh
|
|
56
|
+
|
|
57
|
+
`Email:` ajithabhks@gmail.com
|
|
58
|
+
|
|
59
|
+
|
sigmt-2.2.1/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[](https://pypi.org/project/sigmt/)
|
|
2
|
+
|
|
3
|
+
# SigMT: An open-source Python package for magnetotelluric data processing
|
|
4
|
+
|
|
5
|
+
SigMT is an open-source Python package developed for the processing of magnetotelluric (MT) time series data to estimate MT impedance and tipper responses. The package enables data processing with minimal manual intervention by utilizing a Mahalanobis distance–based data selection tool. Final estimation is performed using a robust statistical approach. In addition, SigMT includes noise rejection tools such as coherency thresholding and polarization direction analysis to enhance the reliability of the estimated MT responses.
|
|
6
|
+
|
|
7
|
+
The package currently supports Metronix and Phoenix (MTU-5C) time series formats through a graphical user interface.
|
|
8
|
+
|
|
9
|
+
## How to install?
|
|
10
|
+
|
|
11
|
+
Open anaconda prompt and type:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install sigmt
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
After installation, type:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
sigmt
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
* <a href="https://ajithabh.com/projects/sigmt/sigmt_metronix_user_guide.html" target="_blank">Read Metronix User Guide</a>
|
|
25
|
+
* <a href="https://ajithabh.com/projects/sigmt/sigmt_phoenix_user_guide.html" target="_blank">Read Phoenix User Guide</a>
|
|
26
|
+
|
|
27
|
+
## How to cite?
|
|
28
|
+
If you use SigMT for publication, please cite the following paper:
|
|
29
|
+
|
|
30
|
+
Ajithabh, K.S., Patro, P.K., 2023. SigMT: An open-source Python package for magnetotelluric data processing. Computers & Geosciences, 171, 105270. https://doi.org/10.1016/j.cageo.2022.105270
|
|
31
|
+
|
|
32
|
+
## Issues
|
|
33
|
+
If you have any questions, feedback, or suggestions regarding SigMT, feel free to open an issue.
|
|
34
|
+
|
|
35
|
+
## Downloads
|
|
36
|
+
* <a href="https://cloud.geo-metronix.de/s/GcigJA3Zp8zTAif" target="_blank">Metronix Test Data Link</a>
|
|
37
|
+
Download Northern_Mining.zip, use Sarıçam site in the ts folder.
|
|
38
|
+
|
|
39
|
+
## Contact details
|
|
40
|
+
* K. S. Ajithabh
|
|
41
|
+
|
|
42
|
+
`Email:` ajithabhks@gmail.com
|
|
43
|
+
|
|
44
|
+
|
|
@@ -10,7 +10,10 @@ setup(
|
|
|
10
10
|
version=__version__,
|
|
11
11
|
packages=['sigmt', 'sigmt.core',
|
|
12
12
|
'sigmt.gui', 'sigmt.utils',
|
|
13
|
+
'sigmt.gui.metronix',
|
|
14
|
+
'sigmt.gui.phoenix',
|
|
13
15
|
'sigmt.utils.edi', 'sigmt.utils.metronix',
|
|
16
|
+
'sigmt.utils.phoenix',
|
|
14
17
|
'sigmt.gui.project_related'],
|
|
15
18
|
include_package_data=True,
|
|
16
19
|
install_requires=requirements,
|
|
@@ -15,6 +15,7 @@ import sigmt.core.sigproc as sp
|
|
|
15
15
|
import sigmt.core.statistics as stats
|
|
16
16
|
import sigmt.utils.utils as utils
|
|
17
17
|
from sigmt.utils.metronix.calibration import MetronixCalibration
|
|
18
|
+
from sigmt.utils.phoenix.calibration import PhoenixCalibration
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
class BandAveraging:
|
|
@@ -23,24 +24,29 @@ class BandAveraging:
|
|
|
23
24
|
|
|
24
25
|
"""
|
|
25
26
|
|
|
26
|
-
def __init__(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
time_series: dict[str, np.ndarray],
|
|
30
|
+
sampling_frequency: float,
|
|
31
|
+
fft_length: int = 1024,
|
|
32
|
+
parzen_window_radius: float = 0.25,
|
|
33
|
+
overlap: int = 50,
|
|
34
|
+
frequencies_per_decade: int = 12,
|
|
35
|
+
remote_reference: bool = False,
|
|
36
|
+
calibrate_electric: bool = False,
|
|
37
|
+
calibrate_magnetic: bool = False,
|
|
38
|
+
calibration_data_electric: Optional[dict[str, dict[str, float]]] = None,
|
|
39
|
+
calibration_data_magnetic: Optional[dict] = None,
|
|
40
|
+
apply_notch_filter: bool = False,
|
|
41
|
+
target_frequency_table_type: Optional[
|
|
42
|
+
Literal['default', 'metronix', 'explicit']] = 'default',
|
|
43
|
+
instrument: Optional[Literal['metronix', 'phoenix']] = None,
|
|
44
|
+
notch_frequency: Optional[float] = None,
|
|
45
|
+
notch_harmonics: Optional[int] = None,
|
|
46
|
+
process_mt: bool = True,
|
|
47
|
+
process_tipper: bool = True,
|
|
48
|
+
reshape: Optional[bool] = True
|
|
49
|
+
) -> None:
|
|
44
50
|
"""
|
|
45
51
|
Constructor
|
|
46
52
|
|
|
@@ -191,6 +197,7 @@ class BandAveraging:
|
|
|
191
197
|
self.process_mt = process_mt
|
|
192
198
|
self.process_tipper = process_tipper
|
|
193
199
|
self.target_frequency_table_type = target_frequency_table_type
|
|
200
|
+
self.instrument = instrument
|
|
194
201
|
|
|
195
202
|
# Class related attributes
|
|
196
203
|
self.channels = None
|
|
@@ -200,16 +207,25 @@ class BandAveraging:
|
|
|
200
207
|
self.dof = None
|
|
201
208
|
self.spectra = None
|
|
202
209
|
|
|
203
|
-
# Dividing time series into several time windows of length equals
|
|
204
|
-
# depend on the time series overlap.
|
|
205
|
-
|
|
210
|
+
# Dividing time series into several time windows of length equals
|
|
211
|
+
# to fft length. Number of windows will depend on the time series overlap.
|
|
212
|
+
if reshape:
|
|
213
|
+
self.time_series = _reshape_time_series_with_overlap(
|
|
214
|
+
time_series=time_series,
|
|
215
|
+
fft_length=fft_length,
|
|
216
|
+
overlap=overlap
|
|
217
|
+
)
|
|
218
|
+
else:
|
|
219
|
+
self.time_series = time_series
|
|
206
220
|
del time_series
|
|
207
221
|
|
|
208
|
-
self.ft_list = utils.get_target_frequency_list(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
222
|
+
self.ft_list = utils.get_target_frequency_list(
|
|
223
|
+
sampling_frequency=self.sampling_frequency,
|
|
224
|
+
parzen_window_radius=self.parzen_window_radius,
|
|
225
|
+
fft_length=self.fft_length,
|
|
226
|
+
table_type=self.target_frequency_table_type,
|
|
227
|
+
frequencies_per_decade=frequencies_per_decade
|
|
228
|
+
)
|
|
213
229
|
|
|
214
230
|
self.get_channels() # Get list of available ts channel. 'Ex', 'Ey', ....
|
|
215
231
|
if calibrate_electric:
|
|
@@ -246,10 +262,12 @@ class BandAveraging:
|
|
|
246
262
|
"""
|
|
247
263
|
print('Calibrating electric field channels.')
|
|
248
264
|
if 'ex' in self.channels:
|
|
249
|
-
dipole_ns = abs(self.calibration_data_electric['ex']['x1']) +
|
|
265
|
+
dipole_ns = (np.abs(self.calibration_data_electric['ex']['x1']) +
|
|
266
|
+
np.abs(self.calibration_data_electric['ex']['x2']))
|
|
250
267
|
self.time_series['ex'] = self.time_series['ex'] / (1 * dipole_ns / 1000)
|
|
251
268
|
if 'ey' in self.channels:
|
|
252
|
-
dipole_ew = abs(self.calibration_data_electric['ey']['y1']) +
|
|
269
|
+
dipole_ew = (np.abs(self.calibration_data_electric['ey']['y1']) +
|
|
270
|
+
np.abs(self.calibration_data_electric['ey']['y2']))
|
|
253
271
|
self.time_series['ey'] = self.time_series['ey'] / (1 * dipole_ew / 1000)
|
|
254
272
|
|
|
255
273
|
def calibrate_magnetic(self) -> None:
|
|
@@ -265,7 +283,12 @@ class BandAveraging:
|
|
|
265
283
|
# Create a list mag channels out of desired elements if existing in self.channels
|
|
266
284
|
magnetic_channels = [element for element in desired_elements if element in self.channels]
|
|
267
285
|
for channel in magnetic_channels:
|
|
268
|
-
if self.
|
|
286
|
+
if self.instrument == 'metronix':
|
|
287
|
+
if not self.calibration_data_magnetic['instrument'] == 'metronix':
|
|
288
|
+
raise ValueError(
|
|
289
|
+
f"Calibration data instrument mismatch: expected 'metronix', "
|
|
290
|
+
f"got {self.calibration_data_magnetic['instrument']}"
|
|
291
|
+
)
|
|
269
292
|
sensor_type = self.calibration_data_magnetic[channel]['sensor_type']
|
|
270
293
|
if self.calibration_data_magnetic[channel]['chopper_status'] == 1:
|
|
271
294
|
chopper_status = "chopper_on"
|
|
@@ -273,10 +296,23 @@ class BandAveraging:
|
|
|
273
296
|
chopper_status = "chopper_off"
|
|
274
297
|
else:
|
|
275
298
|
chopper_status = None
|
|
276
|
-
calibration_data = self.calibration_data_magnetic[channel]['calibration_data'][
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
299
|
+
calibration_data = self.calibration_data_magnetic[channel]['calibration_data'][
|
|
300
|
+
chopper_status]
|
|
301
|
+
calibration_object = MetronixCalibration(
|
|
302
|
+
xfft=self.spectra[channel],
|
|
303
|
+
fft_freqs=self.fft_frequencies,
|
|
304
|
+
sensor_type=sensor_type,
|
|
305
|
+
chopper_status=chopper_status,
|
|
306
|
+
calibration_data=calibration_data
|
|
307
|
+
)
|
|
308
|
+
self.spectra[channel] = calibration_object.calibrated_data
|
|
309
|
+
elif self.instrument == 'phoenix':
|
|
310
|
+
calibration_data = self.calibration_data_magnetic[channel]['calibration_data']
|
|
311
|
+
calibration_object = PhoenixCalibration(
|
|
312
|
+
xfft=self.spectra[channel],
|
|
313
|
+
fft_freqs=self.fft_frequencies,
|
|
314
|
+
calibration_data=calibration_data
|
|
315
|
+
)
|
|
280
316
|
self.spectra[channel] = calibration_object.calibrated_data
|
|
281
317
|
else:
|
|
282
318
|
raise NotImplementedError(
|
|
@@ -299,11 +335,13 @@ class BandAveraging:
|
|
|
299
335
|
|
|
300
336
|
# Submit each task to the executor
|
|
301
337
|
for channel in self.channels:
|
|
302
|
-
futures[channel] = executor.submit(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
338
|
+
futures[channel] = executor.submit(
|
|
339
|
+
sp.notch_filter_sos,
|
|
340
|
+
time_series=self.time_series[channel],
|
|
341
|
+
sampling_frequency=self.sampling_frequency,
|
|
342
|
+
notch_frequency=self.notch_frequency,
|
|
343
|
+
harmonics=self.notch_harmonics
|
|
344
|
+
)
|
|
307
345
|
|
|
308
346
|
# Retrieve the results when needed
|
|
309
347
|
for channel, future in futures.items():
|
|
@@ -333,8 +371,11 @@ class BandAveraging:
|
|
|
333
371
|
print('Performing FFT.')
|
|
334
372
|
self.spectra = {}
|
|
335
373
|
for channel in self.channels:
|
|
336
|
-
self.fft_frequencies, self.spectra[channel] = sp.do_fft(
|
|
337
|
-
|
|
374
|
+
self.fft_frequencies, self.spectra[channel] = sp.do_fft(
|
|
375
|
+
ts=self.time_series[channel],
|
|
376
|
+
fs=self.sampling_frequency,
|
|
377
|
+
fft_length=self.fft_length
|
|
378
|
+
)
|
|
338
379
|
|
|
339
380
|
def perform_band_averaging(self) -> None:
|
|
340
381
|
"""
|
|
@@ -348,16 +389,22 @@ class BandAveraging:
|
|
|
348
389
|
|
|
349
390
|
# Creating empty arrays
|
|
350
391
|
self.dof = np.empty(self.ft_list.shape[0], dtype=int) # Degree of freedom
|
|
351
|
-
self.avgf = np.empty(self.ft_list.shape[0],
|
|
392
|
+
self.avgf = np.empty(self.ft_list.shape[0],
|
|
393
|
+
dtype=int) # Number of frequencies used for averaging
|
|
352
394
|
|
|
353
395
|
# Create a 3D array for parzen window for all target frequencies
|
|
354
396
|
parzen_window = np.empty(
|
|
355
|
-
(self.spectra[next(iter(self.spectra))].shape[0], 1, self.ft_list.shape[0]),
|
|
397
|
+
(self.spectra[next(iter(self.spectra))].shape[0], 1, self.ft_list.shape[0]),
|
|
398
|
+
dtype=float)
|
|
356
399
|
|
|
357
400
|
# Populating parzen window arrays based on target frequency and window radius
|
|
358
401
|
for i in range(self.ft_list.shape[0]):
|
|
359
402
|
ft = float(self.ft_list[i])
|
|
360
|
-
parzen_window[:, :, i] = stats.parzen(
|
|
403
|
+
parzen_window[:, :, i] = stats.parzen(
|
|
404
|
+
f=self.fft_frequencies,
|
|
405
|
+
ft=ft,
|
|
406
|
+
cr=self.parzen_window_radius
|
|
407
|
+
)
|
|
361
408
|
self.dof[i] = (2 * 2 * np.sum(parzen_window[:, :, i] != 0)) - 4
|
|
362
409
|
self.avgf[i] = np.sum(parzen_window[:, :, i] != 0)
|
|
363
410
|
|
|
@@ -514,10 +561,18 @@ class BandAveraging:
|
|
|
514
561
|
axis=0) / sum_parzen)
|
|
515
562
|
|
|
516
563
|
# Computing the Tipper transfer function for all time windows
|
|
517
|
-
self.band_averaged_dataset['tzx'] = (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
564
|
+
self.band_averaged_dataset['tzx'] = (
|
|
565
|
+
(self.band_averaged_dataset['hzhx'] *
|
|
566
|
+
self.band_averaged_dataset['hyhy']) -
|
|
567
|
+
(self.band_averaged_dataset['hzhy'] *
|
|
568
|
+
self.band_averaged_dataset['hyhx'])
|
|
569
|
+
) / denominator
|
|
570
|
+
self.band_averaged_dataset['tzy'] = (
|
|
571
|
+
(self.band_averaged_dataset['hzhy'] *
|
|
572
|
+
self.band_averaged_dataset['hxhx']) -
|
|
573
|
+
(self.band_averaged_dataset['hzhx'] *
|
|
574
|
+
self.band_averaged_dataset['hxhy'])
|
|
575
|
+
) / denominator
|
|
521
576
|
|
|
522
577
|
# TODO: This may not be created in this class
|
|
523
578
|
self.band_averaged_dataset['hz_selection_coh'] = xr.DataArray(
|
|
@@ -538,8 +593,10 @@ def _reshape_time_series_with_overlap(time_series, fft_length, overlap):
|
|
|
538
593
|
|
|
539
594
|
"""
|
|
540
595
|
for channel in time_series:
|
|
541
|
-
time_series[channel] = utils.reshape_array_with_overlap(
|
|
542
|
-
|
|
543
|
-
|
|
596
|
+
time_series[channel] = utils.reshape_array_with_overlap(
|
|
597
|
+
window_length=fft_length,
|
|
598
|
+
overlap=overlap,
|
|
599
|
+
data=time_series[channel]
|
|
600
|
+
)
|
|
544
601
|
|
|
545
602
|
return time_series
|
|
@@ -115,7 +115,8 @@ class RobustEstimation:
|
|
|
115
115
|
f'Channel: {self.channel}, ft: {self.ft} Hz. Applying Mahalanobis distance condition.')
|
|
116
116
|
self.filtered_dataset = self.filtered_dataset.isel(time_window=selected_windows)
|
|
117
117
|
else:
|
|
118
|
-
print(
|
|
118
|
+
print(
|
|
119
|
+
'Skipping Mahalanobis distance condition due to insufficient time windows.')
|
|
119
120
|
print(
|
|
120
121
|
f'Channel: {self.channel}, ft: {self.ft} Hz. Getting Jackknife initial guess.')
|
|
121
122
|
self.get_jackknife_initial_guess()
|
|
@@ -182,14 +183,16 @@ class RobustEstimation:
|
|
|
182
183
|
if not self.processing_mode == "Tipper Only":
|
|
183
184
|
if self.channel == 'ex':
|
|
184
185
|
self.filtered_dataset['selection_array_ex'] = (
|
|
185
|
-
self.filtered_dataset['ex_selection_coh'] * self.filtered_dataset[
|
|
186
|
+
self.filtered_dataset['ex_selection_coh'] * self.filtered_dataset[
|
|
187
|
+
'alpha_e_selection'] *
|
|
186
188
|
self.filtered_dataset['alpha_h_selection'])
|
|
187
189
|
# Avoid crashing due to insufficient data
|
|
188
190
|
if np.sum(self.filtered_dataset['selection_array_ex']) < 10:
|
|
189
191
|
print('There is not enough data to continue the regression.')
|
|
190
192
|
print(
|
|
191
193
|
f'Trying to remove polarization direction (ex) related data rejections for ft:{self.ft} Hz if applied.')
|
|
192
|
-
self.filtered_dataset['selection_array_ex'] = self.filtered_dataset[
|
|
194
|
+
self.filtered_dataset['selection_array_ex'] = self.filtered_dataset[
|
|
195
|
+
'ex_selection_coh'].copy()
|
|
193
196
|
if np.sum(self.filtered_dataset['selection_array_ex']) <= 10:
|
|
194
197
|
print('There is still not enough data to continue the regression.')
|
|
195
198
|
print(
|
|
@@ -201,7 +204,8 @@ class RobustEstimation:
|
|
|
201
204
|
|
|
202
205
|
if self.channel == 'ey':
|
|
203
206
|
self.filtered_dataset['selection_array_ey'] = (
|
|
204
|
-
self.filtered_dataset['ey_selection_coh'] * self.filtered_dataset[
|
|
207
|
+
self.filtered_dataset['ey_selection_coh'] * self.filtered_dataset[
|
|
208
|
+
'alpha_e_selection'] *
|
|
205
209
|
self.filtered_dataset['alpha_h_selection'])
|
|
206
210
|
# Avoid crashing due to insufficient data
|
|
207
211
|
if np.sum(self.filtered_dataset['selection_array_ey']) < 10:
|
|
@@ -209,7 +213,8 @@ class RobustEstimation:
|
|
|
209
213
|
print(
|
|
210
214
|
f'Trying to remove polarization direction (ey) related data rejections for ft:{self.ft} Hz '
|
|
211
215
|
f'if applied.')
|
|
212
|
-
self.filtered_dataset['selection_array_ey'] = self.filtered_dataset[
|
|
216
|
+
self.filtered_dataset['selection_array_ey'] = self.filtered_dataset[
|
|
217
|
+
'ey_selection_coh'].copy()
|
|
213
218
|
if np.sum(self.filtered_dataset['selection_array_ey']) <= 10:
|
|
214
219
|
print('There is still not enough data to continue the regression.')
|
|
215
220
|
print(
|
|
@@ -222,14 +227,16 @@ class RobustEstimation:
|
|
|
222
227
|
if not self.processing_mode == "MT Only":
|
|
223
228
|
if self.channel == 'hz':
|
|
224
229
|
self.filtered_dataset['selection_array_hz'] = (
|
|
225
|
-
self.filtered_dataset['hz_selection_coh'] * self.filtered_dataset[
|
|
230
|
+
self.filtered_dataset['hz_selection_coh'] * self.filtered_dataset[
|
|
231
|
+
'alpha_h_selection'])
|
|
226
232
|
# Avoid crashing due to insufficient data
|
|
227
233
|
if np.sum(self.filtered_dataset['selection_array_hz']) < 10:
|
|
228
234
|
print('There is not enough data to continue the regression.')
|
|
229
235
|
print(
|
|
230
236
|
f'Trying to remove polarization direction (hz) related data rejections for ft:{self.ft} Hz '
|
|
231
237
|
f'if applied.')
|
|
232
|
-
self.filtered_dataset['selection_array_hz'] = self.filtered_dataset[
|
|
238
|
+
self.filtered_dataset['selection_array_hz'] = self.filtered_dataset[
|
|
239
|
+
'hz_selection_coh'].copy()
|
|
233
240
|
if np.sum(self.filtered_dataset['selection_array_hz']) <= 10:
|
|
234
241
|
print('There is still not enough data to continue the regression.')
|
|
235
242
|
print(
|
|
@@ -347,7 +354,8 @@ class RobustEstimation:
|
|
|
347
354
|
self.get_huber_weights(km)
|
|
348
355
|
else:
|
|
349
356
|
# Number of windows in which weight = 1
|
|
350
|
-
lc = max(np.sum(self.huber_weights == 1),
|
|
357
|
+
lc = max(np.sum(self.huber_weights == 1),
|
|
358
|
+
1) # Keeping it min = 1 to avoid division by zero
|
|
351
359
|
# Weighted sum of squared residuals
|
|
352
360
|
sum_squared = (n_time_windows / (lc ** 2)) * (
|
|
353
361
|
np.sum(self.huber_weights * (self.residuals ** 2)))
|
|
@@ -398,7 +406,7 @@ class RobustEstimation:
|
|
|
398
406
|
z_deno)
|
|
399
407
|
|
|
400
408
|
if self.channel == 'ex' or self.channel == 'ey':
|
|
401
|
-
#
|
|
409
|
+
# Fix EDI convention
|
|
402
410
|
self.z1_robust_huber = z1 * -1
|
|
403
411
|
self.z2_robust_huber = z2 * -1
|
|
404
412
|
else:
|
|
@@ -8,10 +8,12 @@ import numpy as np
|
|
|
8
8
|
from scipy import signal
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def notch_filter_sos(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
def notch_filter_sos(
|
|
12
|
+
time_series: np.ndarray,
|
|
13
|
+
sampling_frequency: float,
|
|
14
|
+
notch_frequency: float,
|
|
15
|
+
harmonics: Optional[int] = None
|
|
16
|
+
) -> np.ndarray:
|
|
15
17
|
"""
|
|
16
18
|
SOS filter for notch filtering. Filters out the requested notch frequency and harmonics.
|
|
17
19
|
|
|
@@ -35,11 +37,21 @@ def notch_filter_sos(time_series: np.ndarray,
|
|
|
35
37
|
if harmonics > int(14000 / notch_frequency):
|
|
36
38
|
harmonics = int(14000 / notch_frequency)
|
|
37
39
|
print('No. of harmonics: ' + str(harmonics))
|
|
38
|
-
sos = signal.butter(4, [notch_frequency - 5, notch_frequency + 5], btype='bandstop',
|
|
40
|
+
sos = signal.butter(4, [notch_frequency - 5, notch_frequency + 5], btype='bandstop',
|
|
41
|
+
fs=sampling_frequency,
|
|
39
42
|
output='sos')
|
|
40
43
|
for n in range(2, harmonics + 1):
|
|
41
44
|
f0 = n * notch_frequency
|
|
42
|
-
|
|
45
|
+
high = f0 + 5
|
|
46
|
+
nyq = sampling_frequency / 2
|
|
47
|
+
|
|
48
|
+
# stop once beyond nyq
|
|
49
|
+
if high >= nyq:
|
|
50
|
+
print(f'Could not apply notch filter at frequency {f0} Hz.\n')
|
|
51
|
+
break
|
|
52
|
+
|
|
53
|
+
sos_new = signal.butter(4, [f0 - 5, f0 + 5], btype='bandstop', fs=sampling_frequency,
|
|
54
|
+
output='sos')
|
|
43
55
|
sos = np.concatenate((sos, sos_new), axis=0)
|
|
44
56
|
time_series = signal.sosfilt(sos, time_series, axis=0)
|
|
45
57
|
else:
|
|
@@ -48,7 +60,11 @@ def notch_filter_sos(time_series: np.ndarray,
|
|
|
48
60
|
return time_series
|
|
49
61
|
|
|
50
62
|
|
|
51
|
-
def do_fft(
|
|
63
|
+
def do_fft(
|
|
64
|
+
ts: np.ndarray,
|
|
65
|
+
fs: float,
|
|
66
|
+
fft_length: int
|
|
67
|
+
) -> tuple:
|
|
52
68
|
"""
|
|
53
69
|
Function to perform FFT.
|
|
54
70
|
|