@@ -986,7 +986,8 @@ def to_dataframe(
986986 cols : list of str, optional
987987 Column names to include, by default None
988988 impedance_units : str, optional
989- Impedance units, "mt" [mV/km/nT] or "ohm" [Ohms], by default "mt"
989+ Impedance output units in the dataframe,
990+ "mt" [mV/km/nT] or "ohm" [Ohms], by default "mt"
990991
991992 Returns
992993 -------
@@ -1017,8 +1018,10 @@ def to_dataframe(
10171018 mt_df .dataframe .loc [:, "period" ] = self .period
10181019 if self .has_impedance ():
10191020 z_object = self .Z
1020- z_object .units = impedance_units
1021- mt_df .from_z_object (z_object )
1021+ # Keep Z internal storage in mt units while exposing dataframe values
1022+ # in requested output units.
1023+ z_object .output_units = impedance_units
1024+ mt_df .from_z_object (z_object , units = impedance_units )
10221025 if self .has_tipper ():
10231026 mt_df .from_t_object (self .Tipper )
10241027
@@ -1035,7 +1038,8 @@ def from_dataframe(
10351038 mt_df : MTDataFrame or DataFrame-like
10361039 Dataframe containing MT data for a single station
10371040 impedance_units : str, optional
1038- Impedance units, "mt" [mV/km/nT] or "ohm" [Ohms], by default "mt"
1041+ Impedance units represented in the dataframe,
1042+ "mt" [mV/km/nT] or "ohm" [Ohms], by default "mt"
10391043
10401044 Raises
10411045 ------
@@ -1077,8 +1081,9 @@ def from_dataframe(
10771081
10781082 self .tf_id = self .station
10791083
1080- z_obj = mt_df .to_z_object ()
1081- z_obj .units = impedance_units
1084+ # Construct with dataframe units so incoming arrays are interpreted
1085+ # correctly, and keep output units aligned with MT impedance units.
1086+ z_obj = mt_df .to_z_object (units = impedance_units )
10821087 self .Z = z_obj
10831088 self .Tipper = mt_df .to_t_object ()
10841089
@@ -1542,7 +1547,9 @@ def to_occam1d(
15421547
15431548 return occam_data
15441549
1545- def to_simpeg_1d (self , mode : str = "det" , ** kwargs : Any ) -> Simpeg1D :
1550+ def to_simpeg_1d (
1551+ self , mode : str = "det" , resistivity_error = 10 , phase_error = 2.5 , ** kwargs : Any
1552+ ) -> Simpeg1D :
15461553 """
15471554 Run a 1D inversion using SimPEG.
15481555
@@ -1577,7 +1584,13 @@ def to_simpeg_1d(self, mode: str = "det", **kwargs: Any) -> Simpeg1D:
15771584 if not self .Z ._has_tf_model_error ():
15781585 self .compute_model_z_errors ()
15791586 self .logger .info ("Using default errors for impedance" )
1580- simpeg_1d = Simpeg1D (self .to_dataframe (), mode = mode , ** kwargs )
1587+ simpeg_1d = Simpeg1D (
1588+ self .to_dataframe (impedance_units = "mt" ),
1589+ mode = mode ,
1590+ resistivity_error = resistivity_error ,
1591+ phase_error = phase_error ,
1592+ ** kwargs ,
1593+ )
15811594 simpeg_1d .run_fixed_layer_inversion (** kwargs )
15821595 simpeg_1d .plot_model_fitting (fig_num = 1 )
15831596 simpeg_1d .plot_response (fig_num = 2 , ** kwargs )
0 commit comments