Imaging

Module MTPlot

Provides

  1. Different plotting options to represent the MT response.
  2. Ability to create text files of the plots for further analysis
  3. Class object that contains all the important information for an MT station.
Functions Description
plot_mt_response plots resistivity and phase for a single station Options include tipper, strike and skew.
plot_multiple_mt_responses plots multiple stations at once with options of plotting in single figure, all in one figure as subplots or all in one plot for direct comparison.
plot_pt plots the phase tensor ellipses and parameters in one plot including strike angle, minimum and maximum phase, skew angle and ellipticity
plot_pt_pseudosection plots a pseudo section of phase tensor ellipses assuming the stations are along a profile line. Options to plot induction arrows.
plot_mt_map plots phase tensor ellipses in map view for a single frequency. Options to plot induction arrows.
plot_strike plots strike angle estimated from the invariants of the impedance tensor defined by Weaver et al. [2000,2003], strike angle from the phase tensor and option to plot strike estimated from the induction arrows.
plot_residual_pt_maps plots the residual phase tensor between two surveys in map view.
plot_residual_pt_ps plots the residual phase tensor between two surveys as a pseudo section.

All plot function return plot classes where the important properties are made attributes which can be manipulated by the user. All classes have been written with the basic input being edi files. This was assumed to be the standard MT response file, but turns out to be not as widely used as thought. So the inputs can be other arrays and class objects (see MTplot doc string for details). If you have a data file format you can create a class using the objects in mtpy.core to create an input, otherwise contact us and we can try to build something.

A typical use might be loading in all the .edi files in and plotting them in different modes, like apparent resistivity and phase, phase tensor pseudo section and strike angle.

Example:
>>> import mtpy.imaging.mtplot as mtplot
>>> import os
>>> import matplotlib.pyplot as plt
>>> edipath = r"/home/MT/EDIfiles"
>>> #--> create a list of full paths to the edi files
>>> edilst = [os.path.join(edipath,edi) for edi in os.listdir(edipath)
>>> ...        if edi.find('.edi')>0]
>>> #--> plot apparent resisitivity, phase and induction arrows
>>> rpm = mtplot.plot_multiple_mt_responses(fn_lst=edilst, plot_style='1',
>>> ...                                     plot_tipper='yr')
>>> #--> close all the plots after done looking at them
>>> plt.close('all')
>>> #--> plot phase tensor pseudo section with induction arrows
>>> pts = mtplot.plot_pt_pseudosection(fn_lst=edilst,
>>> ...                                plot_tipper='yr')
>>> #--> write out the phase tensor parameter values to files
>>> pts.export_pt_params_to_file()
>>> #--> change coloring scheme to color by skew and a segmented colormap
>>> pts.ellipse_colorby = 'skew_seg'
>>> pts.ellipse_cmap = 'mt_seg_bl2wh2rd'
>>> pts.ellipse_range = (-9, 9, 3)
>>> pts.redraw_plot()
Authors:

Lars Krieger, Jared Peacock, and Kent Invariarty

Version:

0.0.1 of 2013

Plots the resistivity and phase for different modes and components

Created on Thu May 30 16:54:08 2013

@author: jpeacock-pr

class mtpy.imaging.plotresponse.PlotResponse(**kwargs)[source]

Plots Resistivity and phase for the different modes of the MT response. At the moment is supports the input of an .edi file. Other formats that will be supported are the impedance tensor and errors with an array of periods and .j format.

The normal use is to input an .edi file, however it would seem that not everyone uses this format, so you can input the data and put it into arrays or objects like class mtpy.core.z.Z. Or if the data is in resistivity and phase format they can be input as arrays or a class mtpy.imaging.mtplot.ResPhase. Or you can put it into a class mtpy.imaging.mtplot.MTplot.

The plot places the apparent resistivity in log scale in the top panel(s), depending on the plot_num. The phase is below this, note that 180 degrees has been added to the yx phase so the xy and yx phases plot in the same quadrant. Both the resistivity and phase share the same x-axis which is in log period, short periods on the left to long periods on the right. So if you zoom in on the plot both plots will zoom in to the same x-coordinates. If there is tipper information, you can plot the tipper as a third panel at the bottom, and also shares the x-axis. The arrows are in the convention of pointing towards a conductor. The xx and yy components can be plotted as well, this adds two panels on the right. Here the phase is left unwrapped. Other parameters can be added as subplots such as strike, skew and phase tensor ellipses.

To manipulate the plot you can change any of the attributes listed below and call redraw_plot(). If you know more aout matplotlib and want to change axes parameters, that can be done by changing the parameters in the axes attributes and then call update_plot(), note the plot must be open.

Attributes

plot_pt string to plot phase tensor ellipses
plot_skew string to plot skew
plot_strike string to plot strike
plot_tipper string to plot tipper

Methods

plot() plotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.
redraw_plot() use this function if you updated some attributes and want to re-plot.
save_plot(save_fn[, file_format, …]) save_plot will save the figure to save_fn.
update_plot() update any parameters that where changed using the built-in draw from canvas.
plot()[source]

plotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.

plot_pt

string to plot phase tensor ellipses

plot_skew

string to plot skew

plot_strike

string to plot strike

plot_tipper

string to plot tipper

redraw_plot()[source]

use this function if you updated some attributes and want to re-plot.

Example:
>>> # change the color and marker of the xy components
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> p1.xy_color = (.5,.5,.9)
>>> p1.xy_marker = '*'
>>> p1.redraw_plot()
save_plot(save_fn, file_format='pdf', orientation='portrait', fig_dpi=None, close_plot='y')[source]

save_plot will save the figure to save_fn.

update_plot()[source]

update any parameters that where changed using the built-in draw from canvas.

Use this if you change an of the .fig or axes properties

Example:
>>> # to change the grid lines to only be on the major ticks
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> [ax.grid(True, which='major') for ax in [p1.axr,p1.axp]]
>>> p1.update_plot()

plots multiple MT responses simultaneously

Created on Thu May 30 17:02:39 2013 @author: jpeacock-pr

YG: the code there is massey, todo may need to rewrite it sometime

class mtpy.imaging.plotnresponses.PlotMultipleResponses(**kwargs)[source]

plots multiple MT responses simultaneously either in single plots or in one plot of sub-figures or in a single plot with subfigures for each component.

expecting only one type of input –> can be:

fn_list : list of filenames to plot

z_object_list : list of mtpy.core.z.Z objects

res_object_list : list of mtpy.imaging.mtplot.ResPhase objects

tipper_object_list : list of mtpy.imaging.mtplot.Tipper objects

mt_object_list : list of mtpy.imaging.mtplot.MTplot objects

Attributes

plot_pt string to plot phase tensor ellipses
plot_skew string to plot skew
plot_strike string to plot strike
plot_tipper string to plot tipper
rot_z rotation angle(s)

Methods

plot([show]) plot the apparent resistivity and phase
redraw_plot() use this function if you updated some attributes and want to re-plot.
update_plot() update any parameters that where changed using the built-in draw from canvas.
plot(show=True)[source]

plot the apparent resistivity and phase

plot_pt

string to plot phase tensor ellipses

plot_skew

string to plot skew

plot_strike

string to plot strike

plot_tipper

string to plot tipper

redraw_plot()[source]

use this function if you updated some attributes and want to re-plot.

Example:
>>> # change the color and marker of the xy components
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> p1.xy_color = (.5,.5,.9)
>>> p1.xy_marker = '*'
>>> p1.redraw_plot()
rot_z

rotation angle(s)

update_plot()[source]

update any parameters that where changed using the built-in draw from canvas.

Use this if you change an of the .fig or axes properties

Example:
>>> # to change the grid lines to only be on the major ticks
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> [ax.grid(True, which='major') for ax in [p1.axr,p1.axp]]
>>> p1.update_plot()

Created on Thu May 30 18:28:24 2013

@author: jpeacock-pr

class mtpy.imaging.plotstrike.PlotStrike(**kwargs)[source]

PlotStrike will plot the strike estimated from the invariants, phase tensor and the tipper in either a rose diagram of xy plot

plots the strike angle as determined by phase tensor azimuth (Caldwell et al. [2004]) and invariants of the impedance tensor (Weaver et al. [2003]).

The data is split into decades where the histogram for each is plotted in the form of a rose diagram with a range of 0 to 180 degrees. Where 0 is North and 90 is East. The median angle of the period band is set in polar diagram. The top row is the strike estimated from the invariants of the impedance tensor. The bottom row is the azimuth estimated from the phase tensor. If tipper is ‘y’ then the 3rd row is the strike determined from the tipper, which is orthogonal to the induction arrow direction.

Attributes

-axhinv matplotlib.axes instance for invariant strike
-axhpt matplotlib.axes instance for phase tensor strike -axhtip matplotlib.axes instance for tipper strike -barinv matplotlib.axes.bar instance for invariant strike -barpt matplotlib.axes.bar instance for pt strike -bartr matplotlib.axes.bar instance for tipper strike -bin_width width of histogram bins in degrees -fig matplotlib.figure instance of plot -fig_dpi dots-per-inch resolution of figure -fig_num number of figure being plotted -fig_size size of figure in inches -fold boolean to fold angles to range from [0,180] or [0,360] -font_size font size of axes tick labels -mt_list list of mtplot.MTplot instances containing all the important information for each station -period_tolerance tolerance to look for periods being plotted -plot_range range of periods to plot -plot_tipper string to tell program to plot induction arrows -plot_type string to tell program how to plot strike angles -plot_yn plot strike on instance creation -pt_error_floor error floor to plot phase tensor strike, anything above this error will not be plotted -text_pad padding between text and rose diagram -text_size font size of text labeling the mode of the histogram -title_dict title dictionary

Methods

-plot plots the pseudo section
-redraw_plot on call redraws the plot from scratch -save_figure saves figure to a file of given format -update_plot updates the plot while still active -export_pt_params_to_file writes parameters of the phase tensor and tipper to text files.
redraw_plot()[source]

use this function if you updated some attributes and want to re-plot.

Example:
>>> # change the color and marker of the xy components
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> p1.xy_color = (.5,.5,.9)
>>> p1.xy_marker = '*'
>>> p1.redraw_plot()
rot_z

rotation angle(s)

save_plot(save_fn, file_format='pdf', orientation='portrait', fig_dpi=None, close_plot='y')[source]

save_plot will save the figure to save_fn.

Examples

Example:
>>> # to save plot as jpg
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotPhaseTensorMaps(edilist,freqspot=10)
>>> p1.save_plot(r'/home/MT', file_format='jpg')

‘Figure saved to /home/MT/PTMaps/PTmap_phimin_10Hz.jpg’

update_plot()[source]

update any parameters that where changed using the built-in draw from canvas.

Use this if you change an of the .fig or axes properties

Example:
>>> # to change the grid lines to only be on the major ticks
>>> import mtpy.imaging.mtplottools as mtplot
>>> p1 = mtplot.PlotResPhase(r'/home/MT/mt01.edi')
>>> [ax.grid(True, which='major') for ax in [p1.axr,p1.axp]]
>>> p1.update_plot()
writeTextFiles(save_path=None)[source]

Saves the strike information as a text file.