Package Imaging¶
Penetration Depth¶
- Description:
For a given input edi file, plot the Penetration Depth vs all the periods (1/freq). Or input a directory of edi multi-files (*.edi), the program will loop to plot the penetration depth profile for each edi.
Author: fei.zhang@ga.gov.au Date: 2017-01-23
- mtpy.imaging.penetration_depth1d.plot_edi_dir(edi_path, rholist=['zxy', 'zyx', 'det'], fig_dpi=400, savefile=None)[source]¶
plot edi files from the input directory edi_path
- mtpy.imaging.penetration_depth1d.plot_edi_file(edifile, rholist=['zxy', 'zyx', 'det'], savefile=None, fig_dpi=400)[source]¶
Plot the input edi_file Args:
edi_file: path2edifile rholist: a list of the rho to be used. savefile: path2savefig, not save if None
Returns:
- Description:
With an input edi_file_folder and a list of period index, generate a profile using occam2d module, then plot the Penetration Depth profile at the given periods vs the stations locations.
- Usage:
python mtpy/imaging/penetration_depth2d.py /path2/edi_files_dir/ period_index_list python mtpy/imaging/penetration_depth2d.py.py examples/data/edi2/ 0 1 10 20 30 40
Author: fei.zhang@ga.gov.au Date: 2017-01-23
- Revision History:
- brenainn.moushall@ga.gov.au 03-04-2020 15:41:39 AEDT:
Modify 2D plot profile to take a list of selected periods instead of period indicies
- mtpy.imaging.penetration_depth2d.barplot_multi_station_penentration_depth(edifiles_dir, per_index=0, zcomponent='det')[source]¶
A simple bar chart plot of the penetration depth across multiple edi files (stations), at the given (frequency) per_index. No profile-projection is done in this funciton. :param edifiles_dir: a list of edi files, or a dir of edi :param per_index: an integer smaller than the number of MT frequencies in the edi files. :return:
- Description:
Given a set of EDI files plot the Penetration Depth vs the station_location. Note that the values of periods within10% tolerance (ptol=0.1) are considered as equal. Setting a smaller value for ptol(=0.05) may result less MT sites data included.
- Usage:
python mtpy/imaging/penetration_depth3d.py /path2/edi_files_dir/ period_index
Author: fei.zhang@ga.gov.au Date: 2017-01-23
- mtpy.imaging.penetration_depth3d.create_penetration_depth_csv(edi_dir, outputcsv, zcomponent='det')[source]¶
Loop over all edi files, and create a csv file with the columns: Header Lat, Lon, per0, per1,per2,…..
TODO: calculate pen-depth for each period, and write into a file for each period, even if non-equal freq cross edi files. Moved this function into edi_collection.create_penetration_depth_csv()
lat, lon, pendepth0, pendepth1, … :param edi_dir: path_to_edifiles_dir :param zcomponent: det | zxy | zyx :param outputcsv: path2output.csv file :return:
- mtpy.imaging.penetration_depth3d.create_shapefile(edi_dir, outputfile=None, zcomponent='det')[source]¶
create a shapefile for station, penetration_depths :param edi_dir: :param outputfile: :param zcomponent: :return:
- mtpy.imaging.penetration_depth3d.get_index2(lat, lon, ref_lat, ref_lon, pixelsize)[source]¶
Mapping of lat lon to a grid :param lat: :param lon: :param ref_lon: :param ref_lat: :param pixelsize: :return:
- mtpy.imaging.penetration_depth3d.get_penetration_depths_from_edi_file(edifile, rholist=['det'])[source]¶
Compute the penetration depths of an edi file :param edifile: input edifile :param rholist: flag the method to compute penetration depth: det zxy zyx :return: a tuple:(station_lat, statoin_lon, periods_list, pendepth_list)
- mtpy.imaging.penetration_depth3d.plot_bar3d_depth(edifiles, per_index, whichrho='det')[source]¶
plot 3D bar of penetration depths For a given freq/period index of a set of edifiles/dir, the station,periods, pendepth,(lat, lon) are extracted the geo-bounding box calculated, and the mapping from stations to grids is constructed and plotted.
- Parameters
whichrho – z component either ‘det’, ‘zxy’ or ‘zyx’
edifiles – an edi_dir or list of edi_files
per_index – period index number 0,1,2
- Returns
- mtpy.imaging.penetration_depth3d.plot_latlon_depth_profile(edi_dir, period, zcomponent='det', showfig=True, savefig=True, savepath=None, fig_dpi=400, fontsize=14, file_format='png', ptol=0.1, **kwargs)[source]¶
MT penetration depth profile in lat-lon coordinates with pixelsize = 0.002 :param savefig: :param showfig: :param edi_dir: :param period: :param zcomponent: :return:
- mtpy.imaging.penetration_depth3d.reverse_colourmap(cmap, name='my_cmap_r')[source]¶
In: cmap, name Out: my_cmap_r
Explanation: http://stackoverflow.com/questions/3279560/invert-colormap-in-matplotlib
- Description:
This file defines imaging functions for penetration. The plotting function are extracted and implemented in plot() of each class from penetration_depth1D.py, penetration_depth2D.py and penetration_depth3D.py
- Usage:
see descriptions of each clases
Author: YingzhiGou Date: 20/06/2017
- Revision History:
- brenainn.moushall@ga.gov.au 03-04-2020 15:40:53 AEDT:
Modify Depth2D and get_penetration_depth to get nearest period to specified periods
- class mtpy.imaging.penetration.Depth1D(edis=None, rholist={'det', 'zxy', 'zyx'})[source]¶
Description: For a given input MT object, plot the Penetration Depth vs all the periods (1/freq).
- Attributes
data
the data (mt objects) that are to be plotted
fig
matplotlib fig object
Methods
close
()close the figure :return:
show
([block])display the image :return:
export_image
get_data
get_figure
plot
set_data
set_rholist
- class mtpy.imaging.penetration.Depth2D(selected_periods, data=None, ptol=0.05, rho='det')[source]¶
With a list of MT object and a list of period selected periods, generate a profile using occam2d module, then plot the penetration depth profile at the given periods vs stations.
- Attributes
data
the data (mt objects) that are to be plotted
fig
matplotlib fig object
Methods
close
()close the figure :return:
show
([block])display the image :return:
export_image
get_data
get_figure
plot
set_data
set_rho
- class mtpy.imaging.penetration.Depth3D(edis=None, period=None, rho='det', ptol=0.1)[source]¶
For a set of EDI files (input as a list of MT objects), plot the Penetration Depth vs the station_location, for a given period value or index Note that the values of periods within tolerance (ptol=0.1) are considered as equal. Setting a smaller value for ptol may result less MT sites data included.
- Attributes
data
the data (mt objects) that are to be plotted
fig
matplotlib fig object
Methods
close
()close the figure :return:
show
([block])display the image :return:
export_image
get_data
get_figure
get_period_fmt
plot
set_data
set_period
set_rho
- mtpy.imaging.penetration.check_period_values(period_list, ptol=0.1)[source]¶
check if all the values are equal in the input list :param period_list: a list of period :param ptol=0.1 # 1% percentage tolerance of period values considered as equal :return: True/False
- mtpy.imaging.penetration.get_bounding_box(latlons)[source]¶
get min max lat lon from the list of lat-lon-pairs points
- mtpy.imaging.penetration.get_index(lat, lon, minlat, minlon, pixelsize, offset=0)[source]¶
compute the grid index from the lat lon float value :param lat: float lat :param lon: float lon :param minlat: min lat at low left corner :param minlon: min long at left :param pixelsize: pixel size in lat long degree :param offset: a shift of grid index. should be =0. :return: a paire of integer
- mtpy.imaging.penetration.get_penetration_depth_by_index(mt_obj_list, per_index, whichrho='det')[source]¶
Compute the penetration depth of mt_obj at the given period_index, and using whichrho option.
- Parameters
- mt_obj_listlist of MT
List of stations as MT objects.
- selected_periodfloat
The period in seconds to plot depth for.
- ptolfloat
Tolerance to use when finding nearest period to selected period. If abs(selected_period - nearest_period) is greater than ptol * selected_period, then the period is discarded and will appear as a gap in the plot.
- whichrhostr
‘det’, ‘zxy’ or ‘zyx’. The component to plot.
- mtpy.imaging.penetration.get_penetration_depth_by_period(mt_obj_list, selected_period, ptol=0.1, whichrho='det')[source]¶
This is a more generic and useful function to compute the penetration depths of a list of edi files at given selected_period (in seconds, NOT freq). No assumption is made about the edi files period list. A tolerance of ptol=10% is used to identify the relevant edi files which contain the period of interest.
- Parameters
ptol – freq error/tolerance, need to be consistent with phase_tensor_map.py, default is 0.1
edi_file_list – edi file list of mt object list
period_sec – the float number value of the period in second: 0.1, …20.0
whichrho –
- Returns
tuple of (stations, periods, penetrationdepth, lat-lons-pairs)
- Description:
Plots resistivity and phase maps for a given frequency
References:
CreationDate: 4/19/18 Developer: rakib.hassan@ga.gov.au
- Revision History:
LastUpdate: 4/19/18 RH
- class mtpy.imaging.plot_resphase_maps.PlotResPhaseMaps(**kwargs)[source]¶
Plots apparent resistivity and phase in map view from a list of edi files
Methods
plot
(freq, type, vmin, vmax[, ...])- param freq
plot frequency
- plot(freq, type, vmin, vmax, extrapolation_buffer_degrees=1, regular_grid_nx=100, regular_grid_ny=100, nn=7, p=4, show_stations=True, show_station_names=False, save_path='/home/docs/checkouts/readthedocs.org/user_builds/mtpy2/checkouts/develop/docs/source', file_ext='png', cmap='rainbow', show=True)[source]¶
- Parameters
freq – plot frequency
type – plot type; can be either ‘res’ or ‘phase’
vmin – minimum value used in color-mapping
vmax – maximum value used in color-mapping
extrapolation_buffer_degrees – extrapolation buffer in degrees
regular_grid_nx – number of longitudinal grid points to use during interpolation
regular_grid_ny – number of latitudinal grid points to use during interpolation
nn – number of nearest neighbours to use in inverse distance weighted interpolation
p – power parameter in inverse distance weighted interpolation
save_path – path where plot is saved
file_ext – file extension
show – boolean to toggle display of plot
- Returns
fig object
Module Plot Phase Tensor Maps¶
Plot phase tensor map in Lat-Lon Coordinate System
- Revision History:
Created by @author: jpeacock-pr on Thu May 30 18:20:04 2013
Modified by Fei.Zhang@ga.gov.au 2017-03:
- brenainn.moushall 26-03-2020 15:07:14 AEDT:
Add plotting of geotiff as basemap background.
- class mtpy.imaging.phase_tensor_maps.PlotPhaseTensorMaps(**kwargs)[source]¶
Plots phase tensor ellipses in map view from a list of edi files
- Attributes
rot_z
rotation angle(s)
Methods
export_params_to_file
([save_path])write text files for all the phase tensor parameters. :param save_path: string path to save files into. File naming pattern is like save_path/PhaseTensorTipper_Params_freq.csv/table **Files Content ** *station *lon *lat *phi_min *phi_max *skew *ellipticity *azimuth *tipper_mag_real *tipper_ang_real *tipper_mag_imag *tipper_ang_imag.
plot
([fig, save_path, show, raster_dict])Plots the phase tensor map. :param fig: optional figure object :param save_path: path to folder for saving plots :param show: show plots if True :param raster_dict: Plotting of raster data is currently only supported when mapscale='deg'. This parameter is a dictionary of parameters for plotting raster data, on top of which phase tensor data are plotted. 'lons', 'lats' and 'vals' are one dimensional lists (or numpy arrays) for longitudes, latitudes and corresponding values, respectively. 'levels', 'cmap' and 'cbar_title' are the number of levels to be used in the colormap, the colormap and its title, respectively.
use this function if you updated some attributes and want to re-plot.
save_figure
(save_fn[, file_format, ...])save_plot will save the figure to save_fn.
update any parameters that where changed using the built-in draw from canvas.
- export_params_to_file(save_path=None)[source]¶
write text files for all the phase tensor parameters. :param save_path: string path to save files into. File naming pattern is like save_path/PhaseTensorTipper_Params_freq.csv/table **Files Content **
- Returns
path2savedfile
- plot(fig=None, save_path=None, show=True, raster_dict={'cbar_position': None, 'cbar_title': 'Arbitrary units', 'cmap': 'rainbow', 'lats': [], 'levels': 50, 'lons': [], 'vals': []})[source]¶
Plots the phase tensor map. :param fig: optional figure object :param save_path: path to folder for saving plots :param show: show plots if True :param raster_dict: Plotting of raster data is currently only supported when mapscale=’deg’.
This parameter is a dictionary of parameters for plotting raster data, on top of which phase tensor data are plotted. ‘lons’, ‘lats’ and ‘vals’ are one dimensional lists (or numpy arrays) for longitudes, latitudes and corresponding values, respectively. ‘levels’, ‘cmap’ and ‘cbar_title’ are the number of levels to be used in the colormap, the colormap and its title, respectively.
- property rot_z¶
rotation angle(s)
Module PlotPhaseTensorPseudoSection¶
Created on Thu May 30 18:10:55 2013
@author: jpeacock-pr
- class mtpy.imaging.phase_tensor_pseudosection.PlotPhaseTensorPseudoSection(**kwargs)[source]¶
PlotPhaseTensorPseudoSection will plot the phase tensor ellipses in a pseudo section format
- Attributes
- rotation_angle
Methods
plot
([show])plots the phase tensor pseudo section.
use this function if you updated some attributes and want to re-plot.
save_figure
(save_fn[, file_format, ...])save_plot will save the figure to save_fn.
save_figure2
(save_fn[, file_format, ...])save_plot will save the figure to save_fn.
update any parameters that where changed using the built-in draw from canvas.
writeTextFiles
([save_path, ptol])This will write text files for all the phase tensor parameters
- plot(show=True)[source]¶
plots the phase tensor pseudo section. See class doc string for more details.
- redraw_plot()[source]¶
use this function if you updated some attributes and want to re-plot.
- Example
>>> # change ellipse size and color map to be segmented for skew >>> pt1.ellipse_size = 5 >>> pt1.ellipse_colorby = 'beta_seg' >>> pt1.ellipse_cmap = 'mt_seg_bl2wh2rd' >>> pt1.ellipse_range = (-9, 9, 3) >>> pt1.redraw_plot()
- save_figure(save_fn, file_format='png', orientation='portrait', fig_dpi=None, close_plot='y')[source]¶
save_plot will save the figure to save_fn.
- save_figure2(save_fn, file_format='jpg', 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 be on the major ticks and gray >>> pt1.ax.grid(True, which='major', color=(.5,.5,.5)) >>> pt1.update_plot()
Module MTPlot¶
Provides
Different plotting options to represent the MT response.
Ability to create text files of the plots for further analysis
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
- mtpy.imaging.mtplot.plot_mt_response(**kwargs)[source]¶
Plots Resistivity and phase for the different modes of the MT response. At the moment it 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.
- mtpy.imaging.mtplot.plot_multiple_mt_responses(**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
- mtpy.imaging.mtplot.plot_pt(**kwargs)[source]¶
Will plot phase tensor, strike angle, min and max phase angle, azimuth, skew, and ellipticity as subplots on one plot. It can plot the resistivity tensor along side the phase tensor for comparison.
- mtpy.imaging.mtplot.plot_pt_map(**kwargs)[source]¶
Plots phase tensor ellipses in map view from a list of edi files
- mtpy.imaging.mtplot.plot_pt_pseudosection(**kwargs)[source]¶
PlotPhaseTensorPseudoSection will plot the phase tensor ellipses in a pseudo section format
- mtpy.imaging.mtplot.plot_residual_pt_maps(fn_list1, fn_list2, **kwargs)[source]¶
This will plot residual phase tensors in a map for a single frequency. The data is read in and stored in 2 ways, one as a list ResidualPhaseTensor object for each matching station and the other in a structured array with all the important information. The structured array is the one that is used for plotting. It is computed each time plot() is called so if it is manipulated it is reset. The array is sorted by relative offset, so no special order of input is needed for the file names. However, the station names should be verbatim between surveys, otherwise it will not work.
The residual phase tensor is calculated as I-(Phi_2)^-1 (Phi_1)
The default coloring is by the geometric mean as sqrt(Phi_min*Phi_max), which defines the percent change between measurements.
There are a lot of parameters to change how the plot looks, have a look below if you figure looks a little funny. The most useful will be ellipse_size
The ellipses are normalized by the largest Phi_max of the survey.
- mtpy.imaging.mtplot.plot_residual_pt_ps(fn_list1, fn_list2, **kwargs)[source]¶
This will plot residual phase tensors in a pseudo section. The data is read in and stored in 2 ways, one as a list ResidualPhaseTensor object for each matching station and the other in a structured array with all the important information. The structured array is the one that is used for plotting. It is computed each time plot() is called so if it is manipulated it is reset. The array is sorted by relative offset, so no special order of input is needed for the file names. However, the station names should be verbatim between surveys, otherwise it will not work.
The residual phase tensor is calculated as I-(Phi_2)^-1 (Phi_1)
The default coloring is by the geometric mean as sqrt(Phi_min*Phi_max), which defines the percent change between measurements.
There are a lot of parameters to change how the plot looks, have a look below if you figure looks a little funny. The most useful will be xstretch, ystretch and ellipse_size
The ellipses are normalized by the largest Phi_max of the survey.
- mtpy.imaging.mtplot.plot_resphase_pseudosection(**kwargs)[source]¶
plot a resistivity and phase pseudo section for different components
Need to input one of the following lists:
- mtpy.imaging.mtplot.plot_station_locations(**kwargs)[source]¶
plot station locations in map view.
Need to input one of the following lists:
- mtpy.imaging.mtplot.plot_strike(**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.
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.
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 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.
- property plot_pt¶
string to plot phase tensor ellipses
- property plot_skew¶
string to plot skew
- property plot_strike¶
string to plot strike
- property 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
use this function if you updated some attributes and want to re-plot.
update any parameters that where changed using the built-in draw from canvas.
- property plot_pt¶
string to plot phase tensor ellipses
- property plot_skew¶
string to plot skew
- property plot_strike¶
string to plot strike
- property 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()
- property 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
- rotation_angle
Methods
get_mean
(st_array)get mean value
get_median
(st_array)get median value
get_mode
(st_hist)get mode from a historgram
get_plot_array
(st_array)get a plot array that has the min and max angles
get_stats
(st_array, st_hist[, exponent])print stats nicely
make strike array
plot
([show])plot Strike angles as rose plots
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 any parameters that where changed using the built-in draw from canvas.
writeTextFiles
([save_path])Saves the strike information as a text file.
- 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.
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()
Created on Thu May 30 18:28:24 2013
@author: jpeacock-pr
- class mtpy.imaging.plotstrike2d.PlotStrike2D(**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
rot_z
rotation angle(s)
Methods
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 any parameters that where changed using the built-in draw from canvas.
writeTextFiles
([save_path])Saves the strike information as a text file.
plot
- 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()
- property 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.
- 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()
Plot MT Response¶
plot_mt_response¶
Plots the resistivity and phase for different modes and components
Created 2017
@author: jpeacock
- class mtpy.imaging.plot_mt_response.PlotMTResponse(z_object=None, t_object=None, pt_obj=None, station='MT Response', **kwargs)[source]¶
Plots Resistivity and phase for the different modes of the MT response. At the moment it 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
period
plot period
Methods
plot
([show, overlay_mt_obj])plotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.
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 any parameters that where changed using the built-in draw from canvas.
- property period¶
plot period
- plot(show=True, overlay_mt_obj=None)[source]¶
plotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.
- 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()
Visualization of Models¶
- class mtpy.imaging.plot_depth_slice.PlotDepthSlice(model_fn=None, data_fn=None, **kwargs)[source]¶
Plots depth slices of resistivity model (file.rho)
- Example
>>> import mtpy.modeling.ws3dinv as ws >>> mfn = r"/home/MT/ws3dinv/Inv1/Test_model.00" >>> sfn = r"/home/MT/ws3dinv/Inv1/WSStationLocations.txt" >>> # plot just first layer to check the formatting >>> pds = ws.PlotDepthSlice(model_fn=mfn, station_fn=sfn, >>> ... depth_index=0, save_plots='n') >>> #move color bar up >>> pds.cb_location >>> (0.64500000000000002, 0.14999999999999997, 0.3, 0.025) >>> pds.cb_location = (.645, .175, .3, .025) >>> pds.redraw_plot() >>> #looks good now plot all depth slices and save them to a folder >>> pds.save_path = r"/home/MT/ws3dinv/Inv1/DepthSlices" >>> pds.depth_index = None >>> pds.save_plots = 'y' >>> pds.redraw_plot()
Attributes
Description
cb_location
location of color bar (x, y, width, height) default is None, automatically locates
cb_orientation
[ ‘vertical’ | ‘horizontal’ ] default is horizontal
cb_pad
padding between axes and colorbar default is None
cb_shrink
percentage to shrink colorbar by default is None
climits
(min, max) of resistivity color on log scale default is (0, 4)
cmap
name of color map default is ‘jet_r’
data_fn
full path to data file
depth_index
integer value of depth slice index, shallowest layer is 0
dscale
scaling parameter depending on map_scale
ew_limits
(min, max) plot limits in e-w direction in map_scale units. default is None, sets viewing area to the station area
fig_aspect
aspect ratio of plot. default is 1
fig_dpi
resolution of figure in dots-per-inch. default is 300
fig_list
list of matplotlib.figure instances for each depth slice
fig_size
[width, height] in inches of figure size default is [6, 6]
font_size
size of ticklabel font in points, labels are font_size+2. default is 7
grid_east
relative location of grid nodes in e-w direction in map_scale units
grid_north
relative location of grid nodes in n-s direction in map_scale units
grid_z
relative location of grid nodes in z direction in map_scale units
initial_fn
full path to initial file
map_scale
[ ‘km’ | ‘m’ ] distance units of map. default is km
mesh_east
np.meshgrid(grid_east, grid_north, indexing=’ij’)
mesh_north
np.meshgrid(grid_east, grid_north, indexing=’ij’)
model_fn
full path to model file
nodes_east
relative distance betwen nodes in e-w direction in map_scale units
nodes_north
relative distance betwen nodes in n-s direction in map_scale units
nodes_z
relative distance betwen nodes in z direction in map_scale units
ns_limits
(min, max) plot limits in n-s direction in map_scale units. default is None, sets viewing area to the station area
plot_grid
[ ‘y’ | ‘n’ ] ‘y’ to plot mesh grid lines. default is ‘n’
plot_yn
[ ‘y’ | ‘n’ ] ‘y’ to plot on instantiation
res_model
np.ndarray(n_north, n_east, n_vertical) of model resistivity values in linear scale
save_path
path to save figures to
save_plots
[ ‘y’ | ‘n’ ] ‘y’ to save depth slices to save_path
station_east
location of stations in east direction in map_scale units
station_fn
full path to station locations file
station_names
station names
station_north
location of station in north direction in map_scale units
subplot_bottom
distance between axes and bottom of figure window
subplot_left
distance between axes and left of figure window
subplot_right
distance between axes and right of figure window
subplot_top
distance between axes and top of figure window
title
titiel of plot default is depth of slice
xminorticks
location of xminorticks
yminorticks
location of yminorticks
Methods
plot
([ind])plot the depth slice ind-th
redraw plot if parameters were changed use this function if you updated some attributes and want to re-plot.