armi.bookkeeping.db.compareDB3 module

Use the generic database class to compare two ARMI databases.

This assumes some intimate knowledge about how the database is structured internally. For instance, it knows that the database is composed of HDF5 data (the attrs of a dataset are used, and h5py Groups are indexed), and it knows how special data is structured within the HDF5 dataset and what the corresponding attributes are used for. Some of this could be easily pulled up to the public interfaces of the Database class, which may allow for cross-version database checking, but there is probably little value in doing so if one is able to convert between versions.

Speaking of conversions, there are some common issues that may arise from comparing against databases that were converted from an old version. The process of reading in the old database values can sometimes lead to more parameters being written out to the new database than were in the original database (set to the parameter’s default value). That means that one generally should not be worried about a converted database having more parameters in it that the one produced directly may not, assuming that the extra converted parameters are the default. Also, especially at the Component level, some of the parameters are expected to be different. Specifically the following:

  • temperatures: The old database format simply did not store these on the component level, so when converting a database, the components in a block will uniformly get whatever the Block temperature was.

  • serial numbers: At all levels, we cannot really expect the serial numbers to line up from object to object. These are not really supposed to be the same.

  • volume: Component volumes also are not stored on the database, and come from temperatures

  • memory usage: Relatively self-evident. Resource usage will vary from run to run, even if the code hasn’t changed.

class armi.bookkeeping.db.compareDB3.OutputWriter(fname)[source]

Bases: object

Basically a tee to writeln to runLog and the output file.

writeln(msg: str) None[source]
class armi.bookkeeping.db.compareDB3.DiffResults(tolerance)[source]

Bases: object

Utility class for storing differences between database data.

This class is used to store the differences between reference data and other (“source”) data. It is configured with a tolerance, below which differences are ignored. Differences that exceed the tolerance are stored in a collection of differences, organized by time step to be outputted later. It also keeps track of the number of issues that may have been encountered in attempting to compare two databases. For instance, missing datasets on one database or the other, or datasets with incompatible dimensions and the like.

All differences are based on a weird type of relative difference, which uses the mean of the reference and source data elements as the normalization value: 2*(C-E)/(C+E). This is somewhat strange, in that if the two are very different, the reported relative difference will be smaller than expected. It does have the useful property that if the reference value is zero and the source value is non-zero, the diff will not be infinite. We do not typically report these in any rigorous manner, so this should be fine, though we may wish to revisit this in the future.

addDiff(compType: str, paramName: str, absMean: float, mean: float, absMax: float) None[source]

Add a collection of diffs to the diff dictionary if they exceed the tolerance.

addStructureDiffs(nDiffs: int) None[source]
addTimeStep(tsName: str) None[source]
reportDiffs(stream: OutputWriter) None[source]

Print out a well-formatted table of the non-zero diffs.

nDiffs() int[source]

Return the number of differences that exceeded the tolerance.

armi.bookkeeping.db.compareDB3.compareDatabases(refFileName: str, srcFileName: str, exclusions: Optional[Sequence[str]] = None, tolerance: float = 0.0, timestepCompare: Optional[Sequence[Tuple[int, int]]] = None) Optional[DiffResults][source]

High-level method to compare two ARMI H5 files, given file paths.