def removeMFMT( MFMT, MFAlso = True, MTAlso = True ) : global counter if( counter == 0 ) : shutil.copy2( 'test.endf6.orig.noLineNumbers', 'test.endf6.orig.noLineNumbers%d' % counter ) if( MTAlso and MFAlso ) : cmd = 'removeMFMT.py' elif( MTAlso ) : cmd = 'removeMTs.py' else : cmd = 'removeMFs.py' subprocessing.executeCommand( [ 'python', os.path.join( binDir, cmd ), 'test.endf6.orig.noLineNumbers%d' % counter, 'test.endf6.orig.noLineNumbers%d' % ( counter + 1 ) ] + MFMT.split( ) ) counter += 1
def executeCommand( logFile, file, cmd, workDir, workFile ) : def checkNegative_l0( TM_EEpL, weight, f ) : negative_l0Counter, largestNegative = 0, 0. for ig in sorted( TM_EEpL.keys( ) ) : TM_EpL = TM_EEpL[ig] for ih in sorted( TM_EpL.keys( ) ) : l0Cell = TM_EpL[ih][0] if( l0Cell < 0 ) : negative_l0Counter += 1 largestNegative = min( largestNegative, l0Cell ) fOut.write( 'negative l=0 for weight %s at row %3d column %3d: %s\n' % ( weight, ig, ih, l0Cell ) ) return( negative_l0Counter ) if( workFile == [] ) : dataFile = fudgeFileMisc.fudgeTempFile( dir = workDir, suffix = "_in" ) fullFileName = dataFile.name else : workFile = '_'.join( workFile ) + '_in' if( workDir is not None ) : if( not( os.path.exists( workDir ) ) ) : os.makedirs( workDir ) fullFileName = os.path.join( workDir, workFile ) dataFile = open( fullFileName, 'w' ) dataFile.write( cmd ) dataFile.close( ) infoFile = '%s.info' % fullFileName t0 = times.times( ) try : status, stdout, stderr = subprocessing.executeCommand( [ file, '-output', fullFileName + '.out', fullFileName ], stdout = infoFile, stderr = subprocess.STDOUT ) except : fErr = open( fullFileName + ".err", "w" ) fErr.close( ) raise fOut = open( infoFile, 'a' ) fOut.write( str( t0 ) + "\n" ) if( status != 0 ) : print "status = ", status print s raise Exception( 'Transfer failed for %s %s' % ( file, fullFileName ) ) TM1, TME = parseOutputFile( fullFileName + '.out' ) negative_l0Counter = 0 if( TM1 is not None ) : negative_l0Counter = checkNegative_l0( TM1, "0", fOut ) if( TME is not None ) : negative_l0Counter += checkNegative_l0( TME, "E", fOut ) if( negative_l0Counter > 0 ) : print 'WARNING: %d negative l=0 elements found in transfer matrix' % negative_l0Counter fOut.close( ) if( workDir is None ) : os.remove( fullFileName + '.out' ) os.remove( fullFileName + '.info' ) if( workFile == [] ) : dataFile.delete( ) else : dataFile.close( ) os.remove( fullFileName ) return( TM1, TME )
""" __docformat__ = 'epytext en' import sys, os, string, shutil import math from Tkinter import * import tkFileDialog import Gnuplot from fudge.core.utilities import subprocessing __metaclass__ = type gnuplot_old = 0 if __name__ == '__main__': returnCode, stdout, stderr = subprocessing.executeCommand( ["gnuplot", "--version"]) gnuplot_old = returnCode != 0 Options = { "xMin": "*", "xMax": "*", "yMin": "*", "yMax": "*", "xLabel": "x", "yLabel": "y", "title": "", "xylog": 0 } def adjustRange(xy1, xy2):
MFs = sorted( MTDatas[MTp] ) for MF in MFs : if( MF == 1 ) : continue if( MF not in MFLines ) : MFLines[MF] = [] MFLines[MF] += MTDatas[MTp][MF] + [ endfFormatsModule.endfSENDLine( MAT, MF ) ] MFs = sorted( MFLines.keys( ) ) for MF in MFs : f.write( '\n'.join( MFLines[MF] ) + '\n' ) f.write( endfFormatsModule.endfFENDLine( MAT ) + '\n' ) f.write( endfFormatsModule.endfMENDLine( ) + '\n' ) f.write( '%s' % endfFormatsModule.endfTENDLine( ) + '\n' ) f.close( ) flags = processingInfo.tempInfo( ) flags['verbosity'] = 0 subprocessing.executeCommand( [ 'python', os.path.join( binDir, 'reForm.py' ), 'test.endf6.orig2', 'test.endf6.orig' ] ) subprocessing.deleteFilesUsingGlob( 'test.endf6.orig2' ) style = 'eval' rce = endfFileToGND.endfFileToGND( args.inputFile, singleMTOnly = args.MT, toStdOut = args.verbose, skipBadData = args.skipBadData, doCovariances = not( args.skipCovariances ), verboseWarnings = args.verboseWarnings, printBadNK14 = args.printBadNK14, continuumSpectraFix = args.continuumSpectraFix ) errs = rce['errors'] if( 'reactionSuite' in rce ) : reactions, covariances = rce['reactionSuite'], rce['covarianceSuite'] if( args.checkCovars ) : sys.stderr.write( ''.join( [ "%s: %s" % ( os.path.split( args.inputFile )[-1], warning ) for warning in covariances.check( ) ] ) ) if( args.translateOnly ) : sys.exit( len( errs ) )
# <<END-copyright>> import sys, os, glob, random binDir = os.path.dirname( os.path.abspath( __file__ ) ) sys.path.insert( 0, os.path.dirname( binDir ) ) from fudge.core.utilities.brb import Pause from fudge.core.utilities import subprocessing endfPath = "../examples" if( len( sys.argv ) > 1 ) : endfPath = sys.argv[1] files = glob.glob( os.path.join(endfPath,"*.endf") ) if( not files ) : print "No ENDF files were found in %s. Please give the path to a directory containing ENDF files." % endfPath sys.exit( 1 ) random.shuffle( files ) for index, file in enumerate( files ) : returncode, stdout, stderr = subprocessing.executeCommand( [ 'python', os.path.join( binDir, 'rePrint.py' ), file ], raiseOnError = False ) print file try: returncode, stdout, stderr = subprocessing.executeCommand( [ 'xdiff', '--geometry', '1500x1150+10+10', 'test.endf6.orig.noLineNumbers.cleanAndFixed', 'test.endf6.noLineNumbers' ], raiseOnError = False ) except: print """I couldn't find the xdiff command on your system! If you have another tool (like kompare), try the following: > kompare test.endf6.orig.noLineNumbers.cleanAndFixed test.endf6.noLineNumbers """ response = Pause( 'Enter <RET> to continue or "q" to quit [%d of %d sampled] ' % ( index + 1, len( files ) ) ) if( response == 'q' ) : break
if (MF not in MFLines): MFLines[MF] = [] MFLines[MF] += MTDatas[MTp][MF] + [ endfFormatsModule.endfSENDLine(MAT, MF) ] MFs = sorted(MFLines.keys()) for MF in MFs: f.write('\n'.join(MFLines[MF]) + '\n') f.write(endfFormatsModule.endfFENDLine(MAT) + '\n') f.write(endfFormatsModule.endfMENDLine() + '\n') f.write('%s' % endfFormatsModule.endfTENDLine() + '\n') f.close() flags = {'verbosity': 0} subprocessing.executeCommand([ 'python', os.path.join(binDir, 'reForm.py'), args.outputFile + '.endf6.orig2', args.outputFile + '.endf6.orig' ]) subprocessing.deleteFilesUsingGlob(args.outputFile + '.endf6.orig2') style = 'eval' rce = endfFileToGND.endfFileToGND( args.inputFile, singleMTOnly=args.MT, toStdOut=args.verbose, skipBadData=args.skipBadData, doCovariances=not (args.skipCovariances), verboseWarnings=args.verboseWarnings, verbose=args.verbose, printBadNK14=args.printBadNK14, continuumSpectraFix=args.continuumSpectraFix, ignoreBadDate=args.ignoreBadDate,