mmt_dipole_cuboid_inversion.tools.plot
#
Module Contents#
Functions#
|
Generates multiple arrays with grain geometry properties and generates them |
|
Plots the grain boundaries viewed from a z-axis bird eye perspective |
|
Plots the magnetization of grains with colorscale on a Matplotlib axis |
|
Plots the original scan field data |
|
Plots the inverted field calculated with the Dipole class |
|
Plots the residual from the inversion of the field |
|
|
|
Generates a Matplotlib collection of cuboids from their center locations |
|
Shade color using normal vectors given by normals. |
- mmt_dipole_cuboid_inversion.tools.plot.set_grain_geometries(DipoleIns, spatial_scaling=1.0, tol=1e-07)#
Generates multiple arrays with grain geometry properties and generates them as variables in the DipoleIns instance. Run this function before performing any plotting.
The variables generated are:
- cuboid_idxs
Indices of the cuboids in a 1D np.int32 array
- cuboid_idxs_unique
Unique indices
- cuboid_idxs_counts
Count of the indices (same length as cuboid_idxs_unique)
- grain_vertices
Vertices of the grain cuboids as viewed from the top
- grain_geoms
Shapely polygons obtained by merging grain_vertices of cuboids belonging to a single grain
- grain_geoms_coords
Coordinates of the merged shapely polygons
- grain_centroids
Dictionary with the index of the grains as keys and a 2-array with the coordinates of the centroid of the merged shapely polygon
- spatial_scaling
Scaling factor for the coordinates. This same scaling is applied to the limits of the scan data and inversion results
- mmt_dipole_cuboid_inversion.tools.plot.plot_grain_boundaries(DipoleIns, ax, grain_labels=True, boundaries_args=dict(ec=(0, 0, 0, 1)), labels_args=dict(ha='center', va='center'), tol=1e-07)#
Plots the grain boundaries viewed from a z-axis bird eye perspective
- Parameters:
- DipoleIns
An instance of the Dipole class
- ax
Matplotlib axis
- boundaries_args
Arguments to the PolyCollection handling the boundary drawings
- labels_args
Arguments to the matplotlib text objects handling the grain labels
- tol
Tolerance used to enable merging cuboids of one grain
Notes
Requires set_grain_geometries to be applied to DipoleIns beforehand
- mmt_dipole_cuboid_inversion.tools.plot.plot_magnetization_on_grains(DipoleIns, ax, mag_log_scale=True, grain_plot_args=dict(cmap='coolwarm'), grain_labels=True, labels_args=dict(ha='center', va='center'), tol=1e-07)#
Plots the magnetization of grains with colorscale on a Matplotlib axis
- Parameters:
- DipoleIns
An instance of the Dipole class
- ax
Matplotlib axis
- mag_log_scale
Color grains using a log scale of the magnetization
- grain_plot_args
Arguments to the matplotlib PolyCollection handling the plotting of the grains. For example, set the colormap and clim (color limits) of the grains
- grain_labels
Draw index labels at the centroid of the grains
- labels_args
Arguments to the matplotlib text objects handling the grain labels
- tol
Tolerance used to enable merging cuboids of one grain
Notes
Requires set_grain_geometries to be applied to DipoleIns beforehand
- mmt_dipole_cuboid_inversion.tools.plot.plot_scan_field(DipoleIns, ax, scale_field=None, imshow_args=dict(cmap='magma'))#
Plots the original scan field data
- Parameters:
- DipoleIns
An instance of the Dipole class
- ax
Matplotlib axis
- scale_field
If specified, the field is scaled by this value
- imshow_args
Extra arguments passed to the imshow plot
- Returns:
- im
The imshow plot object
- mmt_dipole_cuboid_inversion.tools.plot.plot_inversion_field(DipoleIns, ax, scale_field=None, imshow_args=dict(cmap='magma'))#
Plots the inverted field calculated with the Dipole class
- Parameters:
- DipoleIns
An instance of the Dipole class
- ax
Matplotlib axis
- scale_field
If specified the field is scaled by this value
- imshow_args
Extra arguments passed to the imshow plot
- Returns:
- im
The imshow plot object
- mmt_dipole_cuboid_inversion.tools.plot.plot_residual(DipoleIns, ax, scale_residual=None, imshow_args=dict(cmap='magma'))#
Plots the residual from the inversion of the field
- Parameters:
- DipoleIns
An instance of the Dipole class
- ax
Matplotlib axis
- scale_residual
If specified the residual is scaled by this value
- imshow_args
Extra arguments passed to the imshow plot
- Returns:
- im
The imshow plot object
- mmt_dipole_cuboid_inversion.tools.plot._cuboids(o, size=(1, 1, 1))#
- mmt_dipole_cuboid_inversion.tools.plot.plotCubeAt(positions, sizes=None, colors=None, lightsource=None, **kwargs)#
Generates a Matplotlib collection of cuboids from their center locations
- Parameters:
- positions
Numpy array with shape (N,3) with the x,y,z centers of the cuboids
- sizes
Numpy array with shape (N,3) with the lx,ly,lz side lengths of the cuboids
- colors
Numpy array of size (N, 3) with the RGBA colors for every cuboid
- lightsource
Can be passed as True or as an instance of a Matplotlib’s LightSource
- Returns:
- Poly3DCollection of cuboids
- mmt_dipole_cuboid_inversion.tools.plot._shade_colors(color, normals, lightsource=None)#
Shade color using normal vectors given by normals. color can also be an array of the same length as normals.