mtpy.imaging package
Subpackages
- mtpy.imaging.mtplot_tools package
- Submodules
- mtpy.imaging.mtplot_tools.arrows module
- mtpy.imaging.mtplot_tools.base module
- mtpy.imaging.mtplot_tools.ellipses module
- mtpy.imaging.mtplot_tools.map_interpolation_tools module
- mtpy.imaging.mtplot_tools.plot_settings module
PlotSettingsPlotSettings.fig_numPlotSettings.fig_dpiPlotSettings.fig_sizePlotSettings.show_plotPlotSettings.font_sizePlotSettings.font_weightPlotSettings.marker_sizePlotSettings.marker_lwPlotSettings.marker_colorPlotSettings.markerPlotSettings.lwPlotSettings.plot_titlePlotSettings.plot_zPlotSettings.plot_tipperPlotSettings.plot_ptPlotSettings.plot_strikePlotSettings.plot_skewPlotSettings.text_sizePlotSettings.text_weightPlotSettings.text_colorPlotSettings.text_haPlotSettings.text_vaPlotSettings.text_anglePlotSettings.text_rotationPlotSettings.cb_orientationPlotSettings.cb_positionPlotSettings.arrow_imag_propertiesPlotSettings.arrow_real_propertiesPlotSettings.det_error_bar_propertiesPlotSettings.font_dictPlotSettings.make_pt_cb()PlotSettings.period_label_dictPlotSettings.set_period_limits()PlotSettings.set_phase_limits()PlotSettings.set_resistivity_limits()PlotSettings.text_dictPlotSettings.xy_error_bar_propertiesPlotSettings.yx_error_bar_properties
- mtpy.imaging.mtplot_tools.plotters module
- mtpy.imaging.mtplot_tools.utils module
- Module contents
MTArrowsMTEllipsePlotBasePlotBaseMapsPlotBaseProfilePlotSettingsPlotSettings.fig_numPlotSettings.fig_dpiPlotSettings.fig_sizePlotSettings.show_plotPlotSettings.font_sizePlotSettings.font_weightPlotSettings.marker_sizePlotSettings.marker_lwPlotSettings.marker_colorPlotSettings.markerPlotSettings.lwPlotSettings.plot_titlePlotSettings.plot_zPlotSettings.plot_tipperPlotSettings.plot_ptPlotSettings.plot_strikePlotSettings.plot_skewPlotSettings.text_sizePlotSettings.text_weightPlotSettings.text_colorPlotSettings.text_haPlotSettings.text_vaPlotSettings.text_anglePlotSettings.text_rotationPlotSettings.cb_orientationPlotSettings.cb_positionPlotSettings.arrow_imag_propertiesPlotSettings.arrow_real_propertiesPlotSettings.det_error_bar_propertiesPlotSettings.font_dictPlotSettings.make_pt_cb()PlotSettings.period_label_dictPlotSettings.set_period_limits()PlotSettings.set_phase_limits()PlotSettings.set_resistivity_limits()PlotSettings.text_dictPlotSettings.xy_error_bar_propertiesPlotSettings.yx_error_bar_properties
add_raster()get_log_tick_labels()griddata_interpolate()interpolate_to_map()plot_errorbar()plot_phase()plot_pt_lateral()plot_resistivity()plot_tipper_lateral()triangulate_interpolation()
Submodules
mtpy.imaging.mtcolors module
Created on Tue May 14 18:05:59 2013
@author: jpeacock-pr
- class mtpy.imaging.mtcolors.FixPointNormalize(vmin=None, vmax=None, sealevel=0, col_val=0.21875, clip=False)[source]
Bases:
NormalizeInspired by https://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib Subclassing Normalize to obtain a colormap with a fixpoint somewhere in the middle of the colormap. This may be useful for a terrain map, to set the “sea level” to a color in the blue/turquise range.
- mtpy.imaging.mtcolors.cmap_discretize(cmap, N)[source]
Return a discrete colormap from the continuous colormap cmap.
cmap: colormap instance, eg. cm.jet. N: number of colors.
- Example
x = resize(arange(100), (5,100)) djet = cmap_discretize(cm.jet, 5) imshow(x, cmap=djet)
- mtpy.imaging.mtcolors.get_color(cvar, cmap)[source]
Gets the color to plot for the given color map.
mtpy.imaging.plot_mt_response module
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]
Bases:
PlotBasePlots 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.
- property period
Plot period.
- plot()[source]
PlotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.
- property plot_model_error
Plot model error.
- property rotation_angle
Rotation angle.
mtpy.imaging.plot_mt_responses module
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.plot_mt_responses.PlotMultipleResponses(mt_data, **kwargs)[source]
Bases:
PlotBasePlots 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.
- Arguments::
- fn_listlist of filenames to plot
ie. [fn_1, fn_2, …], default is None
- plot_num[ 1 | 2 | 3 ]
1 for just Ex/By and Ey/Bx default
2 for all 4 components
3 for off diagonal plus the determinant
- plot_style[ ‘1’ | ‘all’ | ‘compare’ ]
- determines the plotting style:
- ‘1’ for plotting each station in a different
figure. default
- ‘all’ for plotting each station in a subplot
all in the same figure
- ‘compare’ for comparing the responses all in
one plot. Here the responses are colored from dark to light. This plot can get messy if too many stations are plotted.
- property plot_model_error
Plot model error.
- property rotation_angle
Rotation angle.
mtpy.imaging.plot_penetration_depth_1d module
Created on Thu Sep 22 10:58:58 2022
@author: jpeacock
mtpy.imaging.plot_penetration_depth_map module
Created on Thu Sep 22 10:58:58 2022
@author: jpeacock
- class mtpy.imaging.plot_penetration_depth_map.PlotPenetrationDepthMap(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlot the depth of penetration based on the Niblett-Bostick approximation.
- property depth_units
Depth units.
mtpy.imaging.plot_phase_tensor_maps module
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.
Updated 2022 by J. Peacock to work with v2
Using rasterio to plot geotiffs
factorized
using interp function for faster plotting.
- class mtpy.imaging.plot_phase_tensor_maps.PlotPhaseTensorMaps(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlots phase tensor ellipses in map view from a list of edi files.
- property map_scale
Map scale.
- plot(fig=None, save_path=None, show=True, raster_file=None, raster_kwargs={})[source]
Plots the phase tensor map. :param raster_kwargs:
Defaults to {}.
- Parameters:
raster_file – Defaults to None.
fig – Optional figure object, defaults to None.
save_path – Path to folder for saving plots, defaults to None.
show – Show plots if True, defaults to True.
raster_dict – Dictionary containing information for a raster to be plotted below the phase tensors.
- property rotation_angle
Rotation angle.
- property skew_cmap_bounds
Skew bounds for a segmented colorba.
mtpy.imaging.plot_phase_tensor_pseudosection module
Created on Thu May 30 18:10:55 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_phase_tensor_pseudosection.PlotPhaseTensorPseudoSection(mt_data, **kwargs)[source]
Bases:
PlotBaseProfilePlotPhaseTensorPseudoSection will plot the phase tensor ellipses in a pseudo section format
To get a list of .edi files that you want to plot –> :Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath = r"/home/EDIfiles" >>> edilist = [os.path.join(edipath,edi) for edi in os.listdir(edipath) >>> ... if edi.find('.edi')>0]
If you want to plot minimum phase colored from blue to red in a range of
20 to 70 degrees you can do it one of two ways–>
1) :Example:
>>> edict = {'range':(20,70), 'cmap':'mt_bl2gr2rd','colorby':'phimin'} >>> pt1 = mtplot.plot_pt_pseudosection(fn_list=edilist, ellipse_dict=edict)
2) :Example:
>>> pt1 = mtplot.plot_pt_pseudosection(fn_list=edilist, plot_yn='n') >>> pt1.ellipse_colorby = 'phimin' >>> pt1.ellipse_cmap = 'mt_bl2gr2rd' >>> pt1.ellipse_range = (20,70) >>> pt1.plot()
If you want to add real induction arrows that are scaled by 10 and point
away from a conductor –>
- Example:
>>> pt1.plot_tipper = 'yr' >>> pt1.arrow_size = 10 >>> pt1.arrow_direction = -1 >>> pt1.redraw_plot()
If you want to save the plot as a pdf with a generic name –>
- Example:
:: >>> pt1.save_figure(r”/home/PTFigures”, file_format=’pdf’, dpi=300) File saved to ‘/home/PTFigures/PTPseudoSection.pdf’
mtpy.imaging.plot_pseudosection module
Created on Thu May 30 18:39:58 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_pseudosection.PlotResPhasePseudoSection(mt_data, **kwargs)[source]
Bases:
PlotBaseProfilePlot a resistivity and phase pseudo section for different components
Need to input one of the following lists:.
mtpy.imaging.plot_pt module
Created on Thu May 30 17:07:50 2013
@author: jpeacock
- class mtpy.imaging.plot_pt.PlotPhaseTensor(pt_object, station=None, **kwargs)[source]
Bases:
PlotBaseWill 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.
- property rotation_angle
Rotation angle.
mtpy.imaging.plot_residual_pt_maps module
PlotResidualPhaseTensor
*plots the residual phase tensor for two different sets of measurments
Created on Wed Oct 16 14:56:04 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_residual_pt_maps.PlotResidualPTMaps(mt_data_01, mt_data_02, frequencies=array([1.00000000e-03, 1.42510267e-03, 2.03091762e-03, 2.89426612e-03, 4.12462638e-03, 5.87801607e-03, 8.37677640e-03, 1.19377664e-02, 1.70125428e-02, 2.42446202e-02, 3.45510729e-02, 4.92388263e-02, 7.01703829e-02, 1.00000000e-01, 1.42510267e-01, 2.03091762e-01, 2.89426612e-01, 4.12462638e-01, 5.87801607e-01, 8.37677640e-01, 1.19377664e+00, 1.70125428e+00, 2.42446202e+00, 3.45510729e+00, 4.92388263e+00, 7.01703829e+00, 1.00000000e+01, 1.42510267e+01, 2.03091762e+01, 2.89426612e+01, 4.12462638e+01, 5.87801607e+01, 8.37677640e+01, 1.19377664e+02, 1.70125428e+02, 2.42446202e+02, 3.45510729e+02, 4.92388263e+02, 7.01703829e+02, 1.00000000e+03]), **kwargs)[source]
Bases:
PlotBaseThis 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.
- Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath1 = r"/home/EDIfiles1" >>> edilist1 = [os.path.join(edipath1,edi) for edi in os.listdir(edipath1) >>> ... if edi.find('.edi')>0] >>> edipath2 = r"/home/EDIfiles2" >>> edilist2 = [os.path.join(edipath2,edi) for edi in os.listdir(edipath2) >>> ... if edi.find('.edi')>0] >>> # color by phimin with a range of 0-5 deg >>> ptmap = mtplot.plot_residual_pt_maps(edilist1, edilist2, freqspot=10, >>> ... ellipse_dict={'size':1, >>> ... 'range':(0,5)}) >>> >>> # >>> #---add an image--- >>> ptmap.image_file = r"/home/Maps/Basemap.jpg" >>> ptmap.image_extent = (0,10,0,10) >>> ptmap.redraw_plot() >>> # >>> #---Save the plot--- >>> ptmap.save_plot(r"/home/EDIfiles",file_format='pdf') >>> 'Saved figure to /home/EDIfile/PTMaps/PTmap_phimin_10.0_Hz.pdf'
- Example:
>>> #change the axis label and grid color >>> ptmap.ax.set_xlabel('Latitude (deg)') >>> ptmap.ax.grid(which='major', color=(.5,1,0)) >>> ptmap.update_plot()
- Example:
>>> # plot seismic hypocenters from a file >>> lat, lon, depth = np.loadtxt(r"/home/seismic_hypocenter.txt") >>> ptmap.ax.scatter(lon, lat, marker='o')
- property map_scale
Map scale.
- property rotation_angle
Rotation angle.
mtpy.imaging.plot_residual_pt_ps module
PlotResidualPhaseTensorPseudoSection
*plots the residual phase tensor for two different sets of measurments
Created on Wed Oct 16 14:56:04 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_residual_pt_ps.PlotResidualPTPseudoSection(mt_data_01, mt_data_02, frequencies=array([1.00000000e-03, 1.42510267e-03, 2.03091762e-03, 2.89426612e-03, 4.12462638e-03, 5.87801607e-03, 8.37677640e-03, 1.19377664e-02, 1.70125428e-02, 2.42446202e-02, 3.45510729e-02, 4.92388263e-02, 7.01703829e-02, 1.00000000e-01, 1.42510267e-01, 2.03091762e-01, 2.89426612e-01, 4.12462638e-01, 5.87801607e-01, 8.37677640e-01, 1.19377664e+00, 1.70125428e+00, 2.42446202e+00, 3.45510729e+00, 4.92388263e+00, 7.01703829e+00, 1.00000000e+01, 1.42510267e+01, 2.03091762e+01, 2.89426612e+01, 4.12462638e+01, 5.87801607e+01, 8.37677640e+01, 1.19377664e+02, 1.70125428e+02, 2.42446202e+02, 3.45510729e+02, 4.92388263e+02, 7.01703829e+02, 1.00000000e+03]), **kwargs)[source]
Bases:
PlotBaseProfileThis 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.
To get a list of .edi files that you want to plot –> :Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath1 = r"/home/EDIfiles1" >>> edilist1 = [os.path.join(edipath1,edi) for edi in os.listdir(edipath1) >>> ... if edi.find('.edi')>0] >>> edipath2 = r"/home/EDIfiles2" >>> edilist2 = [os.path.join(edipath2,edi) for edi in os.listdir(edipath2) >>> ... if edi.find('.edi')>0] >>> # color by phimin with a range of 0-5 deg
If you want to plot geometric mean colored from white to orange in a range of 0 to 10 percent you can do it one of two ways–>
1) :Example:
>>> edict = {'range':(0,10), 'cmap':'mt_wh2or', 'colorby':'geometric_mean', 'size':10} >>> pt1 = mtplot.residual_pt_ps(edilist1, edilst2, ellipse_dict=edict)
2) :Example:
>>> pt1 = mtplot.residual_pt_ps(edilist1, edilst2, ellipse_dict=edict, plot_yn='n') >>> pt1.ellipse_colorby = 'geometric_mean' >>> pt1.ellipse_cmap = 'mt_wh2or' >>> pt1.ellipse_range = (0, 10) >>> pt1.ellipse_size = 10 >>> pt1.plot()
If you want to save the plot as a pdf with a generic name –>
- Example:
:: >>> pt1.save_figure(r”/home/PTFigures”, file_format=’pdf’, dpi=300) File saved to ‘/home/PTFigures/PTPseudoSection.pdf’
- property rotation_angle
Rotation angle.
mtpy.imaging.plot_resphase_maps module
- 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
2022-09 JP
- class mtpy.imaging.plot_resphase_maps.PlotResPhaseMaps(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlots apparent resistivity and phase in map view from a list of edi files.
Arguments:
**fn_list** : list of strings full paths to .edi files to plot **fig_size** : tuple or list (x, y) in inches dimensions of the figure box in inches, this is a default unit of matplotlib. You can use this so make the plot fit the figure box to minimize spaces from the plot axes to the figure box. *default* is [8, 8] **mapscale** : [ 'deg' | 'm' | 'km' ] Scale of the map coordinates. * 'deg' --> degrees in latitude and longitude * 'm' --> meters for easting and northing * 'km' --> kilometers for easting and northing **plot_yn** : [ 'y' | 'n' ] *'y' to plot on creating an instance *'n' to not plot on creating an instance **title** : string figure title **dpi** : int dots per inch of the resolution. *default* is 300 **font_size** : float size of the font that labels the plot, 2 will be added to this number for the axis labels.
- property map_units
Map units.
mtpy.imaging.plot_spectrogram module
plotft
*PlotTF –> will plot a time frequency distribution of your choice
Created on Mon Aug 19 16:24:29 2013
@author: jpeacock
- class mtpy.imaging.plot_spectrogram.PlotTF(time_series, tf_type='smethod', **kwargs)[source]
Bases:
objectClass to plot Time-Frequency.
- redraw_plot()[source]
Use this function if you updated some attributes and want to re-plot.
- Example:
:: >>> tf1.plot_type = ‘tf’ >>> tf1.redraw_plot()
- save_figure(save_fn, file_format='pdf', orientation='portrait', fig_dpi=None, close_plot='y')[source]
Save_plot will save the figure to save_fn.
Arguments:
**save_fn** : string full path to save figure to, can be input as * directory path -> the directory path to save to in which the file will be saved as save_fn/TF_tftype.file_format * full path -> file will be save to the given path. If you use this option then the format will be assumed to be provided by the path **file_format** : [ pdf | eps | jpg | png | svg ] file type of saved figure pdf,svg,eps... **orientation** : [ landscape | portrait ] orientation in which the file will be saved *default* is portrait **fig_dpi** : int The resolution in dots-per-inch the file will be saved. If None then the dpi will be that at which the figure was made. I don't think that it can be larger than dpi of the figure. **close_plot** : [ y | n ] * 'y' will close the plot after saving. * 'n' will leave plot open :Example: :: >>> # save plot as a jpg >>> tf1.save_plot(r'/home/MT/figures', file_format='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 be on the major ticks and gray >>> tf1.ax.grid(True, which='major', color=(.5,.5,.5)) >>> tf1.update_plot()
mtpy.imaging.plot_stations module
PlotStations
Plots station locations in map view.
Created on Fri Jun 07 18:20:00 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_stations.PlotStations(geo_df, **kwargs)[source]
Bases:
PlotBasePlot station locations in map view.
Can set x_limits and y_limits to zoom in on a specific area. or set image_extent to plot an image in the background. or set pad to set the padding around the stations.
Uses contextily to get the basemap. See https://contextily.readthedocs.io/en/latest/index.html for more information about options.
mtpy.imaging.plot_strike module
Created on Thu May 30 18:28:24 2013
@author: jpeacock-pr
- class mtpy.imaging.plot_strike.PlotStrike(mt_data, **kwargs)[source]
Bases:
PlotBase- 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.
- param fs:
font size for labels of plotting. Default is 10
- param rot_z:
angle of rotation clockwise positive. Default is 0
- param period_tolerance:
float Tolerance level to match periods from different edi files. Default is 0.05
- param text_pad:
padding of the angle label at the bottom of each polar diagram. Default is 1.65
- param text_size:
font size
- param plot_range:
[ ‘data’ | (period_min,period_max) ] period range to estimate the strike angle. Options are:
- ‘data’ for estimating the strike for all periods
in the data.
(pmin,pmax) for period min and period max, input as (log10(pmin),log10(pmax))
- param plot_type:
[ 1 | 2 ] - 1 to plot individual decades in one plot - 2 to plot all period ranges into one polar diagram
for each strike angle estimation
- param plot_tipper:
[ True | False ] - True to plot the tipper strike - False to not plot tipper strike
- param pt_error_floor:
Maximum error in degrees that is allowed to estimate strike. Default is None allowing all estimates to be used.
- param fold:
[ True | False ] * True to plot only from 0 to 180 * False to plot from 0 to 360
- param plot_orthogonal:
[ True | False] * True to plot the orthogonal strike directions * False to not
- param color:
[ True | False ] * True to plot shade colors * False to plot all in one color
- param color_inv:
color of invariants plots
- param color_pt:
color of phase tensor plots
- param color_tip:
color of tipper plots
- param ring_spacing:
spacing of rings in polar plots
- param ring_limits:
(min count, max count) set each plot have these limits
- param plot_orientation:
[ ‘h’ | ‘v’ ] horizontal or vertical plots
- Example:
- )
>>> #---Turn on Tipper >>> strike.plot_tipper = True >>> #---Plot only main directions >>> strike.plot_orthogonal = False >>> # Redraw plot >>> strike.redraw_plot() >>> # plot only from 0-180 >>> strike.fold = True >>> strike.redraw_plot() >>> #---save the plot--- >>> strike.save_plot(r"/home/Figures")
- get_plot_array(estimate, period_range=None)[source]
Get a plot array that has the min and max angles.
- make_strike_df()[source]
Make strike array
Note
Polar plots assume the azimuth is an angle measured counterclockwise positive from x = 0. Therefore all angles are calculated as 90 - angle to make them conform to the polar plot convention..
- property rotation_angle
Rotation angle.
Module contents
- class mtpy.imaging.PlotMTResponse(z_object=None, t_object=None, pt_obj=None, station='MT Response', **kwargs)[source]
Bases:
PlotBasePlots 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.
- property period
Plot period.
- plot()[source]
PlotResPhase(filename,fig_num) will plot the apparent resistivity and phase for a single station.
- property plot_model_error
Plot model error.
- property rotation_angle
Rotation angle.
- class mtpy.imaging.PlotMultipleResponses(mt_data, **kwargs)[source]
Bases:
PlotBasePlots 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.
- Arguments::
- fn_listlist of filenames to plot
ie. [fn_1, fn_2, …], default is None
- plot_num[ 1 | 2 | 3 ]
1 for just Ex/By and Ey/Bx default
2 for all 4 components
3 for off diagonal plus the determinant
- plot_style[ ‘1’ | ‘all’ | ‘compare’ ]
- determines the plotting style:
- ‘1’ for plotting each station in a different
figure. default
- ‘all’ for plotting each station in a subplot
all in the same figure
- ‘compare’ for comparing the responses all in
one plot. Here the responses are colored from dark to light. This plot can get messy if too many stations are plotted.
- property plot_model_error
Plot model error.
- property rotation_angle
Rotation angle.
- class mtpy.imaging.PlotPenetrationDepth1D(tf, **kwargs)[source]
Bases:
PlotBasePlot the depth of penetration based on the Niblett-Bostick approximation.
- property depth_units
Depth units.
- class mtpy.imaging.PlotPenetrationDepthMap(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlot the depth of penetration based on the Niblett-Bostick approximation.
- property depth_units
Depth units.
- class mtpy.imaging.PlotPhaseTensor(pt_object, station=None, **kwargs)[source]
Bases:
PlotBaseWill 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.
- property rotation_angle
Rotation angle.
- class mtpy.imaging.PlotPhaseTensorMaps(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlots phase tensor ellipses in map view from a list of edi files.
- property map_scale
Map scale.
- plot(fig=None, save_path=None, show=True, raster_file=None, raster_kwargs={})[source]
Plots the phase tensor map. :param raster_kwargs:
Defaults to {}.
- Parameters:
raster_file – Defaults to None.
fig – Optional figure object, defaults to None.
save_path – Path to folder for saving plots, defaults to None.
show – Show plots if True, defaults to True.
raster_dict – Dictionary containing information for a raster to be plotted below the phase tensors.
- property rotation_angle
Rotation angle.
- property skew_cmap_bounds
Skew bounds for a segmented colorba.
- class mtpy.imaging.PlotPhaseTensorPseudoSection(mt_data, **kwargs)[source]
Bases:
PlotBaseProfilePlotPhaseTensorPseudoSection will plot the phase tensor ellipses in a pseudo section format
To get a list of .edi files that you want to plot –> :Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath = r"/home/EDIfiles" >>> edilist = [os.path.join(edipath,edi) for edi in os.listdir(edipath) >>> ... if edi.find('.edi')>0]
If you want to plot minimum phase colored from blue to red in a range of
20 to 70 degrees you can do it one of two ways–>
1) :Example:
>>> edict = {'range':(20,70), 'cmap':'mt_bl2gr2rd','colorby':'phimin'} >>> pt1 = mtplot.plot_pt_pseudosection(fn_list=edilist, ellipse_dict=edict)
2) :Example:
>>> pt1 = mtplot.plot_pt_pseudosection(fn_list=edilist, plot_yn='n') >>> pt1.ellipse_colorby = 'phimin' >>> pt1.ellipse_cmap = 'mt_bl2gr2rd' >>> pt1.ellipse_range = (20,70) >>> pt1.plot()
If you want to add real induction arrows that are scaled by 10 and point
away from a conductor –>
- Example:
>>> pt1.plot_tipper = 'yr' >>> pt1.arrow_size = 10 >>> pt1.arrow_direction = -1 >>> pt1.redraw_plot()
If you want to save the plot as a pdf with a generic name –>
- Example:
:: >>> pt1.save_figure(r”/home/PTFigures”, file_format=’pdf’, dpi=300) File saved to ‘/home/PTFigures/PTPseudoSection.pdf’
- class mtpy.imaging.PlotResPhaseMaps(mt_data, **kwargs)[source]
Bases:
PlotBaseMapsPlots apparent resistivity and phase in map view from a list of edi files.
Arguments:
**fn_list** : list of strings full paths to .edi files to plot **fig_size** : tuple or list (x, y) in inches dimensions of the figure box in inches, this is a default unit of matplotlib. You can use this so make the plot fit the figure box to minimize spaces from the plot axes to the figure box. *default* is [8, 8] **mapscale** : [ 'deg' | 'm' | 'km' ] Scale of the map coordinates. * 'deg' --> degrees in latitude and longitude * 'm' --> meters for easting and northing * 'km' --> kilometers for easting and northing **plot_yn** : [ 'y' | 'n' ] *'y' to plot on creating an instance *'n' to not plot on creating an instance **title** : string figure title **dpi** : int dots per inch of the resolution. *default* is 300 **font_size** : float size of the font that labels the plot, 2 will be added to this number for the axis labels.
- property map_units
Map units.
- class mtpy.imaging.PlotResPhasePseudoSection(mt_data, **kwargs)[source]
Bases:
PlotBaseProfilePlot a resistivity and phase pseudo section for different components
Need to input one of the following lists:.
- class mtpy.imaging.PlotResidualPTMaps(mt_data_01, mt_data_02, frequencies=array([1.00000000e-03, 1.42510267e-03, 2.03091762e-03, 2.89426612e-03, 4.12462638e-03, 5.87801607e-03, 8.37677640e-03, 1.19377664e-02, 1.70125428e-02, 2.42446202e-02, 3.45510729e-02, 4.92388263e-02, 7.01703829e-02, 1.00000000e-01, 1.42510267e-01, 2.03091762e-01, 2.89426612e-01, 4.12462638e-01, 5.87801607e-01, 8.37677640e-01, 1.19377664e+00, 1.70125428e+00, 2.42446202e+00, 3.45510729e+00, 4.92388263e+00, 7.01703829e+00, 1.00000000e+01, 1.42510267e+01, 2.03091762e+01, 2.89426612e+01, 4.12462638e+01, 5.87801607e+01, 8.37677640e+01, 1.19377664e+02, 1.70125428e+02, 2.42446202e+02, 3.45510729e+02, 4.92388263e+02, 7.01703829e+02, 1.00000000e+03]), **kwargs)[source]
Bases:
PlotBaseThis 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.
- Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath1 = r"/home/EDIfiles1" >>> edilist1 = [os.path.join(edipath1,edi) for edi in os.listdir(edipath1) >>> ... if edi.find('.edi')>0] >>> edipath2 = r"/home/EDIfiles2" >>> edilist2 = [os.path.join(edipath2,edi) for edi in os.listdir(edipath2) >>> ... if edi.find('.edi')>0] >>> # color by phimin with a range of 0-5 deg >>> ptmap = mtplot.plot_residual_pt_maps(edilist1, edilist2, freqspot=10, >>> ... ellipse_dict={'size':1, >>> ... 'range':(0,5)}) >>> >>> # >>> #---add an image--- >>> ptmap.image_file = r"/home/Maps/Basemap.jpg" >>> ptmap.image_extent = (0,10,0,10) >>> ptmap.redraw_plot() >>> # >>> #---Save the plot--- >>> ptmap.save_plot(r"/home/EDIfiles",file_format='pdf') >>> 'Saved figure to /home/EDIfile/PTMaps/PTmap_phimin_10.0_Hz.pdf'
- Example:
>>> #change the axis label and grid color >>> ptmap.ax.set_xlabel('Latitude (deg)') >>> ptmap.ax.grid(which='major', color=(.5,1,0)) >>> ptmap.update_plot()
- Example:
>>> # plot seismic hypocenters from a file >>> lat, lon, depth = np.loadtxt(r"/home/seismic_hypocenter.txt") >>> ptmap.ax.scatter(lon, lat, marker='o')
- property map_scale
Map scale.
- property rotation_angle
Rotation angle.
- class mtpy.imaging.PlotResidualPTPseudoSection(mt_data_01, mt_data_02, frequencies=array([1.00000000e-03, 1.42510267e-03, 2.03091762e-03, 2.89426612e-03, 4.12462638e-03, 5.87801607e-03, 8.37677640e-03, 1.19377664e-02, 1.70125428e-02, 2.42446202e-02, 3.45510729e-02, 4.92388263e-02, 7.01703829e-02, 1.00000000e-01, 1.42510267e-01, 2.03091762e-01, 2.89426612e-01, 4.12462638e-01, 5.87801607e-01, 8.37677640e-01, 1.19377664e+00, 1.70125428e+00, 2.42446202e+00, 3.45510729e+00, 4.92388263e+00, 7.01703829e+00, 1.00000000e+01, 1.42510267e+01, 2.03091762e+01, 2.89426612e+01, 4.12462638e+01, 5.87801607e+01, 8.37677640e+01, 1.19377664e+02, 1.70125428e+02, 2.42446202e+02, 3.45510729e+02, 4.92388263e+02, 7.01703829e+02, 1.00000000e+03]), **kwargs)[source]
Bases:
PlotBaseProfileThis 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.
To get a list of .edi files that you want to plot –> :Example:
>>> import mtpy.imaging.mtplot as mtplot >>> import os >>> edipath1 = r"/home/EDIfiles1" >>> edilist1 = [os.path.join(edipath1,edi) for edi in os.listdir(edipath1) >>> ... if edi.find('.edi')>0] >>> edipath2 = r"/home/EDIfiles2" >>> edilist2 = [os.path.join(edipath2,edi) for edi in os.listdir(edipath2) >>> ... if edi.find('.edi')>0] >>> # color by phimin with a range of 0-5 deg
If you want to plot geometric mean colored from white to orange in a range of 0 to 10 percent you can do it one of two ways–>
1) :Example:
>>> edict = {'range':(0,10), 'cmap':'mt_wh2or', 'colorby':'geometric_mean', 'size':10} >>> pt1 = mtplot.residual_pt_ps(edilist1, edilst2, ellipse_dict=edict)
2) :Example:
>>> pt1 = mtplot.residual_pt_ps(edilist1, edilst2, ellipse_dict=edict, plot_yn='n') >>> pt1.ellipse_colorby = 'geometric_mean' >>> pt1.ellipse_cmap = 'mt_wh2or' >>> pt1.ellipse_range = (0, 10) >>> pt1.ellipse_size = 10 >>> pt1.plot()
If you want to save the plot as a pdf with a generic name –>
- Example:
:: >>> pt1.save_figure(r”/home/PTFigures”, file_format=’pdf’, dpi=300) File saved to ‘/home/PTFigures/PTPseudoSection.pdf’
- property rotation_angle
Rotation angle.
- class mtpy.imaging.PlotStations(geo_df, **kwargs)[source]
Bases:
PlotBasePlot station locations in map view.
Can set x_limits and y_limits to zoom in on a specific area. or set image_extent to plot an image in the background. or set pad to set the padding around the stations.
Uses contextily to get the basemap. See https://contextily.readthedocs.io/en/latest/index.html for more information about options.
- class mtpy.imaging.PlotStrike(mt_data, **kwargs)[source]
Bases:
PlotBase- 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.
- param fs:
font size for labels of plotting. Default is 10
- param rot_z:
angle of rotation clockwise positive. Default is 0
- param period_tolerance:
float Tolerance level to match periods from different edi files. Default is 0.05
- param text_pad:
padding of the angle label at the bottom of each polar diagram. Default is 1.65
- param text_size:
font size
- param plot_range:
[ ‘data’ | (period_min,period_max) ] period range to estimate the strike angle. Options are:
- ‘data’ for estimating the strike for all periods
in the data.
(pmin,pmax) for period min and period max, input as (log10(pmin),log10(pmax))
- param plot_type:
[ 1 | 2 ] - 1 to plot individual decades in one plot - 2 to plot all period ranges into one polar diagram
for each strike angle estimation
- param plot_tipper:
[ True | False ] - True to plot the tipper strike - False to not plot tipper strike
- param pt_error_floor:
Maximum error in degrees that is allowed to estimate strike. Default is None allowing all estimates to be used.
- param fold:
[ True | False ] * True to plot only from 0 to 180 * False to plot from 0 to 360
- param plot_orthogonal:
[ True | False] * True to plot the orthogonal strike directions * False to not
- param color:
[ True | False ] * True to plot shade colors * False to plot all in one color
- param color_inv:
color of invariants plots
- param color_pt:
color of phase tensor plots
- param color_tip:
color of tipper plots
- param ring_spacing:
spacing of rings in polar plots
- param ring_limits:
(min count, max count) set each plot have these limits
- param plot_orientation:
[ ‘h’ | ‘v’ ] horizontal or vertical plots
- Example:
- )
>>> #---Turn on Tipper >>> strike.plot_tipper = True >>> #---Plot only main directions >>> strike.plot_orthogonal = False >>> # Redraw plot >>> strike.redraw_plot() >>> # plot only from 0-180 >>> strike.fold = True >>> strike.redraw_plot() >>> #---save the plot--- >>> strike.save_plot(r"/home/Figures")
- get_plot_array(estimate, period_range=None)[source]
Get a plot array that has the min and max angles.
- make_strike_df()[source]
Make strike array
Note
Polar plots assume the azimuth is an angle measured counterclockwise positive from x = 0. Therefore all angles are calculated as 90 - angle to make them conform to the polar plot convention..
- property rotation_angle
Rotation angle.