Пример #1
0
def test_materials():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 0.04),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 1.94),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 0.01),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Mass', '<f8')]))
        )
    res = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 9, 7, 'Material', 1, 2, 'kg', 5, 0, 0),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('Type', 'O'), ('TimeCreated', '<i8'), ('Quantity', '<i8'), 
                ('Units', 'O'), ('QualId', '<i8'), ('Parent1', '<i8'), 
                ('Parent2', '<i8')]))
        )
    comps = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 922350000, 0.02),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 922380000, 0.97),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 942390000, 0.005),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('NucId', '<i8'), 
                ('MassFrac', '<f8')]))
        )
    s1 = res.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated'])['Quantity']
    s2 = comps.set_index(['SimId', 'QualId', 'NucId'])['MassFrac']
    series = [s1,s2]
    obs = metrics.materials.func(series)
    assert_frame_equal(exp, obs)
Пример #2
0
def test_explicit_inventory_by_nuc():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'core', 922350000, 1.0), 
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'inventory', 922350000, 1.0),
	    (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'inventory', 922380000, 2.0), 
    	(UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 'core', 922350000, 4.0), 
	    (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 'core', 922380000, 2.0)
	], dtype=ensure_dt_bytes([
	        ('SimId', 'O'), ('Time', '<i8'), ('InventoryName', 'O'), 
    		('NucId', '<i8'), ('Quantity', '<f8')]))
        )
    inv = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 'core', 922350000, 1.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 2, 'core', 922350000, 2.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 2, 'core', 922380000, 2.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 'inventory', 922350000, 1.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 'inventory', 922380000, 2.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 2, 'core', 922350000, 2.0),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'), 
                ('InventoryName', 'O'), ('NucId', '<i8'), ('Quantity', '<f8')]))
        )
    series = [inv.set_index(['SimId', 'Time', 'InventoryName', 'NucId'])['Quantity']]
    obs = metrics.explicit_inventory_by_nuc.func(series)
    assert_frame_equal(exp, obs)
Пример #3
0
def test_fuel_cost():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 1, 'uox', 
        29641.600000000002, 46),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 11, 3, 'mox', 0, 9)
        ], dtype=ensure_dt_bytes([
             ('SimId','O'), ('TransactionId', '<i8'), ('ReceiverId','<i8'),
             ('Commodity', 'O'), ('Cost', '<f8'), ('Time', '<i8')]))
        )
    resources = pd.DataFrame(np.array([
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 12.56),
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 5.5),
              ], dtype=ensure_dt_bytes([
                      ('SimId', 'O'), ('ResourceId', '<i8'), ('Quantity', 
                      '<f8'),]))
              )
    transactions = pd.DataFrame(np.array([
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 1, 27,
                 'uox', 46),
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 11, 3, 13, 
                 'mox', 9)
                 ], dtype=ensure_dt_bytes([
                         ('SimId', 'O'), ('TransactionId', '<i8'),
                         ('ReceiverId', '<i8'), ('ResourceId', '<i8'), 
                         ('Commodity', 'O'), ('Time', '<i8')]))
                 )
    s1 = resources.set_index(['SimId', 'ResourceId'])['Quantity']
    s2 = transactions.set_index(['SimId', 'TransactionId', 'ReceiverId', 
       'ResourceId', 'Commodity'])['Time']
    series = [s1, s2]
    obs = eco_metrics.fuel_cost.func(series)
    assert_frame_equal(exp, obs)
Пример #4
0
def test_decommission_series():
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 10, 'LWR', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 'LWR', 2),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('ExitTime', '<i8'),
                                        ('Prototype', 'O'),
                                        ('Count', '<i8')])))
    agent_entry = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'FRx'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 'LWR'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 'LWR'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 4, 'FRx'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 'LWR'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 'FRx'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 'FRx'),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Prototype', 'O')])))
    agent_exit = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 10),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 20),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 20),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('ExitTime', '<i8')])))
    obs = metrics.decommission_series.func(agent_entry, agent_exit)
    assert_frame_equal(exp, obs)
Пример #5
0
def test_timeseries_inventories(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = ts.inventories(evaler)
    exp_head = ['Time', 'Quantity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    if not HAVE_PYNE:
        raise SkipTest
    cal = ts.inventories(evaler, facilities=['Reactor1'],
                                      nucs=['94239'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 0.0444814879803),
        (2, 0.0621806030246),
        (3, 0.0798797180688),
        (4, 0.0530973451327)
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Quantity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    cal = ts.inventories(evaler, facilities=['Reactor1'],
                                      nucs=['94239', '92235'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 0.0460607124057),
        (2, 0.0726093849721),
        (3, 0.0991580575384),
        (4, 0.119646017699)
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Quantity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #6
0
def test_timeseries_inventories_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.inventories_decayheat(evaler)
    exp_head = ['Time', 'DecayHeat']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    cal = ts.inventories_decayheat(evaler,
                                   facilities=['Reactor1'],
                                   nucs=['94239'])
    refs = pd.DataFrame(
        np.array([(0, 0.0), (1, 7.98590335085e+32), (2, 1.11634819022e+33),
                  (3, 1.43410604536e+33), (4, 9.53273565408e+32)],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)

    cal = ts.inventories_decayheat(evaler,
                                   facilities=['Reactor1'],
                                   nucs=['94239', '92235'])
    refs = pd.DataFrame(
        np.array([(0, 0.0), (1, 7.98591200694e+32), (2, 1.11635390648e+33),
                  (3, 1.43411661226e+33), (4, 9.53310042276e+32)],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #7
0
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)
Пример #8
0
def test_timeseries_inventories_activity(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.inventories_activity(evaler)
    exp_head = ['Time', 'Activity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    cal = ts.inventories_activity(evaler,
                                  facilities=['Reactor1'],
                                  nucs=['94239'])
    refs = pd.DataFrame(
        np.array([(0, 0.0), (1, 2.44036364223e+13), (2, 3.41138054869e+13),
                  (3, 4.38239745515e+13), (4, 2.91305071939e+13)],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Activity', '<f8')])))
    assert_frame_equal(cal, refs)

    cal = ts.inventories_activity(evaler,
                                  facilities=['Reactor1'],
                                  nucs=['94239', '92235'])
    refs = pd.DataFrame(
        np.array([
            (0, 0.0),
            (1, 2.4403666094e+13),
            (2, 3.41140014315e+13),
            (3, 4.3824336769e+13),
            (4, 2.91317575657e+13),
        ],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Activity', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #9
0
def test_timeseries_inventories(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = ts.inventories(evaler)
    exp_head = ['Time', 'Quantity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    if not HAVE_PYNE:
        raise SkipTest
    cal = ts.inventories(evaler, facilities=['Reactor1'], nucs=['94239'])
    refs = pd.DataFrame(
        np.array([(0, 0.0), (1, 0.0444814879803), (2, 0.0621806030246),
                  (3, 0.0798797180688), (4, 0.0530973451327)],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Quantity', '<f8')])))
    assert_frame_equal(cal, refs)

    cal = ts.inventories(evaler,
                         facilities=['Reactor1'],
                         nucs=['94239', '92235'])
    refs = pd.DataFrame(
        np.array([(0, 0.0), (1, 0.0460607124057), (2, 0.0726093849721),
                  (3, 0.0991580575384), (4, 0.119646017699)],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Quantity', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #10
0
def test_timeseries_transactions_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.transactions_decayheat(evaler)
    exp_head = ['Time', 'DecayHeat']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = ts.transactions_decayheat(evaler, nucs=['942390000'])
    refs = pd.DataFrame(
        np.array([
            (0, 0.000000000),
            (1, 3.34065303191e+30),
            (2, 6.68130606382e+30),
            (3, 6.68130606382e+30),
            (4, 6.68130606382e+30),
        ],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = ts.transactions_decayheat(evaler, nucs=['942390000', '922380000'])
    refs = pd.DataFrame(
        np.array([
            (0, 0.000000000),
            (1, 3.34091395721e+30),
            (2, 6.68182791443e+30),
            (3, 6.68214609848e+30),
            (4, 6.68214609848e+30),
        ],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #11
0
def test_timeseries_transactions_activity(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.transactions_activity(evaler)
    exp_head = ['Time', 'Activity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = ts.transactions_activity(evaler, nucs=['942390000'])
    refs = pd.DataFrame(
        np.array([
            (0, 0.000000000),
            (1, 102084984531.0),
            (2, 204169969062.0),
            (3, 204169969062.0),
            (4, 204169969062.0),
        ],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Activity', '<f8')])))
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = ts.transactions_activity(evaler, nucs=['942390000', '922380000'])
    refs = pd.DataFrame(
        np.array([
            (0, 0.000000000),
            (1, 102094774891.0),
            (2, 204189549782.0),
            (3, 204201488588.0),
            (4, 204201488588.0),
        ],
                 dtype=ensure_dt_bytes([('Time', '<i8'),
                                        ('Activity', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #12
0
def test_build_series():
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), -1, 'FRx', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), -1, 'LWR', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'FRx', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'LWR', 2),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 'FRx', 2),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('EnterTime', '<i8'),
                                        ('Prototype', 'O'),
                                        ('Count', '<i8')])))
    agent_entry = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'FRx', -1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'LWR', -1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'LWR', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'FRx', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'LWR', 1),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'FRx', 5),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 'FRx', 5),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('Prototype', 'O'),
                                        ('EnterTime', '<i8')])))
    obs = metrics.build_series.func(agent_entry)
    assert_frame_equal(exp, obs)
Пример #13
0
def test_decayheat():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 2.3944723480343003e-12),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 1.6505536389997207e-11),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 1.92784802432412e-08),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('DecayHeat', '<f8')]))
        )

    act = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 3197501.3876324706),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 24126337.066086654),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 22949993169.28023),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Activity', '<f8')]))
        )

    series = [act.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', \
                  'NucId'])['Activity']]
    obs = metrics.decay_heat.func(series)
    assert_frame_equal(exp, obs)
Пример #14
0
def test_decayheat():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922350000, 9.3280119931e+25),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922380000, 6.42996948889e+26),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             942390000, 7.51020971553e+29),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                     ('ObjId', '<i8'), ('TimeCreated', '<i8'),
                     ('NucId', '<i8'), ('DecayHeat', '<f8')
                 ])))

    act = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922350000, 3197501.3876324706),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922380000, 24126337.066086654),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             942390000, 22949993169.28023),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                     ('ObjId', '<i8'), ('TimeCreated', '<i8'),
                     ('NucId', '<i8'), ('Activity', '<f8')
                 ])))

    obs = metrics.decay_heat.func(act)
    assert_frame_equal(exp, obs)
Пример #15
0
def test_fco_swu():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([(0, 0.002407), (1, 0.001473)],
        dtype=ensure_dt_bytes([('Year', '<i8'), ('SWU', '<f8')]))
        )
    mats = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922350000, 8.328354),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922380000, 325.004979),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922380000, 322.228861),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922380000, 322.228861),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('NucId', '<i8'),
                ('Mass', '<f8')]))
        )
    trans = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 'LWR Fuel'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('ResourceId', '<i8'),
                ('Commodity', 'O')]))
        )
    s1 = mats.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', 'NucId'])['Mass']
    s2 = trans.set_index(['SimId', 'TransactionId', 'ResourceId'])['Commodity']
    series = [s1,s2]
    obs = fco_metrics.fco_swu.func(series)
    np.allclose(exp, obs)
Пример #16
0
def test_timeseries_inventories_activity(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.inventories_activity(evaler)
    exp_head = ['Time', 'Activity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    cal = ts.inventories_activity(evaler, facilities=['Reactor1'],
                                               nucs=['94239'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 2.44036364223e+13),
        (2, 3.41138054869e+13),
        (3, 4.38239745515e+13),
        (4, 2.91305071939e+13)
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Activity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    cal = ts.inventories_activity(evaler, facilities=['Reactor1'],
                                               nucs=['94239', '92235'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 2.4403666094e+13),
        (2, 3.41140014315e+13),
        (3, 4.3824336769e+13),
        (4, 2.91317575657e+13),
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Activity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #17
0
def test_materials():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 'kg', 0.04),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 'kg', 1.94),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 'kg', 0.01),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Units', 'O'), ('Mass', '<f8')]))
        )
    res = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 9, 7, 'Material', 1, 2, 'kg', 5, 0, 0),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('Type', 'O'), ('TimeCreated', '<i8'), ('Quantity', '<i8'), 
                ('Units', 'O'), ('QualId', '<i8'), ('Parent1', '<i8'), 
                ('Parent2', '<i8')]))
        )
    comps = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 922350000, 0.02),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 922380000, 0.97),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 942390000, 0.005),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('NucId', '<i8'), 
                ('MassFrac', '<f8')]))
        )
    s1 = res.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', 'Units'])['Quantity']
    s2 = comps.set_index(['SimId', 'QualId', 'NucId'])['MassFrac']
    series = [s1,s2]
    obs = metrics.materials.func(series)
    assert_frame_equal(exp, obs)
Пример #18
0
def test_fco_fuel_loading():
    exp = pd.DataFrame(np.array([(0, 0.666666), (1, 0.333333)],
        dtype=ensure_dt_bytes([('Year', '<i8'), ('FuelLoading', '<f8')]))
        )
    mats = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922350000, 8.328354),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922380000, 325.004979),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922380000, 322.228861),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922380000, 322.228861),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('NucId', '<i8'),
                ('Mass', '<f8')]))
        )
    trans = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 'FR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 'FR Fuel'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('ResourceId', '<i8'),
                ('Commodity', 'O')]))
        )
    s1 = mats.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', 'NucId'])['Mass']
    s2 = trans.set_index(['SimId', 'TransactionId', 'ResourceId'])['Commodity']
    series = [s1,s2]
    obs = fco_metrics.fco_fuel_loading.func(series)
    assert_frame_equal(exp, obs)
Пример #19
0
def test_fco_swu():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([(0, 0.002407), (1, 0.001473)],
        dtype=ensure_dt_bytes([('Year', '<i8'), ('SWU', '<f8')]))
        )
    mats = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922350000, 8.328354),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922380000, 325.004979),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922380000, 322.228861),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922380000, 322.228861),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('NucId', '<i8'),
                ('Mass', '<f8')]))
        )
    trans = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 'LWR Fuel'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('ResourceId', '<i8'),
                ('Commodity', 'O')]))
        )
    obs = fco_metrics.fco_swu.func(mats, trans)
    np.allclose(exp, obs)
Пример #20
0
def test_timeseries_inventories_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.inventories_decayheat(evaler)
    exp_head = ['Time', 'DecayHeat']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    cal = ts.inventories_decayheat(evaler, facilities=['Reactor1'],
                                                nucs=['94239'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 7.98590335085e+32),
        (2, 1.11634819022e+33),
        (3, 1.43410604536e+33),
        (4, 9.53273565408e+32)
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('DecayHeat', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    cal = ts.inventories_decayheat(evaler, facilities=['Reactor1'],
                                                nucs=['94239', '92235'])
    refs = pd.DataFrame(np.array([
        (0, 0.0),
        (1, 7.98591200694e+32),
        (2, 1.11635390648e+33),
        (3, 1.43411661226e+33),
        (4, 9.53310042276e+32)
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('DecayHeat', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #21
0
def test_decommission_series():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 10, 'LWR', 1),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 'LWR', 2),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('ExitTime', '<i8'), ('Prototype', 'O'),
		        ('Count', '<i8')]))
        )
    agent_entry = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 'FRx'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 'LWR'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 'LWR'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 4, 'FRx'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 'LWR'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 'FRx'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 'FRx'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Prototype', 'O')]))
        )
    agent_exit = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 10),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 20),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 20),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('ExitTime', '<i8')]))
        )
    obs = metrics.decommission_series.func(agent_entry, agent_exit)
    assert_frame_equal(exp, obs)
Пример #22
0
def test_activity():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922350000, 3197501.3876324706),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922380000, 24126337.066086654),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             942390000, 22949993169.28023),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                     ('ObjId', '<i8'), ('TimeCreated', '<i8'),
                     ('NucId', '<i8'), ('Activity', '<f8')
                 ])))

    mass = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922350000, 0.04),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             922380000, 1.94),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1,
             942390000, 0.01),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('QualId', '<i8'),
                                        ('ResourceId', '<i8'), ('ObjId',
                                                                '<i8'),
                                        ('TimeCreated', '<i8'),
                                        ('NucId', '<i8'), ('Mass', '<f8')])))
    obs = metrics.activity.func(mass)
    assert_frame_equal(exp, obs)
Пример #23
0
def test_fco_fuel_loading():
    exp = pd.DataFrame(np.array([(0, 0.666666), (1, 0.333333)], 
        dtype=ensure_dt_bytes([('Year', '<i8'), ('FuelLoading', '<f8')]))
        )
    mats = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922350000, 8.328354),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922380000, 325.004979),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922380000, 322.228861),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922350000, 11.104472),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922380000, 322.228861),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('NucId', '<i8'), 
                ('Mass', '<f8')]))
        )
    trans = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 'FR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 'FR Fuel'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('ResourceId', '<i8'), 
                ('Commodity', 'O')]))
        )
    s1 = mats.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', 'NucId'])['Mass']
    s2 = trans.set_index(['SimId', 'TransactionId', 'ResourceId'])['Commodity']
    series = [s1,s2]
    obs = metrics.fco_fuel_loading.func(series)
    assert_frame_equal(exp, obs)
Пример #24
0
def test_decayheat():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 2.3944723480343003e-12),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 1.6505536389997207e-11),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 1.92784802432412e-08),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('DecayHeat', '<f8')]))
        )

    act = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 3197501.3876324706),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 24126337.066086654),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 22949993169.28023),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'), 
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Activity', '<f8')]))
        )

    series = [act.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', \
                  'NucId'])['Activity']]
    obs = metrics.decay_heat.func(series)
    assert_frame_equal(exp, obs)
Пример #25
0
def test_transaction_quantity():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 3, 3,  10, 20, 'LWR Fuel', 'kg', 410),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 4, 3,  20, 30, 'FR Fuel', 'kg', 305),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 5, 12, 30, 40, 'Spent Fuel', 'kg', 9),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('SenderId', '<i8'),
                ('ReceiverId', '<i8'), ('Commodity', 'O'), ('Units', 'O'),
                ('Quantity', '<f8')]))
        )
    mats = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922350000, 'kg', 10),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3, 922380000, 'kg', 400),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 942390000, 'kg', 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3, 922380000, 'kg', 300),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 942390000, 'kg', 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12, 922360000, 'kg', 4),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'),
                ('ObjId', '<i8'), ('TimeCreated', '<i8'), ('NucId', '<i8'),
                ('Units', 'O'), ('Mass', '<f8')]))
        )
    trans = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 10, 20, 7, 'LWR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 20, 30, 8, 'FR Fuel'),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 30, 40, 9, 'Spent Fuel'),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('TransactionId', '<i8'), ('SenderId', '<i8'),
                ('ReceiverId', '<i8'), ('ResourceId', '<i8'), ('Commodity', 'O')]))
        )
    obs = metrics.transaction_quantity.func(mats, trans)
    assert_frame_equal(exp, obs)
Пример #26
0
def test_materials():
    exp = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922350000, "kg", 0.04),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922380000, "kg", 1.94),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 942390000, "kg", 0.01),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Units", "O"),
                    ("Mass", "<f8"),
                ]
            ),
        )
    )
    res = pd.DataFrame(
        np.array(
            [(UUID("f22f2281-2464-420a-8325-37320fd418f8"), 9, 7, "Material", 1, 2, "kg", 5, 0, 0)],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("Type", "O"),
                    ("TimeCreated", "<i8"),
                    ("Quantity", "<i8"),
                    ("Units", "O"),
                    ("QualId", "<i8"),
                    ("Parent1", "<i8"),
                    ("Parent2", "<i8"),
                ]
            ),
        )
    )
    comps = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 922350000, 0.02),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 922380000, 0.97),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 942390000, 0.005),
            ],
            dtype=ensure_dt_bytes([("SimId", "O"), ("QualId", "<i8"), ("NucId", "<i8"), ("MassFrac", "<f8")]),
        )
    )
    s1 = res.set_index(["SimId", "QualId", "ResourceId", "ObjId", "TimeCreated", "Units"])["Quantity"]
    s2 = comps.set_index(["SimId", "QualId", "NucId"])["MassFrac"]
    series = [s1, s2]
    obs = metrics.materials.func(series)
    assert_frame_equal(exp, obs)
Пример #27
0
def test_agents():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 22, 'Region', ':agents:NullRegion', 'USA', -1, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 23, 'Inst', ':agents:NullInst', 'utility', 22, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 24, 'Facility', ':agents:Source', 'MineU235', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 25, 'Facility', ':agents:Source', 'U238', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 26, 'Facility', ':agents:Source', 'DU', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 'Facility', ':agents:Source', 'DU2', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 28, 'Facility', ':Brightlite:FuelfabFacility', 'LWR Fuel FAb', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 29, 'Facility', ':Brightlite:ReprocessFacility', 'LWR Seperation', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 30, 'Facility', ':Brightlite:ReprocessFacility', 'FR Reprocess', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 31, 'Facility', ':agents:Sink', 'SINK', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 32, 'Facility', ':Brightlite:FuelfabFacility', 'FR Fuel Fab', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 33, 'Inst', ':cycamore:DeployInst', 'utility2', 22, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 35, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 36, 'Facility', ':Brightlite:ReactorFacility', 'FRx', 33, -1, 10, 120.0),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), 
                ('Kind', 'O'), ('Spec', 'O'), ('Prototype', 'O'), 
                ('ParentId', '<i8'), ('Lifetime', '<i8'), 
                ('EnterTime', '<i8'), ('ExitTime', '<f8')]))
        )
    agent_entry = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 22, 'Region', ':agents:NullRegion', 'USA', -1, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 23, 'Inst', ':agents:NullInst', 'utility', 22, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 24, 'Facility', ':agents:Source', 'MineU235', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 25, 'Facility', ':agents:Source', 'U238', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 26, 'Facility', ':agents:Source', 'DU', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 'Facility', ':agents:Source', 'DU2', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 28, 'Facility', ':Brightlite:FuelfabFacility', 'LWR Fuel FAb', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 29, 'Facility', ':Brightlite:ReprocessFacility', 'LWR Seperation', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 30, 'Facility', ':Brightlite:ReprocessFacility', 'FR Reprocess', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 31, 'Facility', ':agents:Sink', 'SINK', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 32, 'Facility', ':Brightlite:FuelfabFacility', 'FR Fuel Fab', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 33, 'Inst', ':cycamore:DeployInst', 'utility2', 22, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 35, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 36, 'Facility', ':Brightlite:ReactorFacility', 'FRx', 33, -1, 10),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), 
                ('Kind', 'O'), ('Spec', 'O'), ('Prototype', 'O'), 
                ('ParentId', '<i8'), ('Lifetime', '<i8'), 
                ('EnterTime', '<i8')]))
        )
    info = pd.DataFrame({'Duration': {0: 120}, 
        'SimId': {0: UUID('f22f2281-2464-420a-8325-37320fd418f8')}, 
        })
    dur = info.set_index(['SimId'])
    series = [raw_to_series(agent_entry, ['SimId', 'AgentId'], col) \
              for col in ('Kind', 'Spec', 'Prototype', 'ParentId', 
                          'Lifetime', 'EnterTime')]
    series += [None, None, dur]
    obs = metrics.agents.func(series)
    assert_frame_equal(exp, obs)
Пример #28
0
def test_transaction_quantity():
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 3, 3, 10, 20,
             'LWR Fuel', 'kg', 410),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 4, 3, 20, 30,
             'FR Fuel', 'kg', 305),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 5, 12, 30, 40,
             'Spent Fuel', 'kg', 9),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('TransactionId', '<i8'),
                     ('ResourceId', '<i8'), ('ObjId', '<i8'),
                     ('TimeCreated', '<i8'), ('SenderId', '<i8'),
                     ('ReceiverId', '<i8'), ('Commodity', 'O'), ('Units', 'O'),
                     ('Quantity', '<f8')
                 ])))
    mats = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3,
             922350000, 'kg', 10),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3,
             922380000, 'kg', 400),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3,
             942390000, 'kg', 5),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3,
             922380000, 'kg', 300),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12,
             942390000, 'kg', 5),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12,
             922360000, 'kg', 4),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('QualId', '<i8'),
                                        ('ResourceId', '<i8'), ('ObjId',
                                                                '<i8'),
                                        ('TimeCreated', '<i8'),
                                        ('NucId', '<i8'), ('Units', 'O'),
                                        ('Mass', '<f8')])))
    trans = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 10, 20, 7,
             'LWR Fuel'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 20, 30, 8,
             'FR Fuel'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 30, 40, 9,
             'Spent Fuel'),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'),
                                        ('TransactionId', '<i8'),
                                        ('SenderId', '<i8'),
                                        ('ReceiverId', '<i8'),
                                        ('ResourceId', '<i8'),
                                        ('Commodity', 'O')])))
    obs = metrics.transaction_quantity.func(mats, trans)
    assert_frame_equal(exp, obs)
Пример #29
0
def test_agents():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 22, 'Region', ':agents:NullRegion', 'USA', -1, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 23, 'Inst', ':agents:NullInst', 'utility', 22, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 24, 'Facility', ':agents:Source', 'MineU235', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 25, 'Facility', ':agents:Source', 'U238', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 26, 'Facility', ':agents:Source', 'DU', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 'Facility', ':agents:Source', 'DU2', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 28, 'Facility', ':Brightlite:FuelfabFacility', 'LWR Fuel FAb', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 29, 'Facility', ':Brightlite:ReprocessFacility', 'LWR Seperation', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 30, 'Facility', ':Brightlite:ReprocessFacility', 'FR Reprocess', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 31, 'Facility', ':agents:Sink', 'SINK', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 32, 'Facility', ':Brightlite:FuelfabFacility', 'FR Fuel Fab', 23, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 33, 'Inst', ':cycamore:DeployInst', 'utility2', 22, -1, 0, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 35, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5, 120.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 36, 'Facility', ':Brightlite:ReactorFacility', 'FRx', 33, -1, 10, 120.0),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), 
                ('Kind', 'O'), ('Spec', 'O'), ('Prototype', 'O'), 
                ('ParentId', '<i8'), ('Lifetime', '<i8'), 
                ('EnterTime', '<i8'), ('ExitTime', '<f8')]))
        )
    agent_entry = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 22, 'Region', ':agents:NullRegion', 'USA', -1, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 23, 'Inst', ':agents:NullInst', 'utility', 22, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 24, 'Facility', ':agents:Source', 'MineU235', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 25, 'Facility', ':agents:Source', 'U238', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 26, 'Facility', ':agents:Source', 'DU', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 'Facility', ':agents:Source', 'DU2', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 28, 'Facility', ':Brightlite:FuelfabFacility', 'LWR Fuel FAb', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 29, 'Facility', ':Brightlite:ReprocessFacility', 'LWR Seperation', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 30, 'Facility', ':Brightlite:ReprocessFacility', 'FR Reprocess', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 31, 'Facility', ':agents:Sink', 'SINK', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 32, 'Facility', ':Brightlite:FuelfabFacility', 'FR Fuel Fab', 23, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 33, 'Inst', ':cycamore:DeployInst', 'utility2', 22, -1, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 34, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 35, 'Facility', ':Brightlite:ReactorFacility', 'LWR', 33, -1, 5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 36, 'Facility', ':Brightlite:ReactorFacility', 'FRx', 33, -1, 10),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), 
                ('Kind', 'O'), ('Spec', 'O'), ('Prototype', 'O'), 
                ('ParentId', '<i8'), ('Lifetime', '<i8'), 
                ('EnterTime', '<i8')]))
        )
    info = pd.DataFrame({'Duration': {0: 120}, 
        'SimId': {0: UUID('f22f2281-2464-420a-8325-37320fd418f8')}, 
        })
    dur = info.set_index(['SimId'])
    series = [raw_to_series(agent_entry, ['SimId', 'AgentId'], col) \
              for col in ('Kind', 'Spec', 'Prototype', 'ParentId', 
                          'Lifetime', 'EnterTime')]
    series += [None, None, dur]
    obs = metrics.agents.func(series)
    assert_frame_equal(exp, obs)
Пример #30
0
def test_decommissioning_cost():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 0, 19),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/49, 20),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/49*2, 21),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*3/7, 22),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*4/7, 23),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*5/7, 24),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*6/7, 25),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7, 26),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*6/7, 27),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*5/7, 28),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*4/7, 29),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/7*3/7, 30),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/49*2, 31),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 7500/49, 32),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 0, 33)
        ], dtype=ensure_dt_bytes([
             ('SimId','O'), ('AgentId', '<i8'), ('DecomPayment','<f8'),
             ('Time', '<i8')]))
        )
    decom = pd.DataFrame(np.array([
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 234),
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 450)
              ], dtype=ensure_dt_bytes([
                      ('SimId', 'O'), ('AgentId', '<i8'), ('DecomTime', 
                      '<i8'),]))
              )
    power = pd.DataFrame(np.array([
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 10.0),
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 11.3)
                 ], dtype=ensure_dt_bytes([
                         ('SimId', 'O'), ('AgentId', '<i8'), ('Value', 
                         '<f8')]))
                 )
    entry = pd.DataFrame(np.array([
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 27, 
                 ':cycamore:Reactor'),
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 
                 ':cycamore:Reactor'),
                 (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 
                 ':cycamore:Sink')
                 ], dtype=ensure_dt_bytes([
                         ('SimId', 'O'), ('AgentId', '<i8'),
                         ('Spec', 'O')]))
                 )
    s1 = decom.set_index(['SimId', 'AgentId'])['DecomTime']
    s2 = power.set_index(['SimId', 'AgentId'])['Value']
    s3 = entry.set_index(['SimId', 'AgentId'])['Spec']
    series = [s1, s2, s3]
    obs = eco_metrics.decommissioning_cost.func(series)
    assert_frame_equal(exp, obs)
Пример #31
0
def test_capital_cost():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 9, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 10, 343.75),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 11, 687.5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 12, 1031.25),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 13, 1375.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 14, 1718.75),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 15, 2062.5),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 16, 2406.25),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 17, 2750.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 18, 1375.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 19, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -8, 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -7, 750.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -6, 1500.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -5, 2250.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -4, 3000.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -3, 3750.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -2, 4500.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, -1, 5250.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 0, 6000.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 1, 3000.0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 2, 0)
        ], dtype=ensure_dt_bytes([
             ('SimId','O'), ('AgentId', '<i8'), ('Time','<i8'),
             ('CashFlow', '<f8')]))
        )
    power = pd.DataFrame(np.array([
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 12, 3),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 12, 4),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 20, 12, 5),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 5.5, 210),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 5.5, 211),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 5.5, 212),
          (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 5.5, 213)
          ], dtype=ensure_dt_bytes([
                  ('SimId', 'O'), ('AgentId', '<i8'), ('Value', '<f8'),
                  ('Time', '<i8')]))
          )
    entry = pd.DataFrame(np.array([
          (13, ':cycamore:Reactor', 210),
          (20, ':cycamore:Reactor', 3),
          (4, ':cycamore:Sink', 1)
          ], dtype=ensure_dt_bytes([('AgentId', '<i8'), ('Spec', 'O'),
                  ('EnterTime', '<i8')]))
          )
    s1 = power.set_index(['SimId', 'AgentId', 'Value'])['Time']
    s2 = entry.set_index(['AgentId', 'Spec'])['EnterTime']
    series = [s1, s2]
    obs = eco_metrics.capital_cost.func(series)
    assert_frame_equal(exp, obs)
Пример #32
0
def test_inventories(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = filters.inventories(evaler)
    exp_head = ['SimId', 'AgentId', 'Prototype',
                'Time', 'InventoryName', 'NucId', 'Quantity', 'Units']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    if not HAVE_PYNE:
        raise SkipTest
    cal = filters.inventories(evaler, facilities=['Reactor1'],
                                   nucs=['94239'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(np.array([
        (15, 'Reactor1', 1, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442),
        (15, 'Reactor1', 3, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885),
        (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327)
    ], dtype=ensure_dt_bytes([
        ('AgentId', '<i8'), ('Prototype', 'O'), ('Time', '<i8'),
        ('InventoryName', 'O'), ('NucId', '<i8'), ('Quantity', '<f8'),
        ('Units', '0')
    ]))
    )
    assert_frame_equal(cal, refs)

    cal = filters.inventories(evaler, facilities=['Reactor1'],
                                   nucs=['94239', '92235'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(np.array([
        (15, 'Reactor1', 1, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 1, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 2, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'spent', 922350000, 0.00884955752212),
        (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442),
        (15, 'Reactor1', 3, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 3, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 3, 'spent', 922350000, 0.0176991150442),
        (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885),
        (15, 'Reactor1', 4, 'core',  922350000, 0.04),
        (15, 'Reactor1', 4, 'spent', 922350000, 0.0265486725664),
        (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327)
    ], dtype=ensure_dt_bytes([
        ('AgentId', '<i8'), ('Prototype', 'O'), ('Time', '<i8'),
        ('InventoryName', 'O'), ('NucId', '<i8'), ('Quantity', '<f8'),
        ('Units', '0')

    ]))
    )
    assert_frame_equal(cal, refs)
Пример #33
0
def test_timelist():
    exp = pd.DataFrame(
        np.array([(UUID('f22f2281-2464-420a-8325-37320fd418f8'), 0),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1),
                  (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 0),
                  (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 1)],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('TimeStep', '<i8')])))
    info = pd.DataFrame(
        np.array([(UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2),
                  (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 2)],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('Duration', '<i8')])))
    obs = metrics.timelist.func(info)
    assert_frame_equal(exp, obs)
Пример #34
0
def test_fco_electricity_generated():
    exp = pd.DataFrame(
        np.array([(0, 3), (1, 3)],
                 dtype=ensure_dt_bytes([('Year', '<i8'), ('Energy', '<f8')])))
    eg = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 1000),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 2000),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 3000),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Year', '<i8'), ('Energy', '<f8')])))
    obs = fco_metrics.fco_electricity_generated.func(eg)
    assert_frame_equal(exp, obs)
Пример #35
0
def test_inventories(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = filters.inventories(evaler)
    exp_head = ['SimId', 'AgentId', 'Prototype',
                'Time', 'InventoryName', 'NucId', 'Quantity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    if not HAVE_PYNE:
        raise SkipTest
    cal = filters.inventories(evaler, facilities=['Reactor1'],
                                   nucs=['94239'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(np.array([
        (15, 'Reactor1', 1, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442),
        (15, 'Reactor1', 3, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885),
        (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327)
    ], dtype=ensure_dt_bytes([
        ('AgentId', '<i8'), ('Prototype', 'O'), ('Time', '<i8'),
        ('InventoryName', 'O'), ('NucId', '<i8'), ('Quantity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    cal = filters.inventories(evaler, facilities=['Reactor1'],
                                   nucs=['94239', '92235'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(np.array([
        (15, 'Reactor1', 1, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 1, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 2, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 2, 'spent', 922350000, 0.00884955752212),
        (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442),
        (15, 'Reactor1', 3, 'core',  922350000, 0.00157922442534),
        (15, 'Reactor1', 3, 'core',  942390000, 0.0444814879803),
        (15, 'Reactor1', 3, 'spent', 922350000, 0.0176991150442),
        (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885),
        (15, 'Reactor1', 4, 'core',  922350000, 0.04),
        (15, 'Reactor1', 4, 'spent', 922350000, 0.0265486725664),
        (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327)
    ], dtype=ensure_dt_bytes([
        ('AgentId', '<i8'), ('Prototype', 'O'), ('Time', '<i8'),
        ('InventoryName', 'O'), ('NucId', '<i8'), ('Quantity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #36
0
def test_fco_electricity_gen():
    exp = pd.DataFrame(np.array([(0, 3), (1, 10)], 
        dtype=ensure_dt_bytes([('Year', '<i8'), ('Power', '<f8')]))
        )
    tsp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 3, 1000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 3, 2000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 12, 10000),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'), 
                ('Value', '<f8')]))
        )
    series = [tsp.set_index(['SimId', 'AgentId', 'Time'])['Value']]
    obs = metrics.fco_electricity_gen.func(series)
    assert_frame_equal(exp, obs)
Пример #37
0
def test_fco_electricity_gen():
    exp = pd.DataFrame(np.array([(0, 3), (1, 10)], 
        dtype=ensure_dt_bytes([('Year', '<i8'), ('Power', '<f8')]))
        )
    tsp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 3, 1000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 3, 2000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 12, 10000),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'), 
                ('Value', '<f8')]))
        )
    series = [tsp.set_index(['SimId', 'AgentId', 'Time'])['Value']]
    obs = metrics.fco_electricity_gen.func(series)
    assert_frame_equal(exp, obs)
Пример #38
0
def test_fco_electricity_generated():
    exp = pd.DataFrame(np.array([(0, 3), (1, 10)], dtype=ensure_dt_bytes([("Year", "<i8"), ("Power", "<f8")])))
    tsp = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 1, 3, 1000),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 2, 3, 2000),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 3, 12, 10000),
            ],
            dtype=ensure_dt_bytes([("SimId", "O"), ("AgentId", "<i8"), ("Time", "<i8"), ("Value", "<f8")]),
        )
    )
    series = [tsp.set_index(["SimId", "AgentId", "Time"])["Value"]]
    obs = metrics.fco_electricity_generated.func(series)
    assert_frame_equal(exp, obs)
Пример #39
0
def test_decayheat():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922350000, 2.3944723480343003e-12),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922380000, 1.6505536389997207e-11),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 942390000, 1.92784802432412e-08),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("DecayHeat", "<f8"),
                ]
            ),
        )
    )

    act = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922350000, 3197501.3876324706),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922380000, 24126337.066086654),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 942390000, 22949993169.28023),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Activity", "<f8"),
                ]
            ),
        )
    )

    series = [act.set_index(["SimId", "QualId", "ResourceId", "ObjId", "TimeCreated", "NucId"])["Activity"]]
    obs = metrics.decay_heat.func(series)
    assert_frame_equal(exp, obs)
Пример #40
0
def test_timelist():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 0),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1),
        (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 0),
        (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 1)
        ], dtype=ensure_dt_bytes([('SimId', 'O'), ('TimeStep', '<i8')]))
        )
    info = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2),
        (UUID('f2952c34-0a0e-47df-b495-6f9afc351d1b'), 2)
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('Duration', '<i8')]))
        )
    obs = metrics.timelist.func(info)
    assert_frame_equal(exp, obs)
Пример #41
0
def test_fco_electricity_generated():
    exp = pd.DataFrame(np.array([(0, 3),
				 (1, 3)
	], dtype=ensure_dt_bytes([
	        ('Year', '<i8'), ('Energy', '<f8')]))
        )
    eg = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 1000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 2000),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 3000),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Year', '<i8'),
                ('Energy', '<f8')]))
        )
    obs = fco_metrics.fco_electricity_generated.func(eg)
    assert_frame_equal(exp, obs)
Пример #42
0
def test_activity():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922350000, 3197501.3876324706),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922380000, 24126337.066086654),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 942390000, 22949993169.28023),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Activity", "<f8"),
                ]
            ),
        )
    )

    mass = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922350000, 0.04),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 922380000, 1.94),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 9, 7, 1, 942390000, 0.01),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Mass", "<f8"),
                ]
            ),
        )
    )
    series = [mass.set_index(["SimId", "QualId", "ResourceId", "ObjId", "TimeCreated", "NucId"])["Mass"]]
    obs = metrics.activity.func(series)
    assert_frame_equal(exp, obs)
Пример #43
0
def test_fco_swu():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array([(0, 0.002407), (1, 0.001473)], dtype=ensure_dt_bytes([("Year", "<i8"), ("SWU", "<f8")]))
    )
    mats = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 7, 3, 3, 922350000, 8.328354),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 7, 3, 3, 922380000, 325.004979),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 6, 8, 4, 3, 922350000, 11.104472),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 6, 8, 4, 3, 922380000, 322.228861),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 7, 9, 5, 12, 922350000, 11.104472),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 7, 9, 5, 12, 922380000, 322.228861),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Mass", "<f8"),
                ]
            ),
        )
    )
    trans = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 1, 7, "LWR Fuel"),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 2, 8, "LWR Fuel"),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 3, 9, "LWR Fuel"),
            ],
            dtype=ensure_dt_bytes(
                [("SimId", "O"), ("TransactionId", "<i8"), ("ResourceId", "<i8"), ("Commodity", "O")]
            ),
        )
    )
    s1 = mats.set_index(["SimId", "QualId", "ResourceId", "ObjId", "TimeCreated", "NucId"])["Mass"]
    s2 = trans.set_index(["SimId", "TransactionId", "ResourceId"])["Commodity"]
    series = [s1, s2]
    obs = metrics.fco_swu.func(series)
    np.allclose(exp, obs)
Пример #44
0
def test_fco_fuel_loading():
    exp = pd.DataFrame(
        np.array([(0, 0.666666), (1, 0.333333)], dtype=ensure_dt_bytes([("Year", "<i8"), ("FuelLoading", "<f8")]))
    )
    mats = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 7, 3, 3, 922350000, 8.328354),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 5, 7, 3, 3, 922380000, 325.004979),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 6, 8, 4, 3, 922350000, 11.104472),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 6, 8, 4, 3, 922380000, 322.228861),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 7, 9, 5, 12, 922350000, 11.104472),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 7, 9, 5, 12, 922380000, 322.228861),
            ],
            dtype=ensure_dt_bytes(
                [
                    ("SimId", "O"),
                    ("QualId", "<i8"),
                    ("ResourceId", "<i8"),
                    ("ObjId", "<i8"),
                    ("TimeCreated", "<i8"),
                    ("NucId", "<i8"),
                    ("Mass", "<f8"),
                ]
            ),
        )
    )
    trans = pd.DataFrame(
        np.array(
            [
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 1, 7, "LWR Fuel"),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 2, 8, "FR Fuel"),
                (UUID("f22f2281-2464-420a-8325-37320fd418f8"), 3, 9, "FR Fuel"),
            ],
            dtype=ensure_dt_bytes(
                [("SimId", "O"), ("TransactionId", "<i8"), ("ResourceId", "<i8"), ("Commodity", "O")]
            ),
        )
    )
    s1 = mats.set_index(["SimId", "QualId", "ResourceId", "ObjId", "TimeCreated", "NucId"])["Mass"]
    s2 = trans.set_index(["SimId", "TransactionId", "ResourceId"])["Commodity"]
    series = [s1, s2]
    obs = metrics.fco_fuel_loading.func(series)
    assert_frame_equal(exp, obs)
Пример #45
0
def test_inventory_quantity_per_gwe():
    # exp is the expected output metrics
    exp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 'core',
             922350000, 1.0),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 'usedfuel',
             922350000, 2.0),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 'core',
             922350000, 2.0),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'),
                     ('InventoryName', 'O'), ('NucId', '<i8'),
                     ('Quantity', '<f8')
                 ])))
    # tsp is the TimeSeriesPower metrics
    tsp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 100),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 200),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 100),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Time', '<i8'), ('Value', '<f8')])))
    # inv is the ExplicitInventory metrics
    inv = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 'core',
             922350000, 300),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 'usedfuel',
             922350000, 600),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 'core',
             922350000, 200),
        ],
                 dtype=ensure_dt_bytes([
                     ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'),
                     ('InventoryName', 'O'), ('NucId', '<i8'),
                     ('Quantity', '<f8')
                 ])))
    obs = metrics.inventory_quantity_per_gwe.func(inv, tsp)
    assert_frame_equal(exp, obs)
Пример #46
0
def test_monthly_electricity_generated_by_agent():
    exp = pd.DataFrame(
        np.array([(UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 100),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 100),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 200),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 200),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 400)],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Month', '<i8'), ('Energy', '<f8')])))
    tsp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 100),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 200),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 100),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 200),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 400),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Time', '<i8'), ('Value', '<f8')])))
    obs = metrics.monthly_electricity_generated_by_agent.func(tsp)
    assert_frame_equal(exp, obs)
Пример #47
0
def test_annual_electricity_generated_by_agent():
    exp = pd.DataFrame(
        np.array([(UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 100),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 100),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 200),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 200),
                  (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 400)],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Year', '<i8'), ('Energy', '<f8')])))
    tsp = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 3, 1200),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 3, 2400),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 12, 1200),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 12, 2400),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 12, 4800),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('AgentId', '<i8'),
                                        ('Time', '<i8'), ('Value', '<f8')])))
    series = [tsp.set_index(['SimId', 'AgentId', 'Time'])['Value']]
    obs = metrics.annual_electricity_generated_by_agent.func(series)
    assert_frame_equal(exp, obs)
Пример #48
0
def test_activity():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 3197501.3876324706),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 24126337.066086654),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 22949993169.28023),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'),
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Activity', '<f8')]))
        )

    mass = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 0.04),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 1.94),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 0.01),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'),
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Mass', '<f8')]))
        )
    obs = metrics.activity.func(mass)
    assert_frame_equal(exp, obs)
Пример #49
0
def test_operation_maintenance():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 0, 232.3),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 2, 232.3),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 8, 400)
        ], dtype=ensure_dt_bytes([
             ('SimId','O'), ('AgentId', '<i8'), ('Time', '<i8'),
             ('O&MPayment','<f8')]))
        )
    power = pd.DataFrame(np.array([
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 2, 2.323),
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 3, 2.323),
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 13, 32, 2.323),
              (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 100, 4)
              ], dtype=ensure_dt_bytes([
                      ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'),
                      ('Value', '<f8')]))
              )
    s1 = power.set_index(['SimId', 'AgentId', 'Time'])['Value']
    series = [s1]
    obs = eco_metrics.operation_maintenance.func(series)
    assert_frame_equal(exp, obs)
Пример #50
0
def test_fco_u_mined():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(
        np.array([(0, 3.780034), (1, 2.185349)],
                 dtype=ensure_dt_bytes([('Year', '<i8'), ('UMined', '<f8')])))
    mats = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3,
             922350000, 8.328354),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 7, 3, 3,
             922380000, 325.004979),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3,
             922350000, 11.104472),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 6, 8, 4, 3,
             922380000, 322.228861),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12,
             922350000, 11.104472),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 7, 9, 5, 12,
             922380000, 322.228861),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'), ('QualId', '<i8'),
                                        ('ResourceId', '<i8'), ('ObjId',
                                                                '<i8'),
                                        ('TimeCreated', '<i8'),
                                        ('NucId', '<i8'), ('Mass', '<f8')])))
    trans = pd.DataFrame(
        np.array([
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 7, 'LWR Fuel'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 8, 'LWR Fuel'),
            (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 9, 'LWR Fuel'),
        ],
                 dtype=ensure_dt_bytes([('SimId', 'O'),
                                        ('TransactionId', '<i8'),
                                        ('ResourceId', '<i8'),
                                        ('Commodity', 'O')])))
    obs = fco_metrics.fco_u_mined.func(mats, trans)
    assert_frame_equal(exp, obs)
Пример #51
0
def test_decayheat():
    if not HAVE_PYNE:
        raise SkipTest
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 9.3280119931e+25),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 6.42996948889e+26),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 7.51020971553e+29),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'),
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('DecayHeat', '<f8')]))
        )

    act = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922350000, 3197501.3876324706),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 922380000, 24126337.066086654),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 5, 9, 7, 1, 942390000, 22949993169.28023),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('QualId', '<i8'), ('ResourceId', '<i8'), ('ObjId', '<i8'),
                ('TimeCreated', '<i8'), ('NucId', '<i8'), ('Activity', '<f8')]))
        )

    obs = metrics.decay_heat.func(act)
    assert_frame_equal(exp, obs)
Пример #52
0
def test_annual_electricity_generated_by_agent():
    exp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 0, 100),
	    (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 1, 100),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 0, 200),
	    (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 1, 200),
	    (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 1, 400)
	], dtype=ensure_dt_bytes([
	        ('SimId', 'O'), ('AgentId', '<i8'), ('Year', '<i8'),
    		('Energy', '<f8')]))
        )
    tsp = pd.DataFrame(np.array([
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 3, 1200),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 3, 2400),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 1, 12, 1200),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 2, 12, 2400),
        (UUID('f22f2281-2464-420a-8325-37320fd418f8'), 3, 12, 4800),
        ], dtype=ensure_dt_bytes([
                ('SimId', 'O'), ('AgentId', '<i8'), ('Time', '<i8'),
                ('Value', '<f8')]))
        )
    obs = metrics.annual_electricity_generated_by_agent.func(tsp)
    assert_frame_equal(exp, obs)
Пример #53
0
def test_timeseries_transactions_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.transactions_decayheat(evaler)
    exp_head = ['Time', 'DecayHeat']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = ts.transactions_decayheat(
        evaler, nucs=['942390000'])
    refs = pd.DataFrame(np.array([
        (0, 0.000000000),
        (1, 3.34065303191e+30),
        (2, 6.68130606382e+30),
        (3, 6.68130606382e+30),
        (4, 6.68130606382e+30),
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('DecayHeat', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = ts.transactions_decayheat(
        evaler, nucs=['942390000', '922380000'])
    refs = pd.DataFrame(np.array([
        (0, 0.000000000),
        (1, 3.34091395721e+30),
        (2, 6.68182791443e+30),
        (3, 6.68214609848e+30),
        (4, 6.68214609848e+30),
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('DecayHeat', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #54
0
def test_timeseries_transactions_activity(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = ts.transactions_activity(evaler)
    exp_head = ['Time', 'Activity']
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = ts.transactions_activity(
        evaler, nucs=['942390000'])
    refs = pd.DataFrame(np.array([
        (0, 0.000000000),
        (1, 102084984531.0),
        (2, 204169969062.0),
        (3, 204169969062.0),
        (4, 204169969062.0),
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Activity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = ts.transactions_activity(
        evaler, nucs=['942390000', '922380000'])
    refs = pd.DataFrame(np.array([
        (0, 0.000000000),
        (1, 102094774891.0),
        (2, 204189549782.0),
        (3, 204201488588.0),
        (4, 204201488588.0),
    ], dtype=ensure_dt_bytes([
        ('Time', '<i8'), ('Activity', '<f8')
    ]))
    )
    assert_frame_equal(cal, refs)
Пример #55
0
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)
Пример #56
0
def test_transactions_nuc(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = filters.transactions_nuc(evaler)
    exp_head = [
        'SimId', 'ResourceId', 'NucId', 'Mass', 'ReceiverId',
        'ReceiverPrototype', 'SenderId', 'SenderPrototype', 'TransactionId',
        'Commodity', 'Time'
    ]
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    if not HAVE_PYNE:
        raise SkipTest
    # test single nuclide selection
    cal = filters.transactions_nuc(evaler, nucs=['942390000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)
    refs = pd.DataFrame(
        np.array([
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 0.0444814879803, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('Mass', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    # refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = filters.transactions_nuc(evaler, nucs=['942390000', '922380000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)
    refs = pd.DataFrame(
        np.array([
            (922380000, 0.7872433760310, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (922380000, 0.7872433760310, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 0.7872433760310, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 0.7872433760310, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 0.0444814879803, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 0.7872433760310, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 0.7872433760310, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 0.0444814879803, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 0.7872433760310, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 0.0444814879803, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 0.9600000000000, 17, 'Reactor3', 13, 'UOX_Source',
             'uox', 3),
            (922380000, 0.9600000000000, 15, 'Reactor1', 13, 'UOX_Source',
             'uox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('Mass', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    # refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)
Пример #57
0
def test_inventories_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = filters.inventories_decayheat(evaler)
    exp_head = [
        'SimId', 'AgentId', 'Prototype', 'Time', 'InventoryName', 'NucId',
        'Quantity', 'Activity', 'DecayHeat'
    ]
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    cal = filters.inventories_decayheat(evaler,
                                        facilities=['Reactor1'],
                                        nucs=['94239'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([(15, 'Reactor1', 1, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 2, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442,
                   9.71016906463e+12, 3.17757855136e+32),
                  (15, 'Reactor1', 3, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885,
                   1.94203381293e+13, 6.35515710272e+32),
                  (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327,
                   2.91305071939e+13, 9.53273565408e+32)],
                 dtype=ensure_dt_bytes([('AgentId', '<i8'), ('Prototype', 'O'),
                                        ('Time', '<i8'),
                                        ('InventoryName', 'O'),
                                        ('NucId', '<i8'), ('Quantity', '<f8'),
                                        ('Activity', '<f8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)

    cal = filters.inventories_decayheat(evaler,
                                        facilities=['Reactor1'],
                                        nucs=['94239', '92235'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([(15, 'Reactor1', 1, 'core', 922350000, 0.00157922442534,
                   29671782.9213, 8.65609466244e+26),
                  (15, 'Reactor1', 1, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 2, 'core', 922350000, 0.00157922442534,
                   29671782.9213, 8.65609466244e+26),
                  (15, 'Reactor1', 2, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 2, 'spent', 922350000, 0.00884955752212,
                   166272852.378, 4.85064734329e+27),
                  (15, 'Reactor1', 2, 'spent', 942390000, 0.0176991150442,
                   9.71016906463e+12, 3.17757855136e+32),
                  (15, 'Reactor1', 3, 'core', 922350000, 0.00157922442534,
                   29671782.9213, 8.65609466244e+26),
                  (15, 'Reactor1', 3, 'core', 942390000, 0.0444814879803,
                   2.44036364223e+13, 7.98590335085e+32),
                  (15, 'Reactor1', 3, 'spent', 922350000, 0.0176991150442,
                   332545704.756, 9.70129468658e+27),
                  (15, 'Reactor1', 3, 'spent', 942390000, 0.0353982300885,
                   1.94203381293e+13, 6.35515710272e+32),
                  (15, 'Reactor1', 4, 'core', 922350000, 0.04, 751553292.748,
                   2.19249259917e+28),
                  (15, 'Reactor1', 4, 'spent', 922350000, 0.0265486725664,
                   498818557.134, 1.45519420299e+28),
                  (15, 'Reactor1', 4, 'spent', 942390000, 0.0530973451327,
                   2.91305071939e+13, 9.53273565408e+32)],
                 dtype=ensure_dt_bytes([('AgentId', '<i8'), ('Prototype', 'O'),
                                        ('Time', '<i8'),
                                        ('InventoryName', 'O'),
                                        ('NucId', '<i8'), ('Quantity', '<f8'),
                                        ('Activity', '<f8'),
                                        ('DecayHeat', '<f8')])))
    assert_frame_equal(cal, refs)
Пример #58
0
def test_transactions_decayheat(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = filters.transactions_decayheat(evaler)
    exp_head = [
        'SimId', 'ResourceId', 'NucId', 'DecayHeat', 'ReceiverId',
        'ReceiverPrototype', 'SenderId', 'SenderPrototype', 'TransactionId',
        'Commodity', 'Time'
    ]
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = filters.transactions_decayheat(evaler, nucs=['942390000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)
    refs = pd.DataFrame(
        np.array([
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 3.34065303191e+30, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('DecayHeat', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = filters.transactions_decayheat(evaler,
                                         nucs=['942390000', '922380000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)
    refs = pd.DataFrame(
        np.array([
            (922380000, 2.609253035160e26, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (922380000, 2.609253035160e26, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 2.609253035160e26, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 2.609253035160e26, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 3.34065303191e+30, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 2.609253035160e26, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 2.609253035160e26, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 3.34065303191e+30, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 2.609253035160e26, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 3.34065303191e+30, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 3.18184057182e+26, 17, 'Reactor3', 13, 'UOX_Source',
             'uox', 3),
            (922380000, 3.18184057182e+26, 15, 'Reactor1', 13, 'UOX_Source',
             'uox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('DecayHeat', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    assert_frame_equal(cal, refs)
Пример #59
0
def test_transactions(db, fname, backend):
    evaler = cym.Evaluator(db)
    cal = filters.transactions(evaler)
    exp_head = [
        'SimId', 'ReceiverId', 'ReceiverPrototype', 'SenderId',
        'SenderPrototype', 'TransactionId', 'ResourceId', 'Commodity', 'Time'
    ]
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # SimId et al. change at each test need to drop it
    drop_cols = [
        'SimId', 'TransactionId', 'ResourceId', 'ReceiverId', 'SenderId'
    ]
    cal = cal.drop(drop_cols, axis=1)
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 2),
            ('Reactor2', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 4),
            ('Reactor3', 'UOX_Source', 'uox', 3),
            ('Reactor3', 'MOX_Source', 'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test single sender
    cal = filters.transactions(evaler, senders=['UOX_Source'])
    cal = cal.drop(drop_cols, axis=1)
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor3', 'UOX_Source', 'uox', 3),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test multiple sender
    cal = filters.transactions(evaler, senders=['UOX_Source', 'MOX_Source'])
    cal = cal.drop(drop_cols, axis=1)
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 2),
            ('Reactor2', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 4),
            ('Reactor3', 'UOX_Source', 'uox', 3),
            ('Reactor3', 'MOX_Source', 'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test single receiver
    cal = filters.transactions(evaler, receivers=['Reactor1'])
    cal = cal.drop(drop_cols, 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test multiple sender
    cal = filters.transactions(evaler, receivers=['Reactor1', 'Reactor3'])
    cal = cal.drop(drop_cols, 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
            ('Reactor3', 'UOX_Source', 'uox', 3),
            ('Reactor3', 'MOX_Source', 'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test multiple sender and multiple receiver
    cal = filters.transactions(evaler,
                               senders=['UOX_Source', 'MOX_Source'],
                               receivers=['Reactor1', 'Reactor2'])
    cal = cal.drop(drop_cols, 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 2),
            ('Reactor2', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test single filters.odity
    cal = filters.transactions(evaler, commodities=['uox'])
    cal = cal.drop(drop_cols, 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor3', 'UOX_Source', 'uox', 3),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)

    # test multiple sender
    cal = filters.transactions(evaler, commodities=['uox', 'mox'])
    cal = cal.drop(drop_cols, 1)  # SimId change at each test need to drop it
    refs = pd.DataFrame(
        np.array([
            ('Reactor1', 'UOX_Source', 'uox', 4),
            ('Reactor1', 'MOX_Source', 'mox', 1),
            ('Reactor1', 'MOX_Source', 'mox', 2),
            ('Reactor1', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 2),
            ('Reactor2', 'MOX_Source', 'mox', 3),
            ('Reactor2', 'MOX_Source', 'mox', 4),
            ('Reactor3', 'UOX_Source', 'uox', 3),
            ('Reactor3', 'MOX_Source', 'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('ReceiverPrototype', 'O'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    refs.index = refs.index.astype('str')
    assert_frame_equal(cal, refs)
Пример #60
0
def test_transactions_activity(db, fname, backend):
    if not HAVE_PYNE:
        raise SkipTest
    evaler = cym.Evaluator(db)
    cal = filters.transactions_activity(evaler)
    exp_head = [
        'SimId', 'ResourceId', 'NucId', 'Activity', 'ReceiverId',
        'ReceiverPrototype', 'SenderId', 'SenderPrototype', 'TransactionId',
        'Commodity', 'Time'
    ]
    assert_equal(list(cal), exp_head)  # Check we have the correct headers

    # test single nuclide selection
    cal = filters.transactions_activity(evaler, nucs=['942390000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)
    refs = pd.DataFrame(
        np.array([
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 102084984531.0, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('Activity', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    assert_frame_equal(cal, refs)

    # test multiple nuclide selection
    cal = filters.transactions_activity(evaler,
                                        nucs=['942390000', '922380000'])
    cal = cal.drop('SimId', 1)  # SimId change at each test need to drop it
    # SimId change at each test need to drop it
    cal = cal.drop('TransactionId', 1)
    # SimId change at each test need to drop it
    cal = cal.drop('ResourceId', 1)

    refs = pd.DataFrame(
        np.array([
            (922380000, 9790360.331530, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 1),
            (922380000, 9790360.331530, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 9790360.331530, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 2),
            (922380000, 9790360.331530, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 102084984531.0, 15, 'Reactor1', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 9790360.331530, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 3),
            (922380000, 9790360.331530, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 102084984531.0, 16, 'Reactor2', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 9790360.331530, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (942390000, 102084984531.0, 17, 'Reactor3', 14, 'MOX_Source',
             'mox', 4),
            (922380000, 11938805.97080, 17, 'Reactor3', 13, 'UOX_Source',
             'uox', 3),
            (922380000, 11938805.97080, 15, 'Reactor1', 13, 'UOX_Source',
             'uox', 4),
        ],
                 dtype=ensure_dt_bytes([('NucId', '<i8'), ('Activity', '<f8'),
                                        ('ReceiverId', '<i8'),
                                        ('ReceiverPrototype', 'O'),
                                        ('SenderId', '<i8'),
                                        ('SenderPrototype', 'O'),
                                        ('Commodity', 'O'), ('Time', '<i8')])))
    assert_frame_equal(cal, refs)