This module contains functions related to mesh verification.
error_stats(fit_seeds, seeds, phases, poly_mesh=None, verif_mask=None)¶
Error statistics for seeds
This function creates a dictionary of error statistics for each of the input distributions in the phases.
fit_seeds (SeedList) – List of seeds of best fit.
seeds (SeedList) – List of seeds.
phases (list) – List of input phase dictionaries.
poly_mesh (PolyMesh) – (optional) Polygonal/polyhedral mesh.
List with the same size and dictionary keywords as phases, but with error statistics dictionaries in each entry.
- Return type
mle_phases(seeds, phases, poly_mesh=None, verif_mask=None)¶
Get maximum likelihood estimators (MLEs) for phases
This function finds distributions in the list of phases and computes the MLE parameters for those distributions. The returned value is a list of phases with the same length and dictionary keywords, except the distributions are replaced with MLE distributions (based on the seeds). Constant values are replaced with the mean of the seed values.
Note that the directional statistics are not used - so the results for orientation angles and matrices are unreliable.
Also note that SciPy currently does not support MLEs for discrete random variables. Any discrete distributions will be given a histogram output.
Directional statistics are not used and as such the results for orientation angles and matrices are unreliable. The only exception is normally distributed orientation angles.
plot_distributions(seeds, phases, dirname='.', ext='png', poly_mesh=None, verif_mask=None)¶
Plot comparison between input and output distributions
This function takes seeds and compares them against the input phases. A polygon mesh can be included for cases where grains are given an area or volume distribution, rather than size/shape/etc.
This function creates both PDF and CDF plots.
seeds (SeedList) – List of seeds to compare.
phases (list) – List of phase dictionaries.
dirname (str) – (optional) Plot output directory. Defaults to
poly_mesh (PolyMesh) – (optional) Polygonal mesh, useful for phases with an area or volume distribution.
none, creates plot files.
plot_volume_fractions(vol_fracs, phases, filename='volume_fractions.png')¶
Plot volume fraction verification
This function creates a bar chart comparing the input and output volume fractions. If the input volume fraction is distributed, the top of the bar will be a curve representing the CDF of the distribution.
seeds_of_best_fit(seeds, phases, pmesh, tmesh)¶
Calculate seed geometries of best fit
This function computes the seeds of best fit for the resultant polygonal and triangular meshes. It calls the the
best_fitfunction of each seed’s geometry, then copies the other seed attributes to create a new
The points on the faces of the grains are used to determine a fit geometry. Points on the exterior of the domain are not used since they would alter the shape of the best fit seed.
List of seeds of best fit.
- Return type
Verify volume fractions
This function computes the volume fractions of each phase in the output mesh. It does so by summing the volumes of the cells in the polygonal mesh.
write_error_stats(errs, phases, filename='error_stats.txt')¶
Write error statistics to file
This function takes previously computed error statistics and writes them to a human-readable text file.
write_mle_phases(inp_phases, out_phases, filename='mles.txt')¶
Write MLE parameters in a table
This function writes out a text file containing the input parameters and maximum likelihood estimators (MLEs) for the outputs.
write_volume_fractions(vol_fracs, phases, filename='volume_fractions.txt')¶
Write volume fractions to a file
Write the volume fractions verification out to a file. The output columns are:
Input relative volume (average, if distributed)
Output relative volume
Input volume fraction (average, if distributed)
Output volume fraction
The first three lines of the output file are headings.