Skip to content

Commit 7ec5dee

Browse files
committed
Update mt.py
1 parent 8353993 commit 7ec5dee

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

mtpy/core/mt.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def __init__(self, fn=None, impedance_units="mt", **kwargs):
110110

111111
self.save_dir = Path.cwd()
112112

113-
self._coordinate_reference_frame_options = (
114-
COORDINATE_REFERENCE_FRAME_OPTIONS
115-
)
113+
self._coordinate_reference_frame_options = COORDINATE_REFERENCE_FRAME_OPTIONS
116114

117115
self.coordinate_reference_frame = (
118116
self.station_metadata.transfer_function.sign_convention
@@ -231,9 +229,7 @@ def impedance_units(self, value):
231229
if not isinstance(value, str):
232230
raise TypeError("Units input must be a string.")
233231
if value.lower() not in self._impedance_unit_factors.keys():
234-
raise ValueError(
235-
f"{value} is not an acceptable unit for impedance."
236-
)
232+
raise ValueError(f"{value} is not an acceptable unit for impedance.")
237233

238234
self._impedance_units = value
239235

@@ -612,6 +608,17 @@ def interpolate(
612608
)
613609

614610
new_m = self.clone_empty()
611+
theta_r = 0
612+
if isinstance(self._rotation_angle, (int, float)):
613+
if self._rotation_angle != 0:
614+
theta_r = float(self._rotation_angle)
615+
elif isinstance(self._rotation_angle, np.ndarray):
616+
if self._rotation_angle.mean() != 0:
617+
theta_r = float(self._rotation_angle.mean())
618+
self.logger.warning(
619+
f"Station {self.station}: Using mean rotation angle of {theta_r:.2f} degrees."
620+
)
621+
new_m._rotation_angle = np.repeat(theta_r, len(new_period))
615622
if self.has_impedance():
616623
new_m.Z = self.Z.interpolate(new_period, method=method, **kwargs)
617624
if new_m.has_impedance():
@@ -622,9 +629,7 @@ def interpolate(
622629
"See scipy.interpolate.interp1d for more information."
623630
)
624631
if self.has_tipper():
625-
new_m.Tipper = self.Tipper.interpolate(
626-
new_period, method=method, **kwargs
627-
)
632+
new_m.Tipper = self.Tipper.interpolate(new_period, method=method, **kwargs)
628633
if new_m.has_tipper():
629634
if np.all(np.isnan(new_m.Tipper.tipper)):
630635
self.logger.warning(
@@ -1109,12 +1114,9 @@ def add_white_noise(self, value, inplace=True):
11091114
)
11101115

11111116
if inplace:
1112-
self._transfer_function[
1113-
"transfer_function"
1114-
] = self._transfer_function.transfer_function.real * (
1115-
noise_real
1116-
) + (
1117-
1j * self._transfer_function.transfer_function.imag * noise_imag
1117+
self._transfer_function["transfer_function"] = (
1118+
self._transfer_function.transfer_function.real * (noise_real)
1119+
+ (1j * self._transfer_function.transfer_function.imag * noise_imag)
11181120
)
11191121

11201122
self._transfer_function["transfer_function_error"] = (
@@ -1123,12 +1125,9 @@ def add_white_noise(self, value, inplace=True):
11231125

11241126
else:
11251127
new_mt_obj._transfer_function = self._transfer_function.copy()
1126-
new_mt_obj._transfer_function[
1127-
"transfer_function"
1128-
] = self._transfer_function.transfer_function.real * (
1129-
noise_real
1130-
) + (
1131-
1j * self._transfer_function.transfer_function.imag * noise_imag
1128+
new_mt_obj._transfer_function["transfer_function"] = (
1129+
self._transfer_function.transfer_function.real * (noise_real)
1130+
+ (1j * self._transfer_function.transfer_function.imag * noise_imag)
11321131
)
11331132

11341133
self._transfer_function["transfer_function_error"] = (

0 commit comments

Comments
 (0)