コード例 #1
0
ファイル: STAYSL.py プロジェクト: nickquartemont/NENG612
    def read_output(self):
        """!
        Reads the STAYSL output and saves as a DataFrame. 

        Calculated the norm of the uncertainty.

        @param self: <em> IterativeSTYASL pointer </em> \n
            The IterativeSTYASL pointer. \n
        """

        self._df = pd.read_table(self.path + 'stayslin.out',
                                 engine='python',
                                 sep='\s+',
                                 skiprows=self._dataStart,
                                 skipfooter=649,
                                 header=None,
                                 names=[
                                     'lowE', 'adjFlux', 'unadjFlux',
                                     'fluxRatio', 'adjStd', 'unadjStd',
                                     'uncertRatio', 'integralFlux',
                                     'intFluxUncert'
                                 ])
        self._df.apply(pd.to_numeric)
        self._df['adjFlux'] = bin_integration(self._df['lowE'].tolist(),
                                              self._df['adjFlux'].tolist(),
                                              'low')
        self._df['adjStd'] = self._df['adjStd'] / 100
        self._stdNorm = np.linalg.norm(self._df['adjStd'].tolist(), self.norm)
コード例 #2
0
    def read_output(self):
        """!
        Reads the STAYSL output and saves as a DataFrame. 

        Calculated the norm of the uncertainty.

        @param self: <em> IterativeSTYASL pointer </em> \n
            The IterativeSTYASL pointer. \n
        """

        self._df = pd.read_table(self.path + 'stayslin.out',
                                 engine='python',
                                 sep='\s+',
                                 skiprows=self._dataStart,
                                 skipfooter=649,
                                 header=None,
                                 names=[
                                     'lowE', 'adjFlux', 'unadjFlux',
                                     'fluxRatio', 'adjStd', 'unadjStd',
                                     'uncertRatio', 'integralFlux',
                                     'intFluxUncert'
                                 ])
        self._df.apply(pd.to_numeric)
        self._df['adjFlux'] = bin_integration(self._df['lowE'].tolist(),
                                              self._df['adjFlux'].tolist(),
                                              'low')
        self._df['adjStd'] = self._df['adjStd'] / 100
        self._stdNorm = np.linalg.norm(self._df['adjStd'].tolist(), self.norm)
        # Add in data for groups if first group is not 1.
        dfi = pd.DataFrame(columns=[
            'lowE', 'adjFlux', 'unadjFlux', 'fluxRatio', 'adjStd', 'unadjStd',
            'uncertRatio', 'integralFlux', 'intFluxUncert'
        ])
        #        print self.FirstGroup
        for a in range(self.FirstGroup - 1):
            #            print 'hi'
            dfi = dfi.append(pd.Series(
                (1E-11 * float(a + 1), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
                index=[
                    'lowE', 'adjFlux', 'unadjFlux', 'fluxRatio', 'adjStd',
                    'unadjStd', 'uncertRatio', 'integralFlux', 'intFluxUncert'
                ]),
                             ignore_index=True)
        self._df = pd.concat([dfi, self._df])
コード例 #3
0
ファイル: STAYSL.py プロジェクト: nickquartemont/NENG612
def integralXSecEst(firPath,
                    numRx,
                    firName='stayslin.out',
                    xSecName='xsectlib_140.dat'):
    """
    @ingroup STAYSL
    Calculates the integral cross section values for the SigPhiCalculator. 
    The results are printed to the screen to be enetered into the
    SigPhiCalculator.
    
    Parameters
    ==========
    @param firPath: \e string \n
        Absolute path to the directory containing the FIR output and cross
        section file. \n
    @param numRx: \e integer \n
        The number of reactions used for the FIR calculation. \n
    @param firName: \e string \n
        Name of the FIR output file. \n
    @param xSecName: \e string \n
        Name of the cross section file. \n
    """

    # Open FIR output file
    try:
        f = open(firPath + firName, 'r')

        # Skip the header
        for i in range(0, 4):
            f.next()

        # Read in the RX names
        rxNames = []
        for i in range(0, numRx):
            splt = f.next().strip().split()
            rxNames.append(splt[0])

        # Read in flux
        start = []
        flux = []
        ebin = []
        for line in f:
            splt = line.strip().split()

            if len(splt) > 0:
                if splt[0] == 'GRP':
                    splt = f.next().strip().split()
                    while len(splt) > 3:
                        ebin.append(float(splt[1]))
                        flux.append(float(splt[2]))
                        if (float(splt[1]) >= 5.500E-07 and len(start) == 0) \
                           or (float(splt[1]) >= 0.1 and len(start) == 1) \
                           or (float(splt[1]) >= 1 and len(start) == 2):
                            start.append(int(splt[0]) - 1)
                        splt = f.next().strip().split()

        # Close the file
        f.close()
    except IOError as e:
        print "I/O error({0}): {1}".format(e.errno, e.strerror)

    # Integrate out per MeV and normalize
    flux = bin_integration(ebin, flux, 'low')
    print "The epithermal/thermal ratio is: {}\n".format(
                                           sum(flux[start[0]:start[1]])\
                                           /sum(flux[:start[0]]))
    flux = np.asarray(flux) / sum(flux)

    # Open XSec file
    try:
        f = open(firPath + xSecName, 'r')

        for line in f:
            splt = line.strip().split()

            # Store cross section
            if splt[0] in rxNames:
                print splt[0]
                xSec = []
                for i in range(0, 20):
                    splt = f.next().strip().split()
                    for xs in splt:
                        xSec.append(float(xs))

                #Calculate integrals
                print 'The > 0.1 flux weighted sigma is: {}'.format(
                                sum(np.asarray(xSec[start[1]:]) \
                                *np.asarray(flux[start[1]:])))
                print 'The > 1 flux weighted sigma is: {}'.format(
                                sum(np.asarray(xSec[start[2]:]) \
                                *np.asarray(flux[start[2]:])))

        # Close the file
        f.close()
    except IOError as e:
        print "I/O error({0}): {1}".format(e.errno, e.strerror)
コード例 #4
0
# Get data from result without updating standard deviation until the end.
path = 'C:/Users/nickq/Documents/AFIT_Masters/NENG612/NIF_Unfold/Unfold/STAYSL/Pin_N120405_iter/Iteration1/stayslin.out'
df = pd.read_table(path,
                   engine='python',
                   sep='\s+',
                   skiprows=99,
                   skipfooter=649,
                   header=None,
                   names=[
                       'lowE', 'adjFlux', 'unadjFlux', 'fluxRatio', 'adjStd',
                       'unadjStd', 'uncertRatio', 'integralFlux',
                       'intFluxUncert'
                   ])

df.apply(pd.to_numeric)
df['adjFlux'] = bin_integration(df['lowE'].tolist(), df['adjFlux'].tolist(),
                                'low')
df['adjStd'] = df['adjStd'] * df['adjFlux'] / 100
df1 = df

adjHisto = Histogram()
adjHisto.build_histo(df['lowE'].tolist(),
                     df['adjFlux'].tolist(),
                     uncert=df['adjStd'].tolist(),
                     edgeLoc='low',
                     name='\\textbf{$\sigma$ updated $\chi^{2}$/v = 1.86}')

#adjHisto.plot(pinGuessHisto,xMin=1E-6,yMax=4e12,logX=False, logY=False,
#                  xLabel='Energy [MeV]', yLabel='Neutron Fluence [n/cm$^2$]',
#                  savePath=outpath+'Pin.png',includeMarkers=False,
#                  legendLoc=2)
#adjHisto.plot(pinGuessHisto,xMin=1E-6, yMin=1, logX=False, logY=True,