Skip to content

Commit f080792

Browse files
authored
Merge pull request #40 from ajithabhks/allow_more_freqencies
Allow more freqencies
2 parents 8633a7b + 4973049 commit f080792

File tree

5 files changed

+25
-30
lines changed

5 files changed

+25
-30
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
[![PyPI version](https://img.shields.io/pypi/v/sigmt)](https://pypi.org/project/sigmt/)
22

3-
Note: I’m currently in the process of updating module and variable names throughout the codebase to make them more descriptive and easier to understand.
4-
5-
These updates may temporarily affect stability or introduce minor breaking changes.
6-
7-
If you rely on a stable version for processing or production use, please use the latest release available on PyPI (`pip install sigmt`) or ([GitHub v2.0.4](https://github.com/ajithabhks/sigmt/tree/v2.0.4)) until the refactoring is complete.
8-
9-
Sorry for any inconvenience.
10-
11-
---
12-
133
# SigMT: An open-source python package for magnetotelluric data processing
144

155
SigMT is a python package designed for the processing of the raw magnetotelluric (MT) data to obtain the MT impedance and tipper estimates. It works in an automated way, so that manual time series inspection and editing are not required. Mahalanobis based data selection tool is implemented in the package to avoid the manual editing of time series. The final impedance estimation is done using the robust estimation method. Different data selection tools such as coherency threshold, polarization direction are included in this package.

sigmt/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
Returns version of the package
33
"""
4-
__version__ = "2.0.4"
4+
__version__ = "2.0.5"

sigmt/core/band_averaging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def __init__(self,
217217
self.detrend_time_series()
218218
self.perform_fft()
219219
if calibrate_magnetic:
220-
self.calibrate_mag()
220+
self.calibrate_magnetic()
221221
del self.calibration_data_magnetic
222222
del self.time_series
223223
gc.collect()
@@ -250,7 +250,7 @@ def calibrate_electric(self) -> None:
250250
dipole_ew = abs(self.calibration_data_electric['ey']['y1']) + abs(self.calibration_data_electric['ey']['y2'])
251251
self.time_series['ey'] = self.time_series['ey'] / (1 * dipole_ew / 1000)
252252

253-
def calibrate_mag(self) -> None:
253+
def calibrate_magnetic(self) -> None:
254254
"""
255255
Calibrates the magnetic field channels.
256256

sigmt/core/plots.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import xarray as xr
88
from matplotlib import pyplot as plt
99

10+
matplotlib.use("Qt5Agg")
1011
plt.rcParams['figure.max_open_warning'] = 50
1112

1213

@@ -55,8 +56,8 @@ def plot_mt_app_res(dataset: xr.Dataset, procinfo: dict) -> None:
5556
plt.errorbar(ftlist, rho_yx, yerr=err_ryx, ecolor='b', fmt="none")
5657
plt.xscale('log')
5758
plt.yscale('log')
58-
if max(ftlist) < 15000 and min(ftlist) > 0.001:
59-
plt.xlim((15000, 0.001))
59+
if max(ftlist) < 15000 and min(ftlist) > 0.0001:
60+
plt.xlim((15000, 0.0001))
6061
else:
6162
plt.xlim((max(ftlist) + 10, min(ftlist) - 10))
6263
if min(ftlist) > 0.001:
@@ -75,8 +76,8 @@ def plot_mt_app_res(dataset: xr.Dataset, procinfo: dict) -> None:
7576
plt.errorbar(ftlist, phase_xy, yerr=err_pxy, ecolor='r', fmt="none")
7677
plt.errorbar(ftlist, phase_yx, yerr=err_pyx, ecolor='b', fmt="none")
7778
plt.xscale('log')
78-
if max(ftlist) < 15000 and min(ftlist) > 0.001:
79-
plt.xlim((15000, 0.001))
79+
if max(ftlist) < 15000 and min(ftlist) > 0.0001:
80+
plt.xlim((15000, 0.0001))
8081
else:
8182
plt.xlim((max(ftlist) + 10, min(ftlist) - 10))
8283
if min(ftlist) > 0.001:
@@ -125,8 +126,8 @@ def plot_tipper(dataset: xr.Dataset, procinfo: dict) -> None:
125126
plt.scatter(ftlist, ty_a, c='b', s=10, label='Ty')
126127
plt.ylim(0, 1)
127128
plt.xscale('log')
128-
if max(ftlist) < 15000 and min(ftlist) > 0.001:
129-
plt.xlim((15000, 0.001))
129+
if max(ftlist) < 15000 and min(ftlist) > 0.0001:
130+
plt.xlim((15000, 0.0001))
130131
else:
131132
plt.xlim((max(ftlist) + 10, min(ftlist) - 10))
132133
if min(ftlist) > 0.001:
@@ -139,8 +140,8 @@ def plot_tipper(dataset: xr.Dataset, procinfo: dict) -> None:
139140
plt.scatter(ftlist, tx_p, c='r', s=10)
140141
plt.scatter(ftlist, ty_p, c='b', s=10)
141142
plt.xscale('log')
142-
if max(ftlist) < 15000 and min(ftlist) > 0.001:
143-
plt.xlim((15000, 0.001))
143+
if max(ftlist) < 15000 and min(ftlist) > 0.0001:
144+
plt.xlim((15000, 0.0001))
144145
else:
145146
plt.xlim((max(ftlist) + 10, min(ftlist) - 10))
146147
if min(ftlist) > 0.001:
@@ -175,7 +176,7 @@ def plot_coherency(dataset: xr.Dataset, procinfo: dict) -> None:
175176
if 'coh_hz' in dataset:
176177
plt.scatter(frequency_values, dataset['coh_hz'].values, c='g', label='Hz')
177178
plt.xscale('log')
178-
plt.xlim((10000, 0.001))
179+
plt.xlim((10000, 0.0001))
179180
plt.ylim(0, 1)
180181
# generate tick values for y
181182
y_ticks = np.arange(0.1, 1.1, 0.1)

sigmt/utils/utils.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,27 @@ def get_target_frequency_list(sampling_frequency: float,
187187

188188
fr = parzen_window_radius * frequency_table # bandwidth of parzen window - oneside from ft
189189
total_bandwidth = fr * 2 # bandwidth of parzen window - two side from ft
190-
# nof spectra in parzen window for each ft
190+
191+
# No. of spectral bins in the parzen window for each ft
191192
dof = total_bandwidth / (sampling_frequency / fft_length)
192193

193194
maximum = sampling_frequency / 2
195+
196+
# Hardcoding maximum frequency to 15000
194197
if maximum > 15000:
195198
maximum = 15000
196199
f_max = max(frequency_table[frequency_table < maximum]) # ft_max, following nyquist
197-
198200
f_max_index = np.where(frequency_table == f_max)[0][0] # index in ftable
199-
min_required = dof[f_max_index] * .01 # min dof required for ft_min
200201

201-
dof_min = min(dof[dof > min_required]) # finding in dof
202-
dof_min_index = np.where(dof == dof_min)[0][0] # finding index
202+
# Finding minimum frequency bin used for a parzen window used.
203+
parzen_lower_extend = frequency_table - (frequency_table * parzen_window_radius)
204+
# Find the index of the target frequency whose lower Parzen window boundary is
205+
# closest to the frequency resolution
206+
f_min_index = np.argmin(abs(parzen_lower_extend - (sampling_frequency / fft_length)))
203207

204-
while dof[dof_min_index] < 10: # Making sure, atleast 10 spectral lines are averaged
205-
dof_min_index = dof_min_index - 1
208+
# Looks for minimum dof=10
209+
f_min_index = np.min([f_min_index, np.argmin(abs(dof-10))])
206210

207-
ft_list = frequency_table[f_max_index:dof_min_index + 1] # Making ft_list
211+
ft_list = frequency_table[f_max_index:f_min_index] # Making ft_list
208212

209213
return ft_list

0 commit comments

Comments
 (0)