MTgeophysics / mtpy

Python toolbox for standard Magnetotelluric (MT) data analysis
GNU General Public License v3.0
144 stars 66 forks source link

Issue in ModEM plot rms #129

Open kashkoulimohammad opened 3 years ago

kashkoulimohammad commented 3 years ago

Dear all,

I tried to use the ModEM_PlotRMS for the example data. Also, I tried other data. In two cases the same error happened:

Traceback (most recent call last):
  File "C:\mtpywin\mtpy\examples\scripts\ModEM_PlotRMS.py", line 54, in <module>
    plot_elements='both'
  File "C:\mtpywin\mtpy\mtpy\modeling\modem\plot_rms_maps.py", line 231, in __init__
    self.plot()
  File "C:\mtpywin\mtpy\mtpy\modeling\modem\plot_rms_maps.py", line 390, in plot
    rms, filt = self._calculate_rms(p_dict)
  File "C:\mtpywin\mtpy\mtpy\modeling\modem\plot_rms_maps.py", line 247, in _calculate_rms
    rms = self.residual.rms_array['rms_z_component_period'][:, self.period_index, ii, jj]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

My script is:

import os
os.chdir(r'C:\mtpywin\mtpy')
import os.path as op
import numpy as np
from mtpy.modeling.modem import PlotRMSMaps
wd = r'C:\mtpywin\mtpy\examples\model_files\ModEM_2'
savepath = r'C:\tmp'
filestem = op.join(wd,'Modular_MPI_NLCG_004')
resid_fn=op.join(wd,filestem + '.res')
probj = PlotRMSMaps(resid_fn,
                    # period=100.,  # can specify a period in seconds
                    period_index='all',
                    rms_cmap='jet', # choose matplotlib colormap or set to None
                    rms_max=5,
                    plot_elements='both'
                    # bimg=r'C:\path\to\a\background_image.tif'
                    )
probj.save_figure(save_path=savepath,
                  save_fig_dpi = 400 # change to your preferred figure resolution
                  )
alkirkby commented 3 years ago

I have pushed a fix and it now works for me, could you please test and let me know?

kashkoulimohammad commented 3 years ago

Hi Alison,

Thank you for your replying. The ModEM_PlotRMS script worked correctly. But ModEM_PlotRMS_by_site script did not work correctly. I think converting from"long, lag" to "easting, northing" is not correct. See these outputs: rms_zxy rms_by_site

123yangzhen123 commented 10 months ago

Hi mohammad i use the code with my edi data, i also find the same question: ModEM_PlotRMS_by_site script did not work correctly.