MTgeophysics / mtpy

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

mtplot.plot_strike #68

Closed ralfschaa closed 5 years ago

ralfschaa commented 5 years ago

Dear all,

the plot strike function seems broken (at several points):

+near line 315: zinv = Zinvariants(mt.Z)

--> 'mt' contains '_Z' but not 'Z' Fix: zinv = Zinvariants(mt._Z)

+near line 340: pt = mt.pt az = 90 - pt.azimuth az_err = pt.azimuth_err

--> no 'pt' in 'mt' Fix: pt = mt.get_PhaseTensor() --> pt.azimuth is an array with azimuth in 1st column error in 2nd Fix: az = 90 - pt.azimuth[0] Fix: az_err = pt.azimuth[1]

+near line 370 : tip = mt.Tipper --> fails when there is no tipper data

Cheers -Ralf

alkirkby commented 5 years ago

Hi Ralf, it works for me. Could you provide the full code that you're using?

You could also try testing the following example using the example data from the repository and let me know if you still get the error (pb23c has no tipper data, Synth00.edi has tipper).

from mtpy.analysis.zinvariants import Zinvariants from mtpy.core.mt import MT

for mtObj in [MT(r'C:\mtpywin\mtpy\examples\data\edi_files\pb23c.edi'), MT(r'C:\mtpywin\mtpy\examples\data\edi_files_2\Synth00.edi')]: zinv = Zinvariants(mtObj.Z) print zinv

pt = mtObj.pt
az = 90 - pt.azimuth
az_err = pt.azimuth_err

tip= mtObj.Tipper
print tip
ralfschaa commented 5 years ago

Thanks Alison,

my apologies for my incomprehensible question -- I read it again and have no idea what it means :/ I should have provided an example the first time!

Looking at it once more I get the following error when using the "plot_strike" function -- here is a brief example that fails for me: (using the example data without tipper)


import os
import glob
import mtpy.imaging.mtplot as mtplot

# Path to folder with EDI files:
fn_path = 'd:\mtpy-0.1-LightWeightTag\examples\data\edi_files'
# Use glob to save all edi-files in this directory to the list:
fn_list = glob.glob( os.path.join( fn_path,'*.edi'))

# Rose plots:
strike = mtplot.plot_strike(fn_list = fn_list) 

Traceback (most recent call last):

File "D:\mtpy\imaging\mtplot.py", line 158, in plot_strike return plotstrike.PlotStrike(**kwargs) File "D:\mtpy\imaging\plotstrike.py", line 179, in init mt_object_list=mt_object_list) File "D:\mtpy\imaging\mtplottools.py", line 1343, in get_mtlist mt_list = [MTplot(fn=fn) for fn in fn_list] File "D:\mtpy\imaging\mtplottools.py", line 780, in init self._read_edi() File "D:\mtpy\imaging\mtplottools.py", line 820, in _read_edi if edi_obj.Tipper.tipper == None: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()


Looking at line 820 in mtplottools.py, it says:

if edi_obj.Tipper.tipper == None

which does not work with array-valued data and hence the error message.

Changing the code as follows fixes the problem, and a plot is generated.

if edi_obj.Tipper.tipper.all() == None

Cheers -Ralf

alkirkby commented 5 years ago

No worries Ralf, that makes more sense now. However, I am actually working on the PlotStrike function and can't reproduce that error. That line you mention does not exist within my version of mtplottools.py, which suggests you may have an old version of mtpy. I would suggest checking the following:

Cheers, Alison.

ralfschaa commented 5 years ago

Thanks Alison,

I think that's it -- I've downloaded the 'release' version 'v0.1-LightWeightTag', but I just saw it seems to be an older version.

That should resolve the issue I guess.

Cheers -Ralf