Skip to content

Commit 4f0eec1

Browse files
committed
updating z with units
1 parent 8f80b15 commit 4f0eec1

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

mtpy/core/mt.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
from mt_metadata.transfer_functions.core import TF
1616

17-
from mtpy.core import Z, Tipper, COORDINATE_REFERENCE_FRAME_OPTIONS
17+
from mtpy.core import (
18+
Z,
19+
Tipper,
20+
COORDINATE_REFERENCE_FRAME_OPTIONS,
21+
)
1822
from mtpy.core.mt_location import MTLocation
1923
from mtpy.core.mt_dataframe import MTDataFrame
2024
from mtpy.utils.estimate_tf_quality_factor import EMTFStats
@@ -1072,9 +1076,7 @@ def add_white_noise(self, value, inplace=True):
10721076
] = self._transfer_function.transfer_function.real * (
10731077
noise_real
10741078
) + (
1075-
1j
1076-
* self._transfer_function.transfer_function.imag
1077-
* noise_imag
1079+
1j * self._transfer_function.transfer_function.imag * noise_imag
10781080
)
10791081

10801082
self._transfer_function["transfer_function_error"] = (
@@ -1088,9 +1090,7 @@ def add_white_noise(self, value, inplace=True):
10881090
] = self._transfer_function.transfer_function.real * (
10891091
noise_real
10901092
) + (
1091-
1j
1092-
* self._transfer_function.transfer_function.imag
1093-
* noise_imag
1093+
1j * self._transfer_function.transfer_function.imag * noise_imag
10941094
)
10951095

10961096
self._transfer_function["transfer_function_error"] = (

mtpy/core/transfer_function/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import numpy as np
2+
3+
MT_TO_OHM_FACTOR = 1.0 / np.pi * np.sqrt(5.0 / 8.0) * 10**3.5
4+
IMPEDANCE_UNITS = {"mt": 1, "ohm": MT_TO_OHM_FACTOR}
5+
16
from .z import Z
27
from .tipper import Tipper
38
from .pt import PhaseTensor

mtpy/core/transfer_function/z.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import numpy as np
1919

2020
from .base import TFBase
21+
from . import MT_TO_OHM_FACTOR, IMPEDANCE_UNITS
2122
from .pt import PhaseTensor
2223
from .z_analysis import (
2324
ZInvariants,
@@ -58,6 +59,7 @@ def __init__(
5859
z_error=None,
5960
frequency=None,
6061
z_model_error=None,
62+
units="mt",
6163
):
6264
"""Initialize an instance of the Z class.
6365
:param z_model_error:
@@ -70,6 +72,9 @@ def __init__(
7072
:param frequency: Array of frequencyuency values corresponding to impedance
7173
tensor elements, defaults to None.
7274
:type frequency: np.ndarray(n_frequency), optional
75+
:param units: units for the impedance [ "mt" [mV/km/nT] | ohm [Ohms] ]
76+
:type units: str
77+
7378
"""
7479

7580
super().__init__(
@@ -80,9 +85,9 @@ def __init__(
8085
_name="impedance",
8186
)
8287

83-
self._ohm_factor = 1.0 / np.pi * np.sqrt(5.0 / 8.0) * 10**3.5
84-
self._unit_factors = {"mt": 1, "ohm": self._ohm_factor}
85-
self.units = "mt"
88+
self._ohm_factor = MT_TO_OHM_FACTOR
89+
self._unit_factors = IMPEDANCE_UNITS
90+
self.units = units
8691

8792
@property
8893
def units(self):

0 commit comments

Comments
 (0)