1. Plotting classes

1.1. MTplot class

class MTfit.plot.plot_classes.MTplot(MTs, plot_type='beachball', stations={}, plot=True, label=False, save_file='', save_dpi=200, *args, **kwargs)[source]

MTplot class - handles plotting of the moment tensor using different plot_classes

This object acts as a handle round a matplotlib figure, handling the moment tensors and creating the plot classes for axes.

Initialises the MTplot object.

Multiple plots (subplots) are handled using the matplotlib GridSpec - to create multiple plots, use nested lists for the MTs, with the inner lists corresponding to each column and the outer each row, e.g.:

[[x,y=1,1;x,y=2,1],[x,y=1,2;x,y=2,2]]

The total number of columns is given by the max number of points in the nested list. Lists with fewer points will have the last plot stretched to cover the remaining columns. Setting None in the list will stretch the plot to it's left to cover the columns.

The args and kwargs, which are passed through to the plot_class object can also be nested in this way. Additionally, if the parameters are equal to the number of columns, or number of rows, the same values are used for each plot in the corresponding column or row. If the dimension of the multiplot is square, the parameters are assumed to correspond to the rows.

Args
MTs: Moment tensor samples for creating MTData object, such as a numpy array of MT 6 vectors (see MTData initialisation for different types, and MTplot docstring for handling multiple plots
Keyword Args
plot_type: str - plot type selection (Default is 'beachball') stations: dict - Dictionary of stations, containing keys: 'names','azimuth','takeoff_angle' and 'polarity' or an empty dict (default) plot: bool - flag to actually plot and show the figure label: bool - flag to show axis labels if multiple plots are being shown save_file: string - filename to save plot to (if set) save_dpi: int - output dpi for file save args: passed through to plot_class initialisation kwargs: passed through to plot_class initialisation
ax_labels(show=True)[source]

Set or update axis label to axis corners.

plot(*args, **kwargs)[source]

Plots the figure and shows it.

Calls the plot functions for each plot_class in the multiplot.

1.2. MTData class

class MTfit.plot.plot_classes.MTData(MTs, probability=[], c=False, **kwargs)[source]

MTData object manages the moment tensors.

Additionally it enables conversion between different parameterisations and calculation of several statistics.

This is used by all of the plot classes for handling the moment tensor, and is transparent to converting and accessing the moment tensors, as it behaves like a numpy array (e.g. indexing and properties like shape are given for the moment tensor).

The MTData object also stores the probability, and is used for calculating the orientation mean.

MTData initialisation

Parameters corresponding to the moment tensor samples can be set as kwargs. These parameters include:

T, N, P, E, u, v, tau, k, gamma, delta, kappa, h, sigma, strike1, dip1, rake1, strike2, dip2, rake2, N1, N2
Args
MTs: numpy array of moment tensor six vectors with shape (6,n).
Alternatively, the input can be a dictionary from the MTfit output.
Keyword Args
probability: list or numpy array of probabilities - should be
the same length as the number of moment tensors, or empty (Default is [])
**kwargs: Attributes that correspond to converted parameters
of the moment tensor, as described above
cluster_normals()[source]

Cluster the normals.

This is a very simplistic algorithm that clusters the normals by dividing them into two groups with the shortest distance between them.

N.B. This depends on the initial values given, so if the normals are not well clustered, or the initial normals chosen are outliers, the results will not be a good clustering.

Consequently, only use this approach for well clustered fault plane normals (in at least one normal direction). The more tightly clustered normals are set to clustered_N1.

Returns
numpy array, numpy array, numpy array, numpy array: tuple of numpy arrays, clustered_N1, clustered_N2, clustered_rake1,clustered_rake2
get_max_probability(single=False)[source]

Returns an MTData object containing the maximum probability solutions

Keyword Args
single: bool - flag to return only one moment tensor (the first maximum probability moment tensor)
Returns:New MTData object with max probability MT samples.
Return type:MTData
get_mean()[source]

Calculates the mean moment tensor and variance of the moment tensor samples

Returns:tuple of numpy arrays for the mean moment tensor six vector and the moment tensor six vector covariance.
Return type:numpy array,numpy array
get_mean_orientation()[source]

Get the mean orientation from the clustered normals and rake parameters using the more tightly clustered parameters.

This also calculates the variance of the rake distributions and covariance of the clustered normals (using the probability if it is set)

Returns
numpy array, numpy array, numpy array: tuple of the mean strike dip and rake of the fault planes.
get_unique_McMC()[source]

Gets the unique McMC samples, with the probability scaled by the number of samples

Returns
MTData: New MTData object with unique MT samples and probabilities corresponding to the moment tensor frequencies.
is_dc()[source]

Returns array of DC values

1.3. _BasePlot class

class MTfit.plot.plot_classes._BasePlot(subplot_spec, fig, MTs, *args, **kwargs)[source]

This is the base class for MT plotting

This class handles plotting to a single axis including projection and conversion of the moment tensor, setting the figure background etc.

Should be subclassed

BasePlot initialisation

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)[source]

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)[source]

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)[source]

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)[source]

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)[source]

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)[source]

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)[source]

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)[source]

3d text plot (see _text_plot documentation)

__call__(*args, **kwargs)[source]

X(*args,**kwargs)=X.__call__(*args,**kwargs)

Plots the result

__init__(subplot_spec, fig, MTs, *args, **kwargs)[source]

BasePlot initialisation

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
__weakref__

list of weak references to the object (if defined)

_ax_plot(*args, **kwargs)[source]

Main plotting function

Plots the axis

_background(handle)[source]

Create the plot background

_convert()[source]

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Convert the moment tensors as required

_eigenvector_matrix(e1, e2, e3)[source]

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)[source]

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)[source]

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_surf_plot(x, y, z, c, zorder=0, **kwargs)[source]

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)[source]

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)[source]

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)

1.4. _FocalSpherePlot class

class MTfit.plot.plot_classes._FocalSpherePlot(subplot_spec, fig, MTs, stations={}, phase='P', *args, **kwargs)[source]

Base class for plotting on a focal sphere

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines stations: dict - station dict containing keys: 'names','azimuth','takeoff_angle' and 'polarity' station_distribution: list - list of station dictionaries corresponding to a location PDF distribution show_zero_polarity: bool - flag to show zero polarity receivers show_stations: bool - flag to show stations when station_distribution present station_markersize: float - station marker size (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Main plotting function

Plots the axis

_axis_lines(r)[source]

Plots the axis lines through the origin

_background(handle)[source]

Plots the axes background

Args
handle: handle of the plot object (for surface plots)
_boundary_lines(r)[source]

Plots the boundary lines, fault planes, nodal lines and axis lines as selected by the initialisation parameters

Args
r: float - circle radius (depends on the projection and determined in _background())
_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Convert the moment tensors as required

_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)[source]

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)[source]

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)[source]

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))[source]

Get small circle about the pole with opening angle alpha

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_nodal_line(MTs, c, zorder=0, *args, **kwargs)[source]

Plots the nodal line for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the line (larger is higher) args: passed through to the _line_plot call so can set e.g. linewidth kwargs: passed through to the _line_plot call so can set e.g. linewidth
_plot_TNP(MT, c=['w', 'k', 'w'], marker=('*', '*', '*'), markersize=10, zorder=0, *args, **kwargs)[source]

Plots the TNP axes for the given moment tensor

Args
MT: MTData - Moment tensor to plot
Keyword Args
c: tuple - color description for T N P axes (see matplotlib documentation) marker: tuple - marker description for T N P axes (see matplotlib documentation) markersize: float - marker width - squared to give marker area zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)[source]

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)[source]

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(lim=1.4142135623730951, colors=('k', 'w', 'k'), marker=('v', 'o', '^'))[source]

Plots stations on the focal sphere

Keyword Args
lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)[source]

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)

1.5. _AmplitudePlot class

class MTfit.plot.plot_classes._AmplitudePlot(subplot_spec, fig, MTs, stations={}, phase='P', *args, **kwargs)[source]

Amplitude plotting (beachball)

parameter single is set to True, as can only plot one source per axis

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines stations: dict - station dict containing keys: 'names','azimuth','takeoff_angle' and 'polarity' station_distribution: list - list of station dictionaries corresponding to a location PDF distribution show_zero_polarity: bool - flag to show zero polarity receivers show_stations: bool - flag to show stations when station_distribution present station_markersize: float - station marker size (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Projects and plots the amplitude surface

Returns
matplotlib surface object
_axis_lines(r)

Plots the axis lines through the origin

_background(handle)[source]

Sets the colormap to be symmetrical and plots the axes background.

Args
handle: handle of the plot object (for surface plots)
_boundary_lines(r)

Plots the boundary lines, fault planes, nodal lines and axis lines as selected by the initialisation parameters

Args
r: float - circle radius (depends on the projection and determined in _background())
_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Calculate and convert the moment tensor to the amplitude on the focal sphere

Returns
numpy array, numpy array, numpy array, numpy array: tuple of x,y,z and (scaled) c values
_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))

Get small circle about the pole with opening angle alpha

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_nodal_line(MTs, c, zorder=0, *args, **kwargs)

Plots the nodal line for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the line (larger is higher) args: passed through to the _line_plot call so can set e.g. linewidth kwargs: passed through to the _line_plot call so can set e.g. linewidth
_plot_TNP(MT, c=['w', 'k', 'w'], marker=('*', '*', '*'), markersize=10, zorder=0, *args, **kwargs)

Plots the TNP axes for the given moment tensor

Args
MT: MTData - Moment tensor to plot
Keyword Args
c: tuple - color description for T N P axes (see matplotlib documentation) marker: tuple - marker description for T N P axes (see matplotlib documentation) markersize: float - marker width - squared to give marker area zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(lim=1.4142135623730951, colors=('k', 'w', 'k'), marker=('v', 'o', '^'))

Plots stations on the focal sphere

Keyword Args
lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)

1.6. _FaultPlanePlot class

class MTfit.plot.plot_classes._FaultPlanePlot(subplot_spec, fig, MTs, stations={}, probability=[], phase='p', *args, **kwargs)[source]

Plots the fault plane distribution

parameter single is set to False as multiple sources can be plotted per axes

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
probability: numpy array - moment tensor probabilities phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines stations: dict - station dict containing keys: 'names','azimuth','takeoff_angle' and 'polarity' station_distribution: list - list of station dictionaries corresponding to a location PDF distribution show_zero_polarity: bool - flag to show zero polarity receivers show_stations: bool - flag to show stations when station_distribution present station_markersize: float - station marker size (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc show_max_likelihood: bool - show the maximum likelihood solution in the default color show_mean: bool - show the mean orientation source in green (thicker plane is better constrained) color: set color for maximum likelihood fault plane (show_max_likelihood)
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Plots the fault planes/nodal lines/TNP axes with color scaled by the probability values (if set)

Darker colors are more likely

_axis_lines(r)

Plots the axis lines through the origin

_background(handle)[source]

Plots the background (ignoring fault planes, nodal lines and TNP axes)

Args
handle: handle of the plot object (for surface plots)
_boundary_lines(r)

Plots the boundary lines, fault planes, nodal lines and axis lines as selected by the initialisation parameters

Args
r: float - circle radius (depends on the projection and determined in _background())
_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Returns tuple of None as not used to plot the source

_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))

Get small circle about the pole with opening angle alpha

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_nodal_line(MTs, c, zorder=0, *args, **kwargs)

Plots the nodal line for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the line (larger is higher) args: passed through to the _line_plot call so can set e.g. linewidth kwargs: passed through to the _line_plot call so can set e.g. linewidth
_plot_TNP(MT, c=['w', 'k', 'w'], marker=('*', '*', '*'), markersize=10, zorder=0, *args, **kwargs)

Plots the TNP axes for the given moment tensor

Args
MT: MTData - Moment tensor to plot
Keyword Args
c: tuple - color description for T N P axes (see matplotlib documentation) marker: tuple - marker description for T N P axes (see matplotlib documentation) markersize: float - marker width - squared to give marker area zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(lim=1.4142135623730951, colors=('k', 'w', 'k'), marker=('v', 'o', '^'))

Plots stations on the focal sphere

Keyword Args
lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)

1.7. _RiedeselJordanPlot class

class MTfit.plot.plot_classes._RiedeselJordanPlot(subplot_spec, fig, MTs, *args, **kwargs)[source]

Plots the source as a Riedesel-Jordan type plot

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines show_stations: bool - flag to show stations when station_distribution present station_markersize: float - sets the source type marker sizes (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) color: str - matplotlib color for source region fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Plots the sources on the Riedesel-Jordan plot (on the focal sphere)

Returns
None
_axis_lines(r)

Plots the axis lines through the origin

_background(*args)[source]

Plot the axes background ignoring the fault plane, TNP and nodal line flags

_boundary_lines(r)[source]

Plots the boundary lines, and the valid source region with color set by the color flag.

Args
r: float - circle radius (depends on the projection and determined in _background())
_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Converts the moment tensor and calculates the base vectors

Returns tuple of None.

_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))

Get small circle about the pole with opening angle alpha

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_nodal_line(MTs, c, zorder=0, *args, **kwargs)

Plots the nodal line for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the line (larger is higher) args: passed through to the _line_plot call so can set e.g. linewidth kwargs: passed through to the _line_plot call so can set e.g. linewidth
_plot_TNP(MT, c=['w', 'k', 'w'], marker=('*', '*', '*'), markersize=10, zorder=0, *args, **kwargs)

Plots the TNP axes for the given moment tensor

Args
MT: MTData - Moment tensor to plot
Keyword Args
c: tuple - color description for T N P axes (see matplotlib documentation) marker: tuple - marker description for T N P axes (see matplotlib documentation) markersize: float - marker width - squared to give marker area zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(*args, **kwargs)[source]

Plots stations on the focal sphere

Keyword Args
lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)

1.8. _RadiationPlot class

class MTfit.plot.plot_classes._RadiationPlot(subplot_spec, fig, MTs, stations={}, phase='P', *args, **kwargs)[source]

Plot the radiation pattern

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines stations: dict - station dict containing keys: 'names','azimuth','takeoff_angle' and 'polarity' station_distribution: list - list of station dictionaries corresponding to a location PDF distribution show_zero_polarity: bool - flag to show zero polarity receivers show_stations: bool - flag to show stations when station_distribution present station_markersize: float - station marker size (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)

Projects and plots the amplitude surface

Returns
matplotlib surface object
_axis_lines(r)

Plots the axis lines through the origin

_background(handle)

Sets the colormap to be symmetrical and plots the axes background.

Args
handle: handle of the plot object (for surface plots)
_boundary_lines(r)[source]

Only plots the axis lines

_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Scales the x,y,z coordinates by the amplitude

Returns
numpy array, numpy array, numpy array, numpy array: tuple of x,y,z and (scaled) c values
_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))

Get small circle about the pole with opening angle alpha

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_nodal_line(MTs, c, zorder=0, *args, **kwargs)

Plots the nodal line for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the line (larger is higher) args: passed through to the _line_plot call so can set e.g. linewidth kwargs: passed through to the _line_plot call so can set e.g. linewidth
_plot_TNP(MT, c=['w', 'k', 'w'], marker=('*', '*', '*'), markersize=10, zorder=0, *args, **kwargs)

Plots the TNP axes for the given moment tensor

Args
MT: MTData - Moment tensor to plot
Keyword Args
c: tuple - color description for T N P axes (see matplotlib documentation) marker: tuple - marker description for T N P axes (see matplotlib documentation) markersize: float - marker width - squared to give marker area zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(*args, **kwargs)[source]

Doesn't plot any stations

_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)

1.9. _HudsonPlot class

class MTfit.plot.plot_classes._HudsonPlot(subplot_spec, fig, MTs, projection='uv', probability=[], **kwargs)[source]

Hudson plot class

Plots the source on the u-v or tau-k Hudson plot

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
projection: str - select the projection type from uv or tauk [default is uv] probability: numpy array - moment tensor probabilities colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc grid_lines: bool - show the interior grid lines marginalised: bool - marginalise the PDF (defailt is True) color: set marker color type_label: bool - show the label of the different types hex_bin: bool - use the hex-bin histogram type (slightly smoother) bins: int/array/list of arrays - bins for numpy histogram call
_2d_hist(data_x, data_y, c=None, bins=10, nx_hex=100, hex_extent=[-1, 1, -1, 1], **kwargs)

2D histogram

Args
data_x: numpy array - x data to bin data_y: numpy array - y data to bin
Keyword Args
bins: int - number of bins to use c: numpy array - weights to use for each sample in the histogram nx_hex: number of hexes to use when hex_bin is True hex_extent: minimum extent of the hexagon region hex_bin: use the matplotlib hexbin function to histogram (2D only)
Returns
matplotlib histogram/hexbin object
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Plots the sources on the hudson plot (as a 2D histogram of the PDF if the probability values are set)

Returns
matplotlib scatter/2dhist object
_background(handle)[source]

Sets limits and plots the axes background

Args
matplotlib surface object
_boundary_lines(*args)[source]

Get and plot boundary lines

Also plots type labels if type_label flag set on initialisation

_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Converts the moment tensors to the chosen source parameters

Returns
numpy array, numpy array, 0, numpy array: tuple of hudson parameters, 0 and probability
_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_hist(data, c=None, bins=10, **kwargs)

1D histogram

Args
data: numpy array - data to bin
Keyword Args
bins: int - number of bins to use c: numpy array - weights to use for each sample in the histogram
Returns
matplotlib histogram object
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_max_2d_for_hist(data_x, data_y, c, bins)
Get Max value for 2d hist (silhouette type plot rather than marginalised
(see Pugh, D J, 2015. Bayesian Source Inversion of Microseismic Events, Thesis))
Returns
numpy array, numpy array, numpy array: tuple of numpy arrays describing the silhouette coordinates and maximum probability values for each point.
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
_tk_boundary_lines()[source]

Get and plot boundary lines for the tau-k plot

Also plots type labels if type_label flag set on initialisation

_uv_boundary_lines()[source]

Get and plot boundary lines for the u-v plot

Also plots type labels if type_label flag set on initialisation

plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)

1.10. _LunePlot class

class MTfit.plot.plot_classes._LunePlot(subplot_spec, fig, MTs, stations={}, phase='P', *args, **kwargs)[source]

Plots the source on the fundamental eigenvalue lune

Can be either a histogram or scatter plot.

parameter single is set to False as multiple sources can be plotted per axes

Args
subplot_spec: matplotlib subplot spec fig: matplotlib figure MTs: moment tensor samples (see MTData initialisation docstring for formats)
Keyword Args
phase: str - phase to plot (default='p') lower: bool - project lower hemisphere (ie. downward hemisphere) full_sphere: bool - plot the full sphere fault_plane: bool - plot the fault planes nodal_line: bool - plot the nodal lines stations: dict - station dict containing keys: 'names','azimuth','takeoff_angle' and 'polarity' station_distribution: list - list of station dictionaries corresponding to a location PDF distribution show_zero_polarity: bool - flag to show zero polarity receivers show_stations: bool - flag to show stations when station_distribution present station_markersize: float - station marker size (squared to get area) station_colors: tuple - tuple of colors for negative, no, and positive polarity TNP: bool - show the TNP axes on the plot colormap: str - matplotlib colormap selection (using matplotlib.cm.get_cmap()) fontsize: int - fontsize for text linewidth: float - base linewidth (sometimes thinner or thicker values are used, but relative to this parameter) text: bool - flag to show or hide text on the plot axis_lines: bool - flag to show or hide axis lines on the plot resolution: int - resolution for spherical sampling etc
_2d_hist(data_g, data_d, c=None, bins=10, nx_hex=100, hex_extent=[-0.5, 0.5, -1.5, 1.5], **kwargs)[source]

2D histogram - handles gamma delta conversion and plotting

Args
data_g: numpy array - g data to bin data_d: numpy array - d data to bin
Keyword Args
bins: int - number of bins to use c: numpy array - weights to use for each sample in the histogram nx_hex: number of hexes to use when hex_bin is True hex_extent: minimum extent of the hexagon region hex_bin: use the matplotlib hexbin function to histogram (2D only)
Returns
matplotlib histogram/hexbin object
_2d_line_plot(x, y, c, linestyle, linewidth, zorder=0, **kwargs)

2d line plot (see _line_plot documentation)

_2d_scatter_plot(x, y, c, marker='.', markersize=10, zorder=0, **kwargs)

2d scatter plot (see _scatter_plot documentation)

_2d_surf_plot(x, y, c, zorder=0, **kwargs)

2d surface plot (see _surf_plot documentation)

_2d_text(x, y, text, fontsize, zorder=2, **kwargs)

2d text plot (see _text_plot documentation)

_3d_line_plot(x, y, z, c, linestyle, linewidth, zorder=0, **kwargs)

3d line plot (see _line_plot documentation)

_3d_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

3d scatter plot (see _scatter_plot documentation)

_3d_surf_plot(x, y, z, c, zorder=0, **kwargs)

3d surface plot (see _surf_plot documentation)

_3d_text(x, y, z, text, fontsize, zorder=2, **kwargs)

3d text plot (see _text_plot documentation)

_ax_plot(*args, **kwargs)[source]

Plots the sources on the lune (as a 2D histogram of the PDF if the probability values are set)

Returns
matplotlib scatter/2dhist object
_axis_lines(r)

Plots the axis lines through the origin

_background(handle)

Plots the axes background

Args
handle: handle of the plot object (for surface plots)
_boundary_lines(*args)[source]

Get and plot boundary lines

Also plots type labels if type_label flag set on initialisation

_convert()

Handles MT conversion to coordinates (setting xdata,ydata,zdata (if required) and cdata attributes)

_convert_mts()[source]

Converts the moment tensors for plotting

Returns
numpy array, numpy array, 0, numpy array: tuple of gamma,delta,0,probability values
_eigenvector_matrix(e1, e2, e3)

create an eigenvector matrix

Args
e1: numpy array/matrix - first eigenvector e2: numpy array/matrix - second eigenvector e3: numpy array/matrix - third eigenvector
Returns
numpy matrix: eigenvector matrix
_fault_plane(MT, c, zorder=0, *args, **kwargs)

Plots the fault planes for a given moment tensor

Args
MT: MTData - Moment tensor to plot c: str - color description (see matplotlib documentation)
Keyword Args
zorder: float - z order for the plane (larger is higher) args: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth kwargs: passed through to the plot_plane (and _line_plot) calls so can set e.g. linewidth
_get_great_circle(v1, v2, az=(0, 6.283185307179586), n=500)

Get the great circle described by the two vectors v1 and v2

Args
v1: numpy matrix/tuple - vector on the great circle v2: numpy matrix/tuple - a different vector on the great circle
Keyword Args
n_quadrants: int - number of quadrants of the great circle to calculate
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_get_nodal_line(T, N, P, E)

Gets the nodal line (values with zero amplitude)

Args
T: numpy matrix - Tension (eigen)vector N: numpy matrix - Neutral (eigen)vector P: numpy matrix - Pressure (eigen)vector E: numpy array - Eigenvalues (E[0]>=E[1]>=E[2])
Returns
numpy array, numpy array, numpy array - tuple of x y z coordinates of the nodal lines
_get_small_circle(pole, alpha, az=(0, 6.283185307179586))[source]

Get and convert a small circle onto the Lune

Args
pole: numpy matrix - pole of the small circle alpha: float - angle of the small circle from the pole
Keyword Args
az: tuple - lower and upper limits of the azimuth to calculate for the small circle
Returns
numpy array, numpy array, numpy array: tuple of coordinates (x,y,z)
_hist(data, c=None, bins=10, **kwargs)

1D histogram

Args
data: numpy array - data to bin
Keyword Args
bins: int - number of bins to use c: numpy array - weights to use for each sample in the histogram
Returns
matplotlib histogram object
_line_plot(x, y, z, c, linestyle='-', linewidth=1, zorder=0, **kwargs)

Call to plot a line (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c value
Keyword Args
linestyle: str - linestyle description (see matplotlib documentation) linewidth: float - line width zorder: float - z index of the surface (positive higher)
_lune_coords(gamma, delta)[source]

Calculates the lune coordinates for a given gamma and delta values

Args
gamma: numpy array/float - gamma values delta: numpy array/float - delta values
Returns
numpy array, numpy array, numpy array: tuple of x, y and z coordinates
_max_2d_for_hist(data_x, data_y, c, bins)
Get Max value for 2d hist (silhouette type plot rather than marginalised
(see Pugh, D J, 2015. Bayesian Source Inversion of Microseismic Events, Thesis))
Returns
numpy array, numpy array, numpy array: tuple of numpy arrays describing the silhouette coordinates and maximum probability values for each point.
_nodal_line(*args, **kwargs)[source]

Pass-through function - nothing plotted

_plot_TNP(*args, **kwargs)[source]

Pass-through function - nothing plotted

_plot_stations(names, azimuth, takeoff_angle, polarity, marker=('v', 'o', '^'), colors=('k', 'w', 'k'), radians=False, lim=1.4142135623730951, zorder=0)

Handles the station plotting on the focal sphere.

If self.text is True then the station names are annotated using radial arrows Args

names: list - list of station names azimuth: numpy array - array of station azimuths takeoff_angle: numpy array - array of station takeoff angles polarity: numpy array - array of station polarities
Keyword Args
radians: bool - flag for station angles in radians [default is False] lim: float - limit of the focal sphere (projection dependent) colors: tuple - tuple of color descriptions for stations with negative, no and positive polarity marker: tuple - tuple of marker descriptions for stations with negative, no and positive polarity
_rotation_matrix(zaxis)

Calculate rotation matrix to rotate the vector zaxis onto the z-axis

Args
zaxis: numpy matrix - vector to be rotated onto the z-axis
Returns
numpy matrix: rotation matrix
_scatter_plot(x, y, z, c, marker='.', markersize=10, zorder=0, **kwargs)

Call to plot scatter (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
marker: str - marker description (see matplotlib documentation) markersize: float - marker width (squared to correspond to markersize parameter) zorder: float - z index of the surface (positive higher)
_stations(*args, **kwargs)[source]

Pass-through function - nothing plotted

_surf_plot(x, y, z, c, zorder=0, **kwargs)

Call to plot a surface (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates c: numpy array/str- c values
Keyword Args
zorder: float - z index of the surface (positive higher)
_text(x, y, z, text, zorder=2, **kwargs)

Call to write text (handles 2 or 3 dimensions as required)

Args
x: numpy array - x coordinates y: numpy array - y coordinates z: numpy array - z coordinates text: str - text value
Keyword Args
zorder: float - z index of the surface (positive higher)
plot(MTs=False, *args, **kwargs)

Plots the result

Keyword Args
MTs: Moment tensors to plot (see MTData initialisation docstring for formats) args: args passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values) kwargs: kwargs passed to the _ax_plot function (e.g. set local parameters to be different from initialisation values)
plot_plane(strike, dip, c, radians=False, zorder=0, *args, **kwargs)

Plot a plane on the focal sphere

Args
strike - strike of the plane dip - dip of the plane c - color description(see matplotlib documentation)
Keyword Args
radians: bool - strike and dip in radians or degrees zorder: float - z order of the plane (larger is on top)