Store 0-based threshold indices in HDF5 files

This commit is contained in:
Paul Romano 2019-05-23 09:26:46 -05:00
parent adce57093d
commit 7a1afc5869
2 changed files with 2 additions and 7 deletions

View file

@ -894,10 +894,7 @@ class Reaction(EqualityMixin):
Tgroup = group.create_group(T)
if self.xs[T] is not None:
dset = Tgroup.create_dataset('xs', data=self.xs[T].y)
if hasattr(self.xs[T], '_threshold_idx'):
threshold_idx = self.xs[T]._threshold_idx + 1
else:
threshold_idx = 1
threshold_idx = getattr(self.xs[T], '_threshold_idx', 0)
dset.attrs['threshold_idx'] = threshold_idx
for i, p in enumerate(self.products):
pgroup = group.create_group('product_{}'.format(i))
@ -939,7 +936,7 @@ class Reaction(EqualityMixin):
'at T={} because no corresponding energy grid '
'exists.'.format(mt, T))
xs = Tgroup['xs'][()]
threshold_idx = Tgroup['xs'].attrs['threshold_idx'] - 1
threshold_idx = Tgroup['xs'].attrs['threshold_idx']
tabulated_xs = Tabulated1D(energy[T][threshold_idx:], xs)
tabulated_xs._threshold_idx = threshold_idx
rx.xs[T] = tabulated_xs

View file

@ -42,8 +42,6 @@ Reaction::Reaction(hid_t group, const std::vector<int>& temperatures)
// Get threshold index
TemperatureXS xs;
read_attribute(dset, "threshold_idx", xs.threshold);
// TODO: change HDF5 format so that threshold_idx is 0-based
--xs.threshold;
// Read cross section values
read_dataset(dset, xs.value);