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
30 stars 9 forks source link

adding ability to just plot tipper #35

Closed kujaku11 closed 3 months ago

kujaku11 commented 4 months ago

Fix Issue #34 for plotting when only tipper data are available as the transfer function

kujaku11 commented 4 months ago

@kkappler This PR will address your tipper only data. I fixed plot_mt_response (I think), when you have time check it out. Think about other ways you might want to plot tipper if you don't like the induction vectors.

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 65.54622% with 41 lines in your changes missing coverage. Please review.

Project coverage is 27.73%. Comparing base (bc74ec8) to head (cc73324).

Files Patch % Lines
mtpy/imaging/plot_mt_response.py 73.26% 27 Missing :warning:
mtpy/utils/filehandling.py 22.22% 7 Missing :warning:
mtpy/modeling/mesh_tools.py 16.66% 5 Missing :warning:
mtpy/modeling/modem/data.py 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## updates #35 +/- ## =========================================== + Coverage 27.63% 27.73% +0.09% =========================================== Files 130 130 Lines 21795 21821 +26 =========================================== + Hits 6024 6052 +28 + Misses 15771 15769 -2 ``` | [Flag](https://app.codecov.io/gh/MTgeophysics/mtpy-v2/pull/35/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MTgeophysics) | Coverage Δ | | |---|---|---| | [tests](https://app.codecov.io/gh/MTgeophysics/mtpy-v2/pull/35/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MTgeophysics) | `27.73% <65.54%> (+0.09%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MTgeophysics#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

kkappler commented 4 months ago

plot_mt_response now creates a plot (before it did not at all) so there is progress, but the plotting does not complete. From the Traceback, it looks like self._plot_pt() is called and that is where error occurs.
TypeError: 'NoneType' object is not subscriptable

Here is the full traceback

File [~/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py:114](http://localhost:8888/lab/tree/software/dias/scratch/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py#line=113), in PlotMTResponse.__init__(self, z_object, t_object, pt_obj, station, **kwargs)
    112 # plot on initializing
    113 if self.show_plot:
--> 114     self.plot()

File [~/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py:502](http://localhost:8888/lab/tree/software/dias/scratch/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py#line=501), in PlotMTResponse.plot(self)
    500 self._plot_phase(self.axp, self.period, self.Z, mode="od")
    501 self._plot_tipper()
--> 502 self._plot_pt()
    504 # ===Plot the xx, yy components if desired==============================
    505 if self.plot_num == 2:

File [~/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py:427](http://localhost:8888/lab/tree/software/dias/scratch/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/plot_mt_response.py#line=426), in PlotMTResponse._plot_pt(self)
    424 color_array = self.get_pt_color_array(self.pt)
    426 # -------------plot ellipses-----------------------------------
--> 427 self.cbax, self.cbpt, = plot_pt_lateral(
    428     self.axpt,
    429     self.pt,
    430     color_array,
    431     self.ellipse_properties,
    432     fig=self.fig,
    433 )
    435 # ----set axes properties-----------------------------------------------
    436 # --> set tick labels and limits
    437 self.axpt.set_xlim(
    438     np.log10(self.x_limits[0]), np.log10(self.x_limits[1])
    439 )

File [~/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/mtplot_tools/plotters.py:238](http://localhost:8888/lab/tree/software/dias/scratch/anaconda3/envs/mt_env/lib/python3.10/site-packages/mtpy/imaging/mtplot_tools/plotters.py#line=237), in plot_pt_lateral(ax, pt_obj, color_array, ellipse_properties, y_shift, fig, edge_color, n_index)
    235 # -------------plot ellipses-----------------------------------
    236 for ii, ff in enumerate(1.0 [/](http://localhost:8888/) pt_obj.frequency):
    237     # make sure the ellipses will be visable
--> 238     if pt_obj.phimax[ii] == 0:
    239         continue
    240     eheight = (
    241         pt_obj.phimin[ii] [/](http://localhost:8888/) pt_obj.phimax[ii] * ellipse_properties["size"]
    242     )

TypeError: 'NoneType' object is not subscriptable