RectilinearMesh2D

digraph inheritancefab15836cf { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Mesh" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Abstract Base Class"]; "myObject" -> "Mesh" [arrowsize=0.5,style="setlinewidth(0.5)"]; "RectilinearMesh2D" [URL="#geobipy.src.classes.mesh.RectilinearMesh2D.RectilinearMesh2D",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class defining a 2D rectilinear mesh with cell centres and edges."]; "Mesh" -> "RectilinearMesh2D" [arrowsize=0.5,style="setlinewidth(0.5)"]; "myObject" [URL="../core/myObject.html#geobipy.src.classes.core.myObject.myObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "ABC" -> "myObject" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

@RectilinearMesh2D_Class Module describing a 2D Rectilinear Mesh class with x and y axes specified

class geobipy.src.classes.mesh.RectilinearMesh2D.RectilinearMesh2D(x=None, y=None, **kwargs)

Class defining a 2D rectilinear mesh with cell centres and edges.

Contains a simple 2D mesh with cell edges, widths, and centre locations. There are two ways of instantiating the RectilinearMesh2D. The first is by specifying the x and y cell centres or edges. In this case, the abscissa is the standard x axis, and y is the ordinate. The z co-ordinates are None. The second is by specifyin the x, y, and z cell centres or edges. In this case, The mesh is a 2D plane with the ordinate parallel to z, and the “horizontal” locations have co-ordinates (x, y). This allows you to, for example, create a vertical 2D mesh that is not parallel to either the x or y axis, like a typical line of data. If x, y, and z are specified, plots can be made against distance which calculated cumulatively between points.

RectilinearMesh2D([x_centres or x_edges], [y_centres or y_edges], [z_centres or z_edges])

Parameters:
  • x (geobipy.RectilinearMesh1D, optional) – text

  • y (float, optional) – text

  • z (geobipy.RectilinearMesh1D, optional) – text

  • relative_to (geobipy.RectilinearMesh1D, optional) – text

  • x_centres (geobipy.StatArray, optional) – The locations of the centre of each cell in the “x” direction. Only x_centres or x_edges can be given.

  • x_edges (geobipy.StatArray, optional) – The locations of the edges of each cell, including the outermost edges, in the “x” direction. Only x_centres or x_edges can be given.

  • y_centres (geobipy.StatArray, optional) – The locations of the centre of each cell in the “y” direction. Only y_centres or y_edges can be given.

  • y_edges (geobipy.StatArray, optional) – The locations of the edges of each cell, including the outermost edges, in the “y” direction. Only y_centres or y_edges can be given.

  • z_centres (geobipy.StatArray, optional) – The locations of the centre of each cell in the “z” direction. Only z_centres or z_edges can be given.

  • z_edges (geobipy.StatArray, optional) – The locations of the edges of each cell, including the outermost edges, in the “z” direction. Only z_centres or z_edges can be given.

  • [x (float, optional) – See geobipy.RectilinearMesh1D for edgesMin description.

  • y – See geobipy.RectilinearMesh1D for edgesMin description.

  • z]edgesMin (float, optional) – See geobipy.RectilinearMesh1D for edgesMin description.

  • [x – See geobipy.RectilinearMesh1D for edgesMax description.

  • y – See geobipy.RectilinearMesh1D for edgesMax description.

  • z]edgesMax (float, optional) – See geobipy.RectilinearMesh1D for edgesMax description.

  • [x – See geobipy.RectilinearMesh1D for log description.

  • y – See geobipy.RectilinearMesh1D for log description.

  • z]log ('e' or float, optional) – See geobipy.RectilinearMesh1D for log description.

  • [x – See geobipy.RectilinearMesh1D for relative_to description.

  • y – See geobipy.RectilinearMesh1D for relative_to description.

  • z]relative_to (float, optional) – See geobipy.RectilinearMesh1D for relative_to description.

Returns:

out – The 2D mesh.

Return type:

RectilinearMesh2D

cellIndex(values, axis, clip=False, trim=False)

Return the cell indices of values along axis.

Parameters:
  • values (scalar or array_like) – Locations to obtain the cell index for

  • axis (int) – Axis along which to obtain indices

  • clip (bool) – A negative index which would normally wrap will clip to 0 instead.

  • trim (bool) – Do not include out of axis indices. Negates clip, since they wont be included in the output.

Returns:

out – indices for the locations along the axis

Return type:

ints

cellIndices(x, y=None, clip=False, trim=False)

Return the cell indices in x and z for two floats.

Parameters:
  • x (scalar or array_like) – x location

  • y (scalar or array_like) – y location (or z location if instantiated with 3 co-ordinates)

  • clip (bool) – A negative index which would normally wrap will clip to 0 instead.

  • trim (bool) – Do not include out of axis indices. Negates clip, since they wont be included in the output.

Returns:

out – indices for the locations along [axis0, axis1]

Return type:

ints

centres(axis=0)

Ravelled cell centres

Returns:

out – ravelled cell centre locations.

Return type:

array_like

createHdf(parent, name, withPosterior=True, add_axis=None, fillvalue=None, upcast=True)

Create the hdf group metadata in file parent: HDF object to create a group inside myName: Name of the group

property distance

The distance along the top of the mesh using the x and y co-ordinates.

edges(axis)

Gets the cell edges in the given dimension

hasSameSize(other)

Determines if the meshes have the same dimension sizes

in_bounds(x, y)

Return whether values are inside the cell edges

Parameters:

values (array_like) – Check if these are inside left <= values < right.

Returns:

out – Are the values inside.

Return type:

bools

intervalStatistic(arr, intervals, axis=0, statistic='mean')

Compute a statistic of the array between the intervals given along dimension dim.

Parameters:
  • arr (array_like) – 2D array to take the mean over the given intervals

  • intervals (array_like) – A new set of mesh edges. The mean is computed between each two edges in the array.

  • axis (int, optional) – Which axis to take the mean

  • statistic (string or callable, optional) –

    The statistic to compute (default is ‘mean’).

    The following statistics are available:

    • ’mean’ : compute the mean of values for points within each bin. Empty bins will be represented by NaN.

    • ’median’ : compute the median of values for points within each bin. Empty bins will be represented by NaN.

    • ’count’ : compute the count of points within each bin. This is identical to an unweighted histogram. values array is not referenced.

    • ’sum’ : compute the sum of values for points within each bin. This is identical to a weighted histogram.

    • ’min’ : compute the minimum of values for points within each bin. Empty bins will be represented by NaN.

    • ’max’ : compute the maximum of values for point within each bin. Empty bins will be represented by NaN.

    • function : a user-defined function which takes a 1D array of values, and outputs a single numerical statistic. This function will be called on the values in each bin. Empty bins will be represented by function([]), or NaN if this returns an error.

See also

scipy.stats.binned_statistic

for more information

mask_cells(axis=None, x_distance=None, y_distance=None, values=None)

Mask cells by a distance.

If the edges of the cell are further than distance away, extra cells are inserted such that the cell’s new edges are at distance away from the centre.

Parameters:
  • xAxis (array_like) – Alternative axis to use for masking. Must have size self.x.nEdges

  • x_distance (float, optional) – Mask along the x axis using this distance. Defaults to None.

  • y_distance (float, optional) – Mask along the y axis using this distance. Defaults to None.

  • values (array_like, optional.) – If given, values will be remapped to the masked mesh. Has shape (y.nCells, x.nCells)

Returns:

  • out (RectilinearMesh2D) – Masked mesh

  • x_indices (ints, optional) – Location of the original centres in the expanded mesh along the x axis.

  • y_indices (ints, optional) – Location of the original centres in the expanded mesh along the y axis.

  • out_values (array_like, optional) – If values is given, values will be remapped to the masked mesh.

property nCells

The number of cells in the mesh.

Returns:

out – Number of cells

Return type:

int

property nNodes

The number of nodes in the mesh.

Returns:

out – Number of nodes

Return type:

int

property nodes

Ravelled cell nodes

Returns:

out – ravelled cell node locations.

Return type:

array_like

pcolor(values, axis=None, yAxis='absolute', **kwargs)

Create a pseudocolour plot of a 2D array using the mesh.

Parameters:
  • values (array_like or StatArray) – A 2D array of colour values.

  • xAxis (str) – If xAxis is ‘x’, the horizontal xAxis uses self.x If xAxis is ‘y’, the horizontal xAxis uses self.y If xAxis is ‘r’, the horizontal xAxis uses cumulative distance along the line

  • zAxis (str) – If zAxis is ‘absolute’ the vertical axis is the relative_to plus z. If zAxis is ‘relative’ the vertical axis is z.

  • alpha (scalar or array_like, optional) – If alpha is scalar, behaves like standard matplotlib alpha and opacity is applied to entire plot If array_like, each pixel is given an individual alpha value.

  • log ('e' or float, optional) – Take the log of the colour to a base. ‘e’ if log = ‘e’, and a number e.g. log = 10. Values in c that are <= 0 are masked.

  • equalize (bool, optional) – Equalize the histogram of the colourmap so that all colours have an equal amount.

  • nbins (int, optional) – Number of bins to use for histogram equalization.

  • xscale (str, optional) – Scale the x axis? e.g. xscale = ‘linear’ or ‘log’

  • yscale (str, optional) – Scale the y axis? e.g. yscale = ‘linear’ or ‘log’.

  • flipX (bool, optional) – Flip the X axis

  • flipY (bool, optional) – Flip the Y axis

  • grid (bool, optional) – Plot the grid

  • noColorbar (bool, optional) – Turn off the colour bar, useful if multiple plotting plotting routines are used on the same figure.

  • trim (bool, optional) – Set the x and y limits to the first and last non zero values along each axis.

Returns:

matplotlib .Axes

Return type:

ax

See also

matplotlib.pyplot.pcolormesh

For additional keyword arguments you may use.

plot_grid(**kwargs)

Plot the mesh grid lines.

Parameters:

xAxis (str) – If xAxis is ‘x’, the horizontal axis uses self.x If xAxis is ‘y’, the horizontal axis uses self.y If xAxis is ‘r’, the horizontal axis uses sqrt(self.x^2 + self.y^2)

plot_relative_to(axis=0, **kwargs)

Plot the relative_to of the mesh as a line.

ravelIndices(ixy, order='C')

Return a global index into a 1D array given the two cell indices in x and z.

Parameters:

ixy (tuple of array_like) – A tuple of integer arrays, one array for each dimension.

Returns:

out – Global index.

Return type:

int

property shape

The dimensions of the mesh

Returns:

out – Array of integers

Return type:

array_like

property summary

Display a summary of the 3D Point Cloud

unravelIndex(indices, order='C')

Return a global index into a 1D array given the two cell indices in x and z.

Parameters:

indices (array_like) – An integer array whose elements are indices into the flattened version of an array.

Returns:

unraveled_coords – Each array in the tuple has the same shape as the self.shape.

Return type:

tuple of ndarray

writeHdf(parent, name, withPosterior=True, index=None)

Write the StatArray to an HDF object parent: Upper hdf file or group myName: object hdf name. Assumes createHdf has already been called create: optionally create the data set as well before writing

property x_centres

Creates an array suitable for plt.pcolormesh for the abscissa.

Parameters:

xAxis (str) – If xAxis is ‘x’, the horizontal xAxis uses self.x If xAxis is ‘y’, the horizontal xAxis uses self.y If xAxis is ‘r’, the horizontal xAxis uses cumulative distance along the line.

property x_edges

Creates an array suitable for plt.pcolormesh for the ordinate

property y_centres

Creates an array suitable for plt.pcolormesh for the abscissa.

Parameters:

xAxis (str) – If xAxis is ‘x’, the horizontal xAxis uses self.x If xAxis is ‘y’, the horizontal xAxis uses self.y If xAxis is ‘r’, the horizontal xAxis uses cumulative distance along the line.

property y_edges

Creates an array suitable for plt.pcolormesh for the ordinate