Made numerous Python scripts in utils work with either 2 or 3.

This commit is contained in:
Paul Romano 2013-06-15 16:11:54 -04:00
parent 85292363d1
commit 45d389c641
5 changed files with 18 additions and 57 deletions

View file

@ -20,9 +20,7 @@ for src in glob.iglob('*.F90'):
dependencies[module] = sorted(list(deps))
keys = dependencies.keys()
keys.sort()
for module in keys:
for module in dependencies.keys():
for dep in dependencies[module]:
print("{0}.o: {1}.o".format(module, dep))
print('')

View file

@ -212,21 +212,24 @@ class XsdirTable(object):
@property
def alias(self):
zaid = self.zaid
Z = int(zaid[:-3])
A = zaid[-3:]
if zaid:
Z = int(zaid[:-3])
A = zaid[-3:]
if A == '000':
s = 'Nat'
elif zaid == '95242':
s = '242m'
elif zaid == '95642':
s = '242'
elif int(A) > 300:
s = str(int(A) - 400) + "m"
if A == '000':
s = 'Nat'
elif zaid == '95242':
s = '242m'
elif zaid == '95642':
s = '242'
elif int(A) > 300:
s = str(int(A) - 400) + "m"
else:
s = str(int(A))
return "{0}-{1}.{2}".format(elements[Z], s, self.xs)
else:
s = str(int(A))
return "{0}-{1}.{2}".format(elements[Z], s, self.xs)
return None
@property
def zaid(self):

View file

@ -5,7 +5,6 @@
import sys
import os
import matplotlib.pyplot as pyplot
if len(sys.argv) > 1:
# Get path to cross_sections.out file from command line argument
@ -56,8 +55,3 @@ print(' Secondary Energy Distributions = ' + str(sum(memory_energy)))
print(' Probability Tables = ' + str(sum(memory_urr)))
print(' S(a,b) Tables = ' + str(sum(memory_sab)))
print(' Total = ' + str(sum(memory_total)))
# Histograms
# pyplot.hist(memory_xs,100)
# pyplot.title('Memory for Cross Sections')
# pyplot.show()

View file

@ -1,34 +0,0 @@
#!/usr/bin/env python2
import struct
class SourceFile(object):
def __init__(self, filename):
# Open source file for reading
self.f = open(filename, 'r')
# Read number of source sites
self.n_sites = struct.unpack('q', self.f.read(8))[0]
# Create list to store source sites
self.sites = []
for i in range(self.n_sites):
# Read position, angle, and energy
(weight,) = struct.unpack('d', self.f.read(8))
xyz = struct.unpack('3d', self.f.read(24))
uvw = struct.unpack('3d', self.f.read(24))
(E,) = struct.unpack('d', self.f.read(8))
# Create source site and append to list
self.sites.append(SourceSite(weight, xyz, uvw, E))
class SourceSite(object):
def __init__(self, weight, xyz, uvw, E):
self.weight = weight
self.xyz = xyz
self.uvw = uvw
self.E = E
def __repr__(self):
return "<SourceSite: xyz={0} at E={1}>".format(self.xyz, self.E)

View file

@ -3,7 +3,7 @@
import sys
if len(sys.argv) != 3:
print "Must supply element and atom/b-cm"
print("Must supply element and atom/b-cm")
exit
element = sys.argv[1]