def __init__(self, label, productFrame, nuclear_term, interferenceReal_term, interferenceImaginary_term, makeCopy=True): if (makeCopy): nuclear_term = nuclear_term.copy() interferenceReal_term = interferenceReal_term.copy() interferenceImaginary_term = interferenceImaginary_term.copy() if (isinstance(nuclear_term, XYs2d)): assert isinstance(interferenceReal_term, XYs2d) and isinstance( interferenceImaginary_term, XYs2d) elif (isinstance(nuclear_term, regions2d)): assert isinstance(interferenceReal_term, regions2d) and isinstance( interferenceImaginary_term, regions2d) else: raise Exception( 'Only XYs2d and regions2d are currently supported, not %s' % brb.getType(nuclear_term)) baseModule.form.__init__( self, label, productFrame, (nuclear_term, interferenceReal_term, interferenceImaginary_term)) self.nuclear_term.label = 'nuclear_term' self.interferenceReal_term.label = 'interferenceReal_term' self.interferenceImaginary_term.label = 'interferenceImaginary_term'
def toFloat(value): try: return (float(value)) except: raise TypeError( 'value must be a convertible to a float; it is of %s: str( value )[:128] = "%s"' % (brb.getType(value), str(value)[:128]))
def addOutputChannel(self, outputChannel): """Adds outputChannel to particle.""" if (isinstance(outputChannel, channelsModule.channel)): outputChannel.setAncestor(self) self.outputChannel = outputChannel else: raise TypeError('Invalid decay channel = %s' % brb.getType(outputChannel))
def append(self, EpP): if (not (isinstance(EpP, XYsModule.XYs1d))): raise Exception('EpP is an instance of %s' % brb.getType(EpP)) if (len(self) > 0): if (EpP.value is None): raise Exception("EpP's value is None") if (EpP.value <= self.EpP[-1].value): raise Exception("EpP.value = %s <= prior's values = %s " % (EpP.value, self.EpP[-1].value)) self.EpP.append(EpP)
def __div__(self, other): """Returns an endl3dmath instance that is the division of self by other. Currently, other must be a number.""" if (fudgemath.isNumber(other)): d = self.copyData() for x, yzs in d.data: for yz in yzs: yz[1] = yz[1] / other else: raise Exception( 'divisor of an endl3dmath instance can only be a number, %s is not allowed' % brb.getType(other))
def getTypeNameGamma(info, ZA, level=None, levelIndex=None): if (level is not None): if (fudgemath.isNumber(level)): if (level < 0): if ((level > -100) and (levelIndex == 0)): level = 0 else: message = 'Negative excitation level = %s for ZA = %s and levelIndex = %s is not allowed' % ( level, ZA, levelIndex) sys.stderr.write(message + '\n') info.doRaise.append(message) level = 0 elif (type(level) != type('')): raise Exception( 'for ZA %d, level (type ="%s") must be a number or a string' % (ZA, brb.getType(level))) if (ZA == 0): ZA = 7 # Special case for gammas which are yo = 7 for ENDL. p = getTypeName(info, ZA, level=level, levelIndex=levelIndex, levelUnit='eV') return (p)
def addWeight(self, weight): if (not (isinstance(weight, weighted))): raise Exception('Invalid weight of type %s' % brb.getType(weight)) self.weights.append(weight)
def getValue(n): if (isNumber(n)): return (n) if (isinstance(n, PQU.PQU)): return (n.getValue()) raise Exception('Invalue number object = %s' % brb.getType(n))
def append(self, EEpP): if (not (isinstance(EEpP, multiD_XYsModule.XYs2d))): raise Exception('EEpP is an instance of %s' % brb.getType(EEpP)) self.data.append(EEpP)