ImageDiff
ImageDiff
tests compare images created by postprocessing of simulations. This is usually generated by a Python postprocessing script, but it would support images natively generated by any application.
ImageDiff
uses matplotlib.pyplot.imread
in the backend to load the images, so the image format for an ImageDiff
test should be supported by this reader.
Options
Test configuration options are added to the tests
file.
imagediff
: A list of files to compare against the goldallowed
: Minimum acceptable similarity (structural similarity index) between the images, defaults to 0.98allowed_linux
: Similarity cutoff used for linux machines, if not provided 'allowed' is usedallowed_darwin
: Similarity cutoff used for Mac OS (Darwin) machines, if not provided 'allowed' is used
Other test commands & restrictions may be found in the TestHarness documentation.
Example test configuration in the MOOSE test suite
In this example, the ImageDiff
tester is used to check that the plots of the spatial distributions of temperature in the simulation, output to CSV
then plotted by a python script, match reference images.
[Tests]
issues = '#18791'
design = 'modules/heat_conduction/tutorials/introduction/index.md'
[heat_conduction_tutorial]
requirement = 'The system shall run a series of basic problems for thermal
transport in a solid '
[therm_step01]
type = Exodiff
input = therm_step01.i
exodiff = therm_step01_out.e
detail = 'with a conduction term and no boundary conditions, '
[]
[therm_step02]
type = Exodiff
input = therm_step02.i
exodiff = therm_step02_out.e
detail = 'with Dirichlet boundary conditions, '
[]
[therm_step02a]
type = CSVDiff
input = therm_step02a.i
csvdiff = therm_step02a_out_t_sampler_0006.csv
detail = 'outputting the temperature solution along a line, '
[]
[therm_step03]
prereq = heat_conduction_tutorial/therm_step02a
type = CSVDiff
input = therm_step03.i
csvdiff = therm_step03_out_t_sampler_0006.csv
detail = 'adding a time-derivative term, '
[]
[therm_step03a]
prereq = heat_conduction_tutorial/therm_step03
type = CSVDiff
input = therm_step03a.i
csvdiff = therm_step03a_out_t_sampler_0006.csv
detail = 'adding a volumetric heating term, '
[]
[therm_soln_compare]
prereq = heat_conduction_tutorial/therm_step03a
type = ImageDiff
command = 'therm_soln_compare.py'
imagediff = 'therm_soln_compare.png'
required_python_packages = 'pandas matplotlib'
detail = 'and plotting a comparison of the results.'
[]
[]
[]
(modules/heat_conduction/tutorials/introduction/tests)