diff --git a/cymetric/metrics.py b/cymetric/metrics.py index 3cf56d5..c798668 100644 --- a/cymetric/metrics.py +++ b/cymetric/metrics.py @@ -115,13 +115,14 @@ def materials(rsrcs, comps): Resources times the massfrac in Compositions) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ + rsrcs = rsrcs[['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', + 'Quantity', 'Units']] x = pd.merge(rsrcs, comps, on=['SimId', 'QualId'], how='inner') - x = x.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', - 'NucId', 'Units']) - y = x['Quantity'] * x['MassFrac'] - y.name = 'Mass' - z = y.reset_index() - return z + x['Mass'] = x['Quantity'] * x['MassFrac'] + x = x.drop(['Quantity', 'MassFrac'], axis=1) + x = x.reindex(columns=['SimId', 'QualId', 'ResourceId', 'ObjId', + 'TimeCreated', 'NucId', 'Units', 'Mass']) + return x del _matdeps, _matschema