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
33 stars 11 forks source link

Phase tensor map #60

Open MohammadHakimRezayee opened 1 month ago

MohammadHakimRezayee commented 1 month ago

I tried to plot the phase tensor map. However, I could plot for one station but not for all station like a grid.

  1. how to create an mth5 file from list of edifies?
  2. When I try to plot the phase tensor, encounter the following error as this is the script:

ptmap = PlotPhaseTensorMaps(mt_data = edi_list, plot_freq = plot_freq , # frequency to plot fig_size = (4,3), # x, y dimensions of figure xpad = 0.02, ypad = 0.02, # pad around stations plot_tipper = 'yr', # 'y' + 'r' and/or 'i' to plot

real and/or imaginary

                        edgecolor='k', # a matplotlib colour or None for no borders
                        lw=0.5, # linewidth for the ellipses
                        minorticks_on=False, # whether or not to turn on minor ticks
                        ellipse_colorby='skew', # 'phimin', 'phimax', or 'skew'
                        ellipse_range = [-12,12,2], # [min,max,step]
                        ellipse_size=0.01, # scaling factor for the ellipses
                        arrow_size=0.1,
                        arrow_head_width=0.002, # scaling for arrows (head width)
                        arrow_head_length=0.002, # scaling for arrows (head length)
                        ellipse_cmap='bwr', # matplotlib colormap
                        station_dict={'id':(5,7)} ,
                        cb_dict = {'position':
                                   [1.05,0.2,0.02,0.3]}, # colorbar position [x,y,dx,dy]
                        font_size=5
                       )

save the plot

ptmap.save_plot(os.path.join(savepath,image_fn))

File ~\AppData\Local\anaconda3\Lib\site-packages\mtpy\imaging\plot_phase_tensor_maps.py:109, in PlotPhaseTensorMaps.init(self, mt_data, **kwargs) 107 # --> plot if desired ------------------------ 108 if self.show_plot: --> 109 self.plot()

File ~\AppData\Local\anaconda3\Lib\site-packages\mtpy\imaging\plot_phase_tensor_maps.py:727, in PlotPhaseTensorMaps.plot(self, fig, save_path, show, raster_file, raster_kwargs) 725 self.plot_xarr = np.zeros(len(self.mt_data)) 726 self.plot_yarr = np.zeros(len(self.mt_data)) --> 727 for index, tf in enumerate(self.mt_data.values()): 728 if self.pt_type == "ellipses": 729 plot_x, plot_y = self._get_patch_ellipse(tf)

AttributeError: 'list' object has no attribute 'values'

wieweiwei commented 3 days ago

The values attribute is a property inherent to the dictionary class. When the method is designed to accept an mt_data parameter, you have provided it with edi_list. Upon inspecting the method's implementation, it becomes evident that this is not the intended input. The method requires a dictionary that contains multiple MT (Magnetotelluric) objects. However, what you have passed is a list of full paths to EDI files. This discrepancy between the expected input and the provided argument may lead to an error or unexpected behavior in the method's execution. 11