MTgeophysics / mtpy-v2

Tools to work with magnetotelluric transfer functions, based on MTH5 and mt-metadata. This is an update to mtpy.
https://mtpy-v2.readthedocs.io/en/latest/index.html
MIT License
22 stars 7 forks source link

plot pseudo-section of phasetensor with tipper #14

Open kashkoulimohammad opened 5 months ago

kashkoulimohammad commented 5 months ago

Hi, I am tiring to plot pseudo-section of phasetensor with tipper but I faced with this error:

C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\scipy\stats\_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide
  slope = ssxym / ssxm
C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\scipy\stats\_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt
  t = r * np.sqrt(df / ((1.0 - r + TINY)*(1.0 + r + TINY)))
C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\scipy\stats\_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide
  slope_stderr = np.sqrt((1 - r**2) * ssym / ssxm / df)
Traceback (most recent call last):
  File "C:\Users\Mohammad\Desktop\MTpy_V2\2.py", line 11, in <module>
    plot_pt_pseudosection = dgh_mt_data.plot_phase_tensor_pseudosection(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\mtpy\core\mt_data.py", line 1116, in plot_phase_tensor_pseudosection
    return PlotPhaseTensorPseudoSection(mt_data=self, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\mtpy\imaging\plot_phase_tensor_pseudosection.py", line 101, in __init__
    self.plot()
  File "C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\mtpy\imaging\plot_phase_tensor_pseudosection.py", line 340, in plot
    self._get_profile_line()
  File "C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\mtpy\imaging\mtplot_tools\base.py", line 655, in _get_profile_line
    mt_obj.project_onto_profile_line(
  File "C:\Users\Mohammad\.conda\envs\MTpy-v2\Lib\site-packages\mtpy\core\mt_location.py", line 452, in project_onto_profile_line
    raise ValueError(
ValueError: utm_crs is None, cannot project onto profile line.

my script is:

from mtpy import MTCollection
mc = MTCollection()
mc.open_collection(r'C:\Users\Mohammad\Desktop\work\nasrabad_data\nasrabad_data\15\15.h5')
#plot_strike_all = mc.plot_strike()
mc.utm_crs = 32640
mc.working_dataframe = mc.master_dataframe[mc.master_dataframe.station.str.startswith("15_010-0000")]
dgh_mt_data = mc.to_mt_data()
plot_pt_pseudosection = dgh_mt_data.plot_phase_tensor_pseudosection( 
    plot_tipper="yri", 
    profile_reverse=False,
    y_limits=(10**2, 1)
)
kujaku11 commented 4 months ago

@kashkoulimohammad

Looks like you found a bug.

I added key word arguments to to_mt_data in PR #17

Your code is close, just need to set the utm_crs in the MTData object instead of the MTCollection object:

from mtpy import MTCollection
mc = MTCollection()
mc.open_collection(r'C:\Users\Mohammad\Desktop\work\nasrabad_data\nasrabad_data\15\15.h5')

mc.working_dataframe = mc.master_dataframe[mc.master_dataframe.station.str.startswith("15_010-0000")]

# here is the new change. You can set the `utm_crs` through `to_mt_data` now.
dgh_mt_data = mc.to_mt_data(utm_crs=32640)
plot_pt_pseudosection = dgh_mt_data.plot_phase_tensor_pseudosection( 
    plot_tipper="yri", 
    profile_reverse=False,
    y_limits=(10**2, 1)
)
kashkoulimohammad commented 4 months ago

Thanks @kujaku11 It does not work.

Traceback (most recent call last):
  File "C:\Users\Mohammad\Desktop\MTpy_V2\2_1.py", line 8, in <module>
    dgh_mt_data = mc.to_mt_data(utm_crs=32640)
TypeError: to_mt_data() got an unexpected keyword argument 'utm_crs'
kujaku11 commented 4 months ago

@kashkoulimohammad Try to reinstall mtpy-v2 from git.