Skip to content

Commit 2c2155b

Browse files
committed
update mt with impedance units
1 parent 46096df commit 2c2155b

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

mtpy/core/mt_dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def to_z_object(self, units="mt"):
755755
self.dataframe.station == self.station, f"z_{comp}_model_error"
756756
]
757757

758-
z_object = Z(z, z_err, self.frequency, z_model_err, unit=units)
758+
z_object = Z(z, z_err, self.frequency, z_model_err, units=units)
759759

760760
if (z == 0).all():
761761
for comp in ["xx", "xy", "yx", "yy"]:

mtpy/core/transfer_function/base.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,16 @@ def __eq__(self, other):
102102

103103
# loop over variables to make sure they are all the same.
104104
for var in list(self._dataset.data_vars):
105-
try:
106-
if not (self._dataset[var] == other._dataset[var]).all().data:
105+
has_tf_str = f"_has_{var.replace('transfer_function', 'tf')}"
106+
if getattr(self, has_tf_str):
107+
if getattr(other, has_tf_str):
108+
if not np.allclose(
109+
self._dataset[var].data, other._dataset[var].data
110+
):
111+
self.logger.info(f"Transfer functions {var} not equal")
112+
return False
113+
else:
107114
return False
108-
except TypeError:
109-
continue
110115
return True
111116

112117
def __deepcopy__(self, memo):

tests/core/test_mt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,11 @@ def test_impedance_in_ohms(self):
558558
z_obj = self.m1.Z
559559
z_obj.units = "ohm"
560560

561-
self.assertEqual(z_obj, self.mt_df.to_z_object())
561+
self.assertEqual(z_obj, self.mt_df.to_z_object(units="ohm"))
562562

563563
def test_impedance_not_equal(self):
564564

565-
self.assertNotEqual(self.m1.Z, self.mt_df.to_z_object())
565+
self.assertNotEqual(self.m1.Z, self.mt_df.to_z_object(units="mt"))
566566

567567

568568
# =============================================================================

0 commit comments

Comments
 (0)