Issue in ModEM plot rms
kashkoulimohammad opened this issue · 3 comments
kashkoulimohammad commented
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
I have pushed a fix and it now works for me, could you please test and let me know?
kashkoulimohammad commented
123yangzhen123 commented
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.