Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 15 additions & 27 deletions brownies/BNL/plot_evaluation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ def getEXFORSets(sym, A, metastable, reaction=None, quantity="SIG", nox4evals=Tr
print('WARNING: x4i not successfully imported (check your PYTHONPATH?), so EXFOR data not plotted')
return exforData

def barnsConverter(x):
if x == 'barns':
return 'b'
else:
return x

db = exfor_manager.X4DBManagerPlainFS()
i = 0
M = ""
Expand Down Expand Up @@ -357,30 +351,24 @@ def barnsConverter(x):
legend = ds[d].legend()
if verbose:
print(' ', d, legend)
dat = []
unc = []
for line in ds[d].data:
if len(line) != 4:
continue
if line[0] is None or line[1] is None:
continue
dx = 0.0
dy = 0.0
if line[2] is not None:
dx = line[2]
if line[3] is not None:
dy = line[3]
dat.append([line[0], line[1]])
unc.append([dx, dy])
if None in unc[-1]:
unc[-1][unc[-1].index(None)] = 0.0
if len(dat) > 0:
if 'Energy' in ds[d].data and 'Data' in ds[d].data:
dat = ds[d].data[['Energy', 'Data']].pint.dequantify().values.tolist()
try:
unc = ds[d].data[['d(Energy)', 'd(Data)']].pint.dequantify().values.tolist()
except KeyError as err: # There was a problem getting uncertainties, so skip it
unc = None
xUnit = str(ds[d].data['Energy'].pint.units)
yUnit = str(ds[d].data['Data'].pint.units)
if yUnit == 'b/sr':
yUnit='b' # newish strange choice in EXFOR management
if e.startswith('V') or not suppressEXFORLegend:
theLegend = legend + ' (' + str(d[0]) + '.' + str(d[1][-3:]) + ')'
else:
theLegend = '_noLegend_'
exforData.append(
DataSet2d(data=dat, uncertainty=unc, xUnit=ds[d].units[0], yUnit=barnsConverter(ds[d].units[1]),
DataSet2d(data=dat, uncertainty=unc,
xUnit=xUnit,
yUnit=yUnit,
legend=theLegend, lineStyle=' ', symbol=plotstyles.getPlotSymbol(i),
color=plotstyles.getPlotColor(theLegend, False)))
i += 1
Expand Down Expand Up @@ -1298,8 +1286,8 @@ def makeAngDistMubarPlot(gndsMap={}, xyData={}, xydyData={}, xdxydyData={},
xdxydyData=xdxydyData,
plotStyle=plotStyle,
suggestTitle=getSuggestTitle(target, projectile, reactionName, mt),
suggestXLog=(mt in [1, 2, 18, 102] + range(501, 574)),
suggestYLog=(mt in [1, 2, 18, 102] + range(501, 574)),
suggestXLog=(mt in [1, 2, 18, 102] + list(range(501, 574))),
suggestYLog=(mt in [1, 2, 18, 102] + list(range(501, 574))),
suggestFrame=suggestFrame,
figsize=figsize,
useBokeh=useBokeh)
Expand Down
2 changes: 1 addition & 1 deletion brownies/BNL/restools/resonance_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def getFakeResonanceSet(
:param L: orbital angular momentum
:param J: total angular momentum
:param levelDensity: dictionary containing L/J-specific energy-dependent level densities
:param aveWidthFuncs': dictionary containing L/J-specific energy-dependent widths
:param aveWidthFuncs: dictionary containing L/J-specific energy-dependent widths
:param DOFs: Chi-square degrees of freedom for each reaction channel, used for drawing resonance widths.
:param widthKeys: column headers for resulting Table
:param domainMin: lower bound for generating resonances, usually equal to lower bound for level densities / widths
Expand Down
6 changes: 3 additions & 3 deletions brownies/bin/endf2gnds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def process_args( ) :
outFile = args.outputFile
if outFile is None:
outFile = os.path.basename(inFile) + '.gnds.xml'
outCovFile = os.path.basename(inFile) + '.gnds-covar.xml'
outCovFile = os.path.basename(inFile) + '.gndsCov.xml'
elif '.xml' in outFile:
outCovFile = outFile.replace('.xml', '-covar.xml')
outCovFile = outFile.replace('.xml', '.gndsCov.xml')
else:
outCovFile = outFile + "-covar.xml"
outCovFile = outFile + ".gndsCov.xml"

try:
kwargs = {}
Expand Down
5 changes: 3 additions & 2 deletions brownies/bin/gnds2endf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

description = """Translate a GNDS file to ENDF-6.
Sample use: python gnds2endf.py n-001_H_001.xml n-001_H_002.endf
If file n-001_H_001-covar.xml exists, covariances will automatically be read from it.
If file n-001_H_001.gndsCov.xml exists, covariances will automatically be read from it.
The output file name is optional, defaults to the input file with '.endf' appended."""

__doc__ = description
Expand All @@ -38,7 +38,8 @@
parser.add_argument('gnds', help='GNDS file to translate.')
parser.add_argument('output', nargs='?', default=None, help='The translated ENDF file.')

if( __name__ == '__main__' ) :

if __name__ == '__main__':
args = parser.parse_args( )

gndsCov = None
Expand Down
8 changes: 4 additions & 4 deletions brownies/bin/xs_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ def fit_series(xdata, ydata, yerr, seriesInstance, priorModel=None, priorCov=Non
kernel[ix, ic] = seriesInstance.evaluateBasisFunction(x, ic)
try:
fit, cov, resid, chi2 = fudge.core.math.linearAlgebra.cglsqrSolve(
data=numpy.matlib.mat(ydata),
dataUnc=numpy.matlib.mat(yerr),
data=numpy.asmatrix(ydata),
dataUnc=numpy.asmatrix(yerr),
kernel=kernel,
prior=priorModel,
priorCov=priorCov)
except numpy.linalg.linalg.LinAlgError as theError:
print('kernel', kernel)
print('data', numpy.matlib.mat(ydata))
print('unc', numpy.matlib.mat(yerr))
print('data', numpy.asmatrix(ydata))
print('unc', numpy.asmatrix(yerr))
raise theError
results = {'fit': fit, 'cov': cov, 'residual': resid, 'chi2': chi2}
return results
Expand Down
2 changes: 1 addition & 1 deletion fudge/core/math/linearAlgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ def get_test_matrix(endfFile=None, MT=None, MF=None):
idata += 1
if i != j:
aTestMatrix[j].append(aTestMatrix[i][j])
return numpy.mat(aTestMatrix)
return numpy.asmatrix(aTestMatrix)


def get_covariances_from_endf(endfFile, MT, MF=33):
Expand Down
4 changes: 2 additions & 2 deletions fudge/covariances/mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ def add_values(v1, v2):
commonColAxis.values.values = add_values(commonColAxis.values, cc.matrix.axes[1].values)

# Now sum up the components
commonMatrix = numpy.mat(firstCovMtx.group((commonRowAxis.values.values, commonColAxis.values.values),
commonMatrix = numpy.asmatrix(firstCovMtx.group((commonRowAxis.values.values, commonColAxis.values.values),
(commonRowAxis.unit,
commonColAxis.unit)).matrix.array.constructArray())
for c in summands[1:]:
cc = make_common_type(c)
commonMatrix += numpy.mat(cc.group((commonRowAxis.values.values, commonColAxis.values.values),
commonMatrix += numpy.asmatrix(cc.group((commonRowAxis.values.values, commonColAxis.values.values),
(commonRowAxis.unit, commonColAxis.unit)).matrix.array.constructArray())

# Now create the instance of the resulting CovarianceMatrix
Expand Down
2 changes: 1 addition & 1 deletion fudge/reactionData/crossSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def integrateTwoFunctionsWithUncertainty(self, f2, domainMin=None, domainMax=Non

# Compute the uncertainty itself
import numpy
phi = numpy.mat( phi )
phi = numpy.asmatrix( phi )
theArray = theCovariance.matrix.array.constructArray()
try:
coco = (phi * theArray * phi.T)[0,0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ def spin( self ) :

@property
def etaCoefficient( self ) :
r"""This function returns the parameter :math:`\eta \, \sqrt{E} = Z_1 \, Z_2 \, sqrt{\alpha^2 \mu m_1 / 2}`."""
"""This function returns the parameter :math:`\\eta \\, \\sqrt{E} = Z_1 \\, Z_2 \\, sqrt{\\alpha^2 \\mu m_1 / 2}`."""

self.initialize( )
return( self.__etaCoefficient )

@property
def kCoefficient( self ) :
r"""This function returns the coefficient for the particle wave number (i.e., :math:`k(E) / \sqrt{E}`)."""
"""This function returns the coefficient for the particle wave number (i.e., :math:`k(E) / \\sqrt{E}`)."""

self.initialize( )
return( self.__kCoefficient )
Expand Down Expand Up @@ -219,16 +219,17 @@ def initialize( self ):
self.__kCoefficient = (A / (A + 1)) * math.sqrt( 2 * mass1 ) / hbar_c * 1e-14 # 1e-14 = sqrt( barn )

def dSigma_dMu(self, energy, muCutoff, accuracy=1e-3, epsilon=1e-6, excludeRutherfordScattering=False, probability=False):
r"""
This function returns :math:`d\sigma / d\mu` at the specified incident energy if *probability* is False and :math:`P(\mu)` otherwise
if True.. The :math:`\mu` domain goes from muMin to *muCutoff*. For identical particles, muMin is set to -*muCutoff* otherwise it is -1.

"""
This function returns :math:`d\\sigma / d\\mu` at the specified incident energy if *probability* is False and :math:`P(\\mu)` otherwise
if True.. The :math:`\\mu` domain goes from muMin to *muCutoff*. For identical particles, muMin is set to -*muCutoff* otherwise it is -1.

:param energy: Energy of the projectile.
:param muCutoff: The maximum (and maybe minimum) value of :math:`\mu` for the returned function.
:param muCutoff: The maximum (and maybe minimum) value of :math:`\\mu` for the returned function.
:param accuracy: The accuracy of the returned function.
:param epsilon: This variable is not used.
:param excludeRutherfordScattering: If True, Rutherford scattering is not added to the returned function, otherwise it is.
:param probability: If True :math:`P(\mu)` is returned otherwise :math:`d\sigma / d\mu` is returned.
:param probability: If True :math:`P(\\mu)` is returned otherwise :math:`d\\sigma / d\\mu` is returned.

:return: An instance of :py:class:`angularModule.XYs1d`.
"""
Expand Down Expand Up @@ -289,8 +290,8 @@ def calculateAverageProductData( self, style, indent = '', **kwargs ) :
raise CoulombDepositionNotSupported( "Cannot compute average product data for %s distribution" % self.moniker )

def processCoulombPlusNuclearMuCutoff( self, style, energyMin = None, accuracy = 1e-3, epsilon = 1e-6, excludeRutherfordScattering = False ) :
r"""
This function returns the cross section and angular distribution for :math:`\mu` from muMin to muMax.
"""
This function returns the cross section and angular distribution for :math:`\\mu` from muMin to muMax.
For identical particles, muMin is set to -muMax otherwise it is -1. The value of muMax is the *muCufoff*
member of *style*.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, domainMin=None, domainMax=None, domainUnit=None ):

@property
def etaCoefficient( self ) :
r"""This method returns the parameter :math:`\eta \, \sqrt{E} = Z_1 \, Z_2 \, sqrt{\alpha^2 \mu m_1 / 2}`."""
"""This method returns the parameter :math:`\\eta \\, \\sqrt{E} = Z_1 \\, Z_2 \\, sqrt{\\alpha^2 \\mu m_1 / 2}`."""

return( self.ancestor.etaCoefficient )

Expand All @@ -64,7 +64,7 @@ def spin( self ) :

@property
def kCoefficient( self ) :
r"""This function returns the coefficient for the particle wave number (i.e., :math:`k(E) / \sqrt{E}`)."""
"""This function returns the coefficient for the particle wave number (i.e., :math:`k(E) / \\sqrt{E}`)."""

return( self.ancestor.kCoefficient )

Expand All @@ -89,11 +89,11 @@ def convertUnits( self, unitMap ):
self.domainUnit = newUnit

def crossSectionVersusEnergy(self, muMax, accuracy=1e-3, energyMin=None, energyMax=None):
r"""
Returns the partial Rutherford cross section by Integrating :math:`d\sigma / d\mu` from muMin to *muMax*. For identical particles, muMin
"""
Returns the partial Rutherford cross section by Integrating :math:`d\\sigma / d\\mu` from muMin to *muMax*. For identical particles, muMin
is set to -*muMax* otherwise it is -1.

:param muMax: The upper limit for the :amth:`\mu` integration.
:param muMax: The upper limit for the :amth:`\\mu` integration.
:param accuracy: The lin-lin interpolation accuracy of the returned cross section.
:param energyMin: The minimum projectile energy for the returned cross section.
:param energyMax: The maximum projectile energy for the returned cross section.
Expand Down Expand Up @@ -130,10 +130,10 @@ def evaluateAtX(self, energy):


def dSigma_dMuVersusEnergy(self, muMax, accuracy=1e-3, energyMin=None, energyMax=None):
r"""
Returns :math:`d\sigma(E) / d\mu`.
"""
Returns :math:`d\\sigma(E) / d\\mu`.

:param muMax: The upper limit for the :amth:`\mu` integration.
:param muMax: The upper limit for the :amth:`\\mu` integration.
:param accuracy: The lin-lin interpolation accuracy of the returned cross section.
:param energyMin: The minimum projectile energy for the returned cross section.
:param energyMax: The maximum projectile energy for the returned cross section.
Expand All @@ -159,13 +159,13 @@ def dSigma_dMuVersusEnergy(self, muMax, accuracy=1e-3, energyMin=None, energyMax
return xys2d

def dSigma_dMu(self, energy, accuracy=1e-3, muMax=0.999, probability=False):
r"""
Returns :math:`d\sigma / d\mu` at the specified projdctile energy if *probability* is False, otherwise :math:`P(mu)` is returned..
"""
Returns :math:`d\\sigma / d\\mu` at the specified projdctile energy if *probability* is False, otherwise :math:`P(mu)` is returned..

:param energy: Energy of the projectile.
:param accuracy: The lin-lin interpolation accuracy of the returned data.
:param muMax: Slices the upper domain mu to this value.
:param probability: If True :math:`P(mu)` is returned instead of :math:`d\sigma / d\mu`.
:param probability: If True :math:`P(mu)` is returned instead of :math:`d\\sigma / d\\mu`.

:return: A :py:class:`angularModule.XYs1d` instance.
"""
Expand Down Expand Up @@ -224,10 +224,10 @@ def energyDomain(self, energyMin=None, energyMax=None):
return energyUnit, energyMin, energyMax

def evaluate( self, energy, mu, phi = 0.0 ) :
r"""
Returns the :math:`d\sigma / d \Omega(energy,\mu,\phi) for Rutherford scattering. Note, Rutherford
"""
Returns the :math:`d\\sigma / d \\Omega(energy,\\mu,\\phi) for Rutherford scattering. Note, Rutherford
scattering is independent of phi but phi is listed as an argument to be consistent with others
:math:`d\sigma / d\Omega` that may depend on phi.
:math:`d\\sigma / d\\Omega` that may depend on phi.

:param energy: Projectile energy.
:param mu: Scattering angle cosine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def fixMuRange(data, epsilon=1e-6):
r"""
This function ensures that the range of mu in *data* is [-1, 1] by adding 0.0's to the missing ranges. Note, *data* is modified.

:param data: A python list of :math:`P(\mu)`.
:param data: A python list of :math:`P(\\mu)`.
:param epsilon: The relative amount to add a point below (above) the first (last) point in addition to the point at -1 (1).
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__( self, nuclearTerm = None, realInterference = None, imaginaryInterf

@property
def etaCoefficient( self ) :
r"""This method returns the parameter :math:`\eta \, \sqrt{E} = Z_1 \, Z_2 \, sqrt{\alpha^2 \mu m_1 / 2}`."""
"""This method returns the parameter :math:`\\eta \\, \\sqrt{E} = Z_1 \\, Z_2 \\, sqrt{\\alpha^2 \\mu m_1 / 2}`."""

return( self.ancestor.etaCoefficient )

Expand Down Expand Up @@ -206,8 +206,8 @@ def convertUnits( self, unitMap ):
self.imaginaryInterferenceTerm.convertUnits( unitMap )

def dSigma_dMu(self, energy, accuracy=1e-3, muMax=0.999, probability=False):
r"""
This function returns :math:`d\sigma / d\mu` at the specified incident energy.
"""
This function returns :math:`d\\sigma / d\\mu` at the specified incident energy.

:param energy: Energy of the projectile.
:param accuracy: The accuracy of the returned *dSigma_dMu*.
Expand All @@ -218,8 +218,8 @@ def dSigma_dMu(self, energy, accuracy=1e-3, muMax=0.999, probability=False):
"""

class Tester :
r"""
This class is used to added point to :math:`d\sigma / d\mu` until the desired lin-lin interpolation is met.
"""
This class is used to added point to :math:`d\\sigma / d\\mu` until the desired lin-lin interpolation is met.
This class is for internal use.
"""

Expand All @@ -237,8 +237,8 @@ def __init__( self, evaluate, energy, relativeTolerance, absoluteTolerance ) :
self.absoluteTolerance = absoluteTolerance

def evaluateAtX( self, mu ) :
r"""
This function returns *self* evaluated at a projectile energy and outgoing :math:`\mu`.
"""
This function returns *self* evaluated at a projectile energy and outgoing :math:`\\mu`.

:param mu: The mu point to evaluate *self* at.
"""
Expand Down
Loading
Loading