armi.utils.plotting module

This module makes heavy use of matplotlib. Beware that plots generated with matplotlib may not free their memory, even after the plot is closed, and excessive use of plotting functions may gobble up all of your machine’s memory.

Therefore, you should use these plotting tools judiciously. It is not advisable to, for instance, plot some sequence of objects in a loop at every time node. If you start to see your memory usage grow inexplicably, you should question any plots that you are generating.

armi.utils.plotting.colorGenerator(skippedColors=10)[source]

Selects a color from the matplotlib css color database.

Parameters:

skippedColors (int) – Number of colors to skip in the matplotlib CSS color database when generating the next color. Without skipping colors the next color may be similar to the previous color.

Notes

Will cycle indefinitely to accommodate large cores. Colors will repeat.

armi.utils.plotting.plotBlockDepthMap(core, param='pdens', fName=None, bare=False, cmapName='jet', labels=(), labelFmt='{0:.3f}', legendMap=None, fontSize=None, minScale=None, maxScale=None, axisEqual=False, makeColorBar=False, cBarLabel='', title='', shuffleArrows=False, titleSize=25, depthIndex=0)[source]

Plot a param distribution in xy space with the ability to page through depth.

Notes

This is useful for visualizing the spatial distribution of a param through the core. Blocks could possibly not be in alignment between assemblies, but the depths viewable are based on the first fuel assembly.

Parameters:
  • plotFaceMap. (The kwarg definitions are the same as those of) –

  • depthIndex (int) – The the index of the elevation to show block params. The index is determined by the index of the blocks in the first fuel assembly.

armi.utils.plotting.plotFaceMap(core, param='pdens', vals='peak', data=None, fName=None, bare=False, cmapName='jet', labels=(), labelFmt='{0:.3f}', legendMap=None, fontSize=None, minScale=None, maxScale=None, axisEqual=False, makeColorBar=False, cBarLabel='', title='', shuffleArrows=False, titleSize=25, referencesToKeep=None)[source]

Plot a face map of the core.

Parameters:
  • core (Core) – The core to plot.

  • param (str, optional) – The block-parameter to plot. Default: pdens

  • vals (str, optional) – Can be ‘peak’, ‘average’, or ‘sum’. The type of vals to produce. Will find peak, average, or sum of block values in an assembly. Default: peak

  • data (list, optional) – rather than using param and vals, use the data supplied as is. It must be in the same order as iter(r).

  • fName (str, optional) – File name to create. If none, will show on screen.

  • bare (bool, optional) – If True, will skip axis labels, etc.

  • cmapName (str) – The name of the matplotlib colormap to use. Default: jet Other possibilities: http://matplotlib.org/examples/pylab_examples/show_colormaps.html

  • labels (list of str, optional) – Data labels corresponding to data values.

  • labelFmt (str, optional) – A format string that determines how the data is printed if labels is not provided. E.g. "{:.1e}"

  • legendMap (list, optional) – A tuple list of (value, lable, decription), to define the data in the legend.

  • fontSize (int, optional) – Font size in points

  • minScale (float, optional) – The minimum value for the low color on your colormap (to set scale yourself) Default: autoscale

  • maxScale (float, optional) – The maximum value for the high color on your colormap (to set scale yourself) Default: autoscale

  • axisEqual (Boolean, optional) –

    If True, horizontal and vertical axes are scaled equally such that a circle appears as a circle rather than an ellipse.

    If False, this scaling constraint is not imposed.

  • makeColorBar (Boolean, optional) –

    If True, a vertical color bar is added on the right-hand side of the plot.

    If False, no color bar is added.

  • cBarLabel (String, optional) – If True, this string is the color bar quantity label. If False, the color bar will have no label. When makeColorBar=False, cBarLabel affects nothing.

  • title (String, optional) – If True, the string is added as the plot title. If False, no plot title is added.

  • shuffleArrows (list, optional) – Adds arrows indicating fuel shuffling maneuvers

  • titleSize (int, optional) – Size of title on plot

  • referencesToKeep (list, optional) – References to previous plots you might want to plot on: patches, collection, texts.

Examples

Plotting a BOL assembly type facemap with a legend:

>>> plotFaceMap(core, param='typeNumAssem', cmapName='RdYlBu')
armi.utils.plotting.close(fig=None)[source]

Wrapper for matplotlib close.

This is useful to avoid needing to import plotting and matplotlib. The plot functions cannot always close their figure if it is going to be used somewhere else after becoming active (e.g. in reports or gallery examples).

class armi.utils.plotting.DepthSlider(ax, sliderLabel, depths, updateFunc, selectedDepthColor, fontsize=8, valInit=0, **kwargs)[source]

Bases: Slider

Page slider used to view params at different depths.

set_val(val)[source]

Set the value and update the color.

Notes

valmin/valmax are set on the parent to 0 and len(depths).

next(_event)[source]

Move forward to the next depth (page).

previous(_event)[source]

Move backward to the previous depth (page).

updatePageDepthColor(newVal)[source]

Update the page colors.

armi.utils.plotting.plotAssemblyTypes(blueprints=None, fileName=None, assems=None, maxAssems=None, showBlockAxMesh=True, yAxisLabel=None, title=None) Figure[source]

Generate a plot showing the axial block and enrichment distributions of each assembly type in the core.

Parameters:
  • blueprints (Blueprints) – The blueprints to plot assembly types of. (Either this or assems must be non-None.)

  • fileName (str or None) – Base for filename to write, or None for just returning the fig

  • assems (list) – list of assembly objects to be plotted. (Either this or blueprints must be non-None.)

  • maxAssems (integer) – maximum number of assemblies to plot in the assems list.

  • showBlockAxMesh (bool) – if true, the axial mesh information will be displayed on the right side of the assembly plot.

  • yAxisLabel (str) – Optionally, provide a label for the Y-axis.

  • title (str) – Optionally, provide a title for the plot.

Returns:

fig – The figure object created

Return type:

plt.Figure

armi.utils.plotting.plotBlockFlux(core, fName=None, bList=None, peak=False, adjoint=False, bList2=[])[source]

Produce energy spectrum plot of real and/or adjoint flux in one or more blocks.

Parameters:
  • core (Core) – Core object

  • fName (str, optional) – the name of the plot file to produce. If none, plot will be shown. A text file with the flux values will also be generated if this is non-empty.

  • bList (iterable, optional) – is a single block or a list of blocks to average over. If no bList, full core is assumed.

  • peak (bool, optional) – a flag that will produce the peak as well as the average on the plot.

  • adjoint (bool, optional) – plot the adjoint as well.

  • bList2 – a separate list of blocks that will also be plotted on a separate axis on the same plot. This is useful for comparing flux in some blocks with flux in some other blocks.

Notes

This is not a great method. It should be cleand up and migrated into utils.plotting.

armi.utils.plotting.makeHistogram(x, y)[source]

Take a list of x and y values, and return a histogram-ified version Good for plotting multigroup flux spectrum or cross sections.

armi.utils.plotting.plotBlockDiagram(block, fName, cold, cmapName='RdYlBu', materialList=None)[source]

Given a Block with a spatial Grid, plot the diagram of it with all of its components. (wire, duct, coolant, etc…).

Parameters:
  • block (block object) –

  • fName (String) – name of the file to save to

  • cold (boolean) – true is for cold temps, hot is false.

  • cmapName (String) – name of a colorMap to use for block colors

  • materialList (List) – a list of material names across all blocks to be plotted so that same material on all diagrams will have the same color.

armi.utils.plotting.plotTriangleFlux(rtfluxData: RtfluxData, axialZ, energyGroup, hexPitch=1.7320508075688772, hexSideSubdivisions=1, imgFileExt='.png')[source]

Plot region total flux for one core-wide axial slice on triangular/hexagonal geometry.

Warning

This will run on non-triangular meshes but will look wrong.

Parameters:
  • rtfluxData (RtfluxData object) – The RTFLUX/ATFLUX data object containing all read file data. Alternatively, this could be a FIXSRC file object, but only if FIXSRC.fixSrc is first renamed FIXSRC.triangleFluxes.

  • axialZ (int) – The DIF3D axial node index of the core-wide slice to plot.

  • energyGroup (int) – The energy group index to plot.

  • hexPitch (float, optional) – The flat-to-flat hexagonal assembly pitch in this core. By default, it is sqrt(3) so that the triangle edge length is 1 if hexSideSubdivisions=1.

  • hexSideSubdivisions (int, optional) – By default, it is 1 so that the triangle edge length is 1 if hexPitch=sqrt(3).

  • imgFileExt (str, optional) – The image file extension.

Examples

>>> rtflux = rtflux.RtfluxStream.readBinary("RTFLUX")
>>> plotTriangleFlux(rtflux, axialZ=10, energyGroup=4)
armi.utils.plotting.plotNucXs(isotxs, nucNames, xsNames, fName=None, label=None, noShow=False, title=None)[source]

generates a XS plot for a nuclide on the ISOTXS library.

Parameters:
  • isotxs (IsotxsLibrary) – A collection of cross sections (XS) for both neutron and gamma reactions.

  • nucNames (str or list) – The nuclides to plot

  • xsNames (str or list) – the XS to plot e.g. n,g, n,f, nalph, etc. see xsCollections for actual names.

  • fName (str, optional) – if fName is given, the file will be written rather than plotting to screen

  • label (str, optional) – is an optional label for image legends, useful in ipython sessions.

  • noShow (bool, optional) – Won’t finalize plot. Useful for using this to make custom plots.

Examples

>>> l = ISOTXS()
>>> plotNucXs(l, 'U238NA','fission')
>>> # Plot n,g for all xenon and krypton isotopes
>>> f = lambda name: 'XE' in name or 'KR' in name
>>> plotNucXs(l, sorted(filter(f,l.nuclides.keys())),itertools.repeat('nGamma'))

See also

armi.nucDirectory.nuclide.plotScatterMatrix