def test_timeseries_transactions(db, fname, backend): evaler = cym.Evaluator(db) cal = ts.transactions(evaler) exp_head = ['Time', 'Mass'] assert_equal(list(cal), exp_head) # Check we have the correct headers if not HAVE_PYNE: raise SkipTest # test single nuclide selection cal = ts.transactions(evaler, nucs=['942390000']) refs = pd.DataFrame( np.array([ (0, 0.000000000), (1, 0.0444814879803), (2, 0.0889629759607), (3, 0.0889629759607), (4, 0.0889629759607), ], dtype=ensure_dt_bytes([('Time', '<i8'), ('Mass', '<f8')]))) assert_frame_equal(cal, refs) # test multiple nuclide selection cal = ts.transactions(evaler, nucs=['942390000', '922380000']) refs = pd.DataFrame( np.array([ (0, 0.000000000), (1, 0.831724864011), (2, 1.66344972802), (3, 2.62344972802), (4, 2.62344972802), ], dtype=ensure_dt_bytes([('Time', '<i8'), ('Mass', '<f8')]))) assert_frame_equal(cal, refs)
def get_val(ev, parameter): key = parameter[0] for i in range(len(parameter))[1:]: if parameter[i] == ['']: parameter[i][:] = [] fac1 = parameter[1] fac2 = parameter[2] nucs = parameter[3] cumul = parameter[4] if key == "inv": pdf = cytim.inventories(ev, facilities=parameter[1], nucs=parameter[3])['Quantity'] if cumul == ["cumul"]: val = 0 for index, row in pdf.iteritems(): row += val val = row return pdf if key == "trans": pdf = cytim.transactions(ev, senders=parameter[1], receivers=parameter[2], nucs=parameter[3])['Mass'] if cumul == ["cumul"]: val = 0 for i, row in pdf.iteritems(): pdf.at[i] += val val = pdf.at[i] return pdf
def Trans(file, rec=(), send=(), nucs_=(), coms=()): ''' Return the transactions between senders (send) and receivers (rec), filtered by nuclide (nucs) and commodities (coms) ''' db = cym.dbopen(file) ev = cym.Evaluator(db=db, write=False) df1 = tm.transactions(ev, receivers=rec, senders=send, nucs=nucs_, commodities=coms) return df1
def TransFrac(file='', ev=None, rec=(), send=(), nucs1=(), nucs2=(), factor1=1, factor2=1): ''' Return the fraction nucs1 / (nucs1+nucs2) in the transaction between senders and receivers, weighting factor can be added on nucs1 and nucs2 ''' if (file != ''): db = cym.dbopen(file) ev = cym.Evaluator(db=db, write=False) elif (ev == None): print('Need either a Filename or a cymetric evaler....') return None df1 = tm.transactions(ev, receivers=rec, senders=send, nucs=nucs1) df2 = tm.transactions(ev, receivers=rec, senders=send, nucs=nucs2) df_r = df2 df_r[df_r.columns[1]] = (df2[df2.columns[1]] / factor2) / \ (df1[df1.columns[1]] / factor1 + df2[df2.columns[1]] / factor2) return df_r
def test_timeseries_transactions(db, fname, backend): evaler = cym.Evaluator(db) cal = ts.transactions(evaler) exp_head = ['Time', 'Mass'] assert_equal(list(cal), exp_head) # Check we have the correct headers if not HAVE_PYNE: raise SkipTest # test single nuclide selection cal = ts.transactions(evaler, nucs=['942390000']) refs = pd.DataFrame(np.array([ (0, 0.000000000), (1, 0.0444814879803), (2, 0.0889629759607), (3, 0.0889629759607), (4, 0.0889629759607), ], dtype=ensure_dt_bytes([ ('Time', '<i8'), ('Mass', '<f8') ])) ) assert_frame_equal(cal, refs) # test multiple nuclide selection cal = ts.transactions( evaler, nucs=['942390000', '922380000']) refs = pd.DataFrame(np.array([ (0, 0.000000000), (1, 0.831724864011), (2, 1.66344972802), (3, 2.62344972802), (4, 2.62344972802), ], dtype=ensure_dt_bytes([ ('Time', '<i8'), ('Mass', '<f8') ])) ) assert_frame_equal(cal, refs)