MTgeophysics/mtpy

Unable to generate Phase Tensor Plot

roshanmanjitsingh opened this issue · 24 comments

I have an MT data file where the entries are in column format.
I have converted it into EDI format.
For some frequencies, I do have only the tipper data and not the impedance data
and vice versa.
In the EDI file, I am adding "0.000000E+0" for the component whose value is missing.
For example, corresponding to the frequency "2.441406E-05" I don't have the Z information so in the EDI file, I am adding "0.000000E+0" for all the Z components whereas for tipper I am giving the measured value.

In such cases, I am unable to generate the phase tensor plots for the respective sites.

Hi Roshan, @roshanmanjitsingh

Thank you for your enquiry. I will pass the issue to @alkirkby to have a look.

Hi @roshanmanjitsingh, I can't seem to reproduce your error. Are you adding 0.000000E+0 to all of the Z fields?
You could try using a no-data-value of 1.000000e+32 and setting EMPTY=1.0e+32 in the header. Alternatively, if you could provide your code and edi files I can look into it for you.

I can't see the files. Can you zip them up and email them to me?

OK it's not a problem with the edi files it's the script. If you run:

from mtpy.core import mt

edi_file = 'path/to/edifile'

mt_obj = mt.MT(edi_file)
pt_obj = mt_obj.plot_mt_response()

It should work. I get a plot like this:
image

quite possibly, it is definitely worth pulling the latest version, let me know how you go.

Following those instructions should get you the latest version. If you navigate to the path where mtpy is installed (e.g. /c/mtpywin/mtpy), make sure the develop branch is checked out, and run git pull, you should have the latest version.
If you used pip install mtpy that version is out of date.

Hmm
It's really hard to debug as I can't reproduce the error, it works fine for me. How are you running the script (e.g. jupyter notebook, spyder, or commandline)? and what version of matplotlib are you using?
I have matplotlib=3.2.1 (you can get a list of installed packages and versions by running pip freeze)
and I am running it in spyder

I'm running out of suggestions I'm sorry, @zhang01GA do you have any ideas?
The only other things I can suggest are:

  • make sure you have the mtpy environment active in Anaconda
  • if that doesn't help try running it as a script directly in a command prompt (ensuring the mtpy environment is active)

@alkirkby @roshanmanjitsingh , we have a new developer @snazzybloke (Ante Bilic) who can start looking into this problem. I will provide assistance as required

Hi @roshanmanjitsingh,
I would need to know your whole environment to reproduce and investigate the issue.
Would you be able share your package versions?
(try perhaps pip freeze > requriements.txt)

Hi @roshanmanjitsingh,

I've run into the same errors as you by running Alison's script shown above.
The issue was matplotlib. My version was 3.4.1 and after replacing it with 3.2.1:
pip install matplotlib==3.2.1
the script reproduces Alison's plots without a hiccup.

So, as a quick fix I suggest that you set up the virtual environment for mtpy to use the 3.2.1 matplotlib ver.
Clearly, a better solution is needed that does not crash with newer versions.

Ante

@roshanmanjitsingh, further to my comment above, even with the newer matplotlib version you should still be able to produce the plots simply by running your script from the command line, e.g.:
> python script_name.py

The error I see is between IPython and new matplotlib, which makes it impossible for either spyder or jupyter to render the plot object (since they both rely on IPython directly and/or via ipykernel).