Merge pull request #715 from wbinventor/hotfix-mgxs-pandas-nuclides

[HOTFIX] MGXS Pandas DataFrames with Nuclides
This commit is contained in:
sam 2016-08-31 07:03:23 -04:00 committed by GitHub
commit b47ccb4d8c

View file

@ -337,7 +337,7 @@ class MGXS(object):
if self.by_nuclide:
return self.get_nuclides()
else:
return 'sum'
return ['sum']
@property
def loaded_sp(self):
@ -1483,25 +1483,27 @@ class MGXS(object):
if self.by_nuclide and nuclides == 'sum':
# Use tally summation to sum across all nuclides
query_nuclides = self.get_nuclides()
xs_tally = self.xs_tally.summation(nuclides=query_nuclides)
query_nuclides = [nuclides]
xs_tally = self.xs_tally.summation(nuclides=self.get_nuclides())
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
# Remove nuclide column since it is homogeneous and redundant
if self.domain_type == 'mesh':
df.drop('nuclide', axis=1, level=0, inplace=True)
df.drop('sum(nuclide)', axis=1, level=0, inplace=True)
else:
df.drop('nuclide', axis=1, inplace=True)
df.drop('sum(nuclide)', axis=1, inplace=True)
# If the user requested a specific set of nuclides
elif self.by_nuclide and nuclides != 'all':
query_nuclides = nuclides
xs_tally = self.xs_tally.get_slice(nuclides=nuclides)
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
# If the user requested all nuclides, keep nuclide column in dataframe
else:
query_nuclides = self.nuclides
df = self.xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
@ -1513,7 +1515,7 @@ class MGXS(object):
# Override energy groups bounds with indices
all_groups = np.arange(self.num_groups, 0, -1, dtype=np.int)
all_groups = np.repeat(all_groups, self.num_nuclides)
all_groups = np.repeat(all_groups, len(query_nuclides))
if 'energy low [MeV]' in df and 'energyout low [MeV]' in df:
df.rename(columns={'energy low [MeV]': 'group in'},
inplace=True)