Skip to content

Commit

Permalink
added some key error catches
Browse files Browse the repository at this point in the history
  • Loading branch information
Flan committed Apr 24, 2016
1 parent 5f5119d commit 5716968
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
31 changes: 22 additions & 9 deletions pyne/origen22.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,15 +1509,28 @@ def xslibs(nucs=NUCS, xscache=None, nlb=(201, 202, 203), verbose=False):
t9[nlb[2]][field] = {}
# fill with data
for nuc in nucs:
if verbose:
print('computing {0}'.format(nucname.name(nuc)))
key = nucname.zzaaam(nuc)
if nuc in ACTIVATION_PRODUCT_NUCS:
_compute_xslib(nuc, key, t9[nlb[0]], xscache)
if nuc in ACTINIDE_AND_DAUGHTER_NUCS:
_compute_xslib(nuc, key, t9[nlb[1]], xscache)
if nuc in FISSION_PRODUCT_NUCS:
_compute_xslib(nuc, key, t9[nlb[2]], xscache)
try:
if verbose:
print('computing {0}'.format(nucname.name(nuc)))
key = nucname.zzaaam(nuc)
if nuc in ACTIVATION_PRODUCT_NUCS:
_compute_xslib(nuc, key, t9[nlb[0]], xscache)
if nuc in ACTINIDE_AND_DAUGHTER_NUCS:
_compute_xslib(nuc, key, t9[nlb[1]], xscache)
if nuc in FISSION_PRODUCT_NUCS:
_compute_xslib(nuc, key, t9[nlb[2]], xscache)
except KeyError:
print('Key Error with ', key, ' in a computing cross sections')
continue
#if verbose:
# print('computing {0}'.format(nucname.name(nuc)))
#key = nucname.zzaaam(nuc)
#if nuc in ACTIVATION_PRODUCT_NUCS:
# _compute_xslib(nuc, key, t9[nlb[0]], xscache)
#if nuc in ACTINIDE_AND_DAUGHTER_NUCS:
# _compute_xslib(nuc, key, t9[nlb[1]], xscache)
#if nuc in FISSION_PRODUCT_NUCS:
# _compute_xslib(nuc, key, t9[nlb[2]], xscache)
xscache['E_g'] = old_group_struct
xscache['phi_g'] = old_flux
return t9
Expand Down
10 changes: 5 additions & 5 deletions pyne/xs/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def __getitem__(self, key):
xsdata = ds.discretize(**kw)
if xsdata is not None:
self._cache[key] = xsdata
break
else:
self._cache[key] = [0]
break
else:
raise KeyError
# Return the value requested
return self._cache[key]

Expand All @@ -131,8 +131,8 @@ def __setitem__(self, key, value):
return
self.clear()
self._cache['phi_g'] = None
#for ds in self.data_sources:
# ds.dst_group_struct = value
for ds in self.data_sources:
ds.dst_group_struct = value
elif (key == 'phi_g'):
value = value if value is None else np.asarray(value, dtype='f8')
cache_value = self._cache['phi_g']
Expand Down

0 comments on commit 5716968

Please sign in to comment.