55from itertools import product
66
77from numpy import transpose , hstack
8- from matplotlib .pyplot import gca
8+ from matplotlib .pyplot import gca , axvline
99
1010from serpentTools .utils .plot import magicPlotDocDecorator , formatPlot
1111from serpentTools .engines import KeywordParser
@@ -304,8 +304,8 @@ def _postcheck(self):
304304 "stored on reader" )
305305
306306 @magicPlotDocDecorator
307- def plot (self , resp , zai = None , pert = None , mat = None , sigma = 3 ,
308- normalize = True , ax = None , labelFmt = None ,
307+ def plot (self , resp , zai = None , pert = None , mat = None , mevscale = False ,
308+ egrid = None , sigma = 3 , normalize = True , ax = None , labelFmt = None ,
309309 title = None , logx = True , logy = False , loglog = False , xlabel = None ,
310310 ylabel = None , legend = None , ncol = 1 ):
311311 """
@@ -331,6 +331,12 @@ def plot(self, resp, zai=None, pert=None, mat=None, sigma=3,
331331 mat: None or str or list of strings
332332 Plot sensitivities due to these materials. Passing ``None``
333333 will plot against all materials.
334+ mevscale : bool, optional
335+ Flag for plotting energy grid in MeV units. If ``True``, the energy
336+ axis is expressed in MeV. Default is ``False``.
337+ egrid : numpy.array, optional
338+ User-defined energy grid boundaries displayed on the sensitivities
339+ as vblack, dashed vertical lines. Default is ``None``.
334340 {sigma}
335341 normalize: True
336342 Normalize plotted data per unit lethargy
@@ -389,7 +395,7 @@ def plot(self, resp, zai=None, pert=None, mat=None, sigma=3,
389395
390396 errors = resMat [..., 1 ] * values * sigma
391397
392- energies = self .energies * 1E6
398+ energies = self .energies if mevscale else self . energies * 1E6
393399 for z , m , p in product (zais , mats , perts ):
394400 iZ = self .zais [z ]
395401 iM = self .materials [m ]
@@ -402,6 +408,13 @@ def plot(self, resp, zai=None, pert=None, mat=None, sigma=3,
402408 ax .errorbar (energies , yVals , yErrs , label = label ,
403409 drawstyle = 'steps-post' )
404410
411+ if egrid is not None :
412+ for group in egrid :
413+ ax .axvline (group , color = 'k' , linestyle = 'dashed' )
414+
415+ if xlabel is None :
416+ xlabel = "Energy [MeV]" if mevscale else "Energy [eV]"
417+
405418 xlabel = 'Energy [eV]' if xlabel is None else xlabel
406419 ylabel = ylabel if ylabel is not None else (
407420 'Sensitivity {} {}' .format (
0 commit comments