Exemple #1
0
def transactions(evaler, senders=(), receivers=(), commodities=()):
    """
    Filter the Transaction Data Frame on specific sending facility and
    receving facility.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    """

    # initiate evaluation
    trans = evaler.eval('Transactions')
    agents = evaler.eval('AgentEntry')

    rec_agent = agents.rename(index=str, columns={'AgentId': 'ReceiverId'})
    if len(receivers) != 0:
        rec_agent = rec_agent[rec_agent['Prototype'].isin(receivers)]

    send_agent = agents.rename(index=str, columns={'AgentId': 'SenderId'})
    if len(senders) != 0:
        send_agent = send_agent[send_agent['Prototype'].isin(senders)]

    # check if sender and receiver exist
    if rec_agent.empty or send_agent.empty:
        return None

    # Clean Transation PDF
    rdc_table = []
    rdc_table.append(['ReceiverId', rec_agent['ReceiverId'].tolist()])
    rdc_table.append(['SenderId', send_agent['SenderId'].tolist()])
    if len(commodities) != 0:
        rdc_table.append(['Commodity', commodities])

    trans = reduce(trans, rdc_table)

    # Merge Sender to Transaction PDF
    base_col = ['SimId', 'SenderId']
    added_col = base_col + ['Prototype']
    trans = merge(trans, base_col, send_agent, added_col)
    trans = trans.rename(index=str, columns={'Prototype': 'SenderPrototype'})

    # Merge Receiver to Transaction PDF
    base_col = ['SimId', 'ReceiverId']
    added_col = base_col + ['Prototype']
    trans = merge(trans, base_col, rec_agent, added_col)
    trans = trans.rename(index=str, columns={'Prototype': 'ReceiverPrototype'})

    return trans
Exemple #2
0
def transactions(evaler, senders=(), receivers=(), commodities=()):
    """
    Filter the Transaction Data Frame on specific sending facility and
    receving facility.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    """

    # initiate evaluation
    trans = evaler.eval('Transactions')
    agents = evaler.eval('AgentEntry')

    rec_agent = agents.rename(index=str, columns={'AgentId': 'ReceiverId'})
    if len(receivers) != 0:
        rec_agent = rec_agent[rec_agent['Prototype'].isin(receivers)]

    send_agent = agents.rename(index=str, columns={'AgentId': 'SenderId'})
    if len(senders) != 0:
        send_agent = send_agent[send_agent['Prototype'].isin(senders)]

    # Clean Transation PDF
    rdc_table = []
    rdc_table.append(['ReceiverId', rec_agent['ReceiverId'].tolist()])
    rdc_table.append(['SenderId', send_agent['SenderId'].tolist()])
    if len(commodities) != 0:
        rdc_table.append(['Commodity', commodities])

    trans = reduce(trans, rdc_table)

    # Merge Sender to Transaction PDF
    base_col = ['SimId', 'SenderId']
    added_col = base_col + ['Prototype']
    trans = merge(trans, base_col, send_agent, added_col)
    trans = trans.rename(index=str, columns={
                         'Prototype': 'SenderPrototype'})

    # Merge Receiver to Transaction PDF
    base_col = ['SimId', 'ReceiverId']
    added_col = base_col + ['Prototype']
    trans = merge(trans, base_col, rec_agent, added_col)
    trans = trans.rename(index=str, columns={
                         'Prototype': 'ReceiverPrototype'})

    return trans
Exemple #3
0
def transactions_nuc(evaler, senders=(), receivers=(), commodities=(),
                     nucs=()):
    """
    Filter the Transaction Data Frame, which include nuclide composition, on
    specific sending facility and receving facility. Applying nuclides
    selection when required.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    nucs :  of nuclide to select.
    """

    compo = evaler.eval('Materials')

    df = transactions(evaler, senders, receivers, commodities)

    if len(nucs) != 0:
        nucs = format_nucs(nucs)
        compo = reduce(compo, [['NucId', nucs]])

    base_col = ['SimId', 'ResourceId']
    added_col = base_col + ['NucId', 'Mass']
    df = merge(df, base_col, compo, added_col)

    return df
Exemple #4
0
def inventories(evaler, facilities=(), nucs=()):
    """
    Shape the reduced inventory Data Frame. Applying nuclides/facilities selection when required.

    Parameters
    ----------
    evaler : evaler
    facilities :  of the facility
    nucs :  of nuclide to select.
    """

    # Get inventory table
    df = evaler.eval('ExplicitInventory')
    agents = evaler.eval('AgentEntry')

    rdc_table = []  # because we want to get rid of the nuclide asap
    if len(nucs) != 0:
        nucs = format_nucs(nucs)
        rdc_table.append(['NucId', nucs])

    if len(facilities) != 0:
        agents = agents[agents['Prototype'].isin(facilities)]
        rdc_table.append(['AgentId', agents['AgentId'].tolist()])
    else:
        wng_msg = "no faciity provided"
        warnings.warn(wng_msg, UserWarning)
    df = reduce(df, rdc_table)

    base_col = ['SimId', 'AgentId']
    added_col = base_col + ['Prototype']
    df = merge(df, base_col, agents, added_col)

    return df
Exemple #5
0
def transactions_decayheat(evaler,
                           senders=(),
                           receivers=(),
                           commodities=(),
                           nucs=()):
    """
    Return the transation df, with the decayheat. Applying nuclides selection
    when required.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    nucs :  of nuclide to select.
    """

    df = transactions(evaler, senders, receivers, commodities)

    if len(nucs) != 0:
        nucs = format_nucs(nucs)

    compo = evaler.eval('DecayHeat')
    compo = reduce(compo, [['NucId', nucs]])

    base_col = ['SimId', 'ResourceId']
    added_col = base_col + ['NucId', 'DecayHeat']
    df = merge(df, base_col, compo, added_col)

    return df
Exemple #6
0
def transactions_nuc(evaler, senders=(), receivers=(), commodities=(), nucs=()):
    """
    Filter the Transaction Data Frame, which include nuclide composition, on
    specific sending facility and receving facility. Applying nuclides
    selection when required.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    nucs :  of nuclide to select.
    """

    compo = evaler.eval('Materials')

    df = transactions(evaler, senders, receivers, commodities)

    if len(nucs) != 0:
        nucs = format_nucs(nucs)
        compo = reduce(compo, [['NucId', nucs]])

    base_col = ['SimId', 'ResourceId']
    added_col = base_col + ['NucId', 'Mass']
    df = merge(df, base_col, compo, added_col)

    return df
Exemple #7
0
def inventories(evaler, facilities=(), nucs=()):
    """
    Shape the reduced inventory Data Frame. Applying nuclides/facilities selection when required.

    Parameters
    ----------
    evaler : evaler
    facilities :  of the facility
    nucs :  of nuclide to select.
    """

    # Get inventory table
    df = evaler.eval('ExplicitInventory')
    agents = evaler.eval('AgentEntry')

    rdc_table = []  # because we want to get rid of the nuclide asap
    if len(nucs) != 0:
        nucs = format_nucs(nucs)
        rdc_table.append(['NucId', nucs])

    if len(facilities) != 0:
        agents = agents[agents['Prototype'].isin(facilities)]
        rdc_table.append(['AgentId', agents['AgentId'].tolist()])
    else:
        wng_msg = "no faciity provided"
        warnings.warn(wng_msg, UserWarning)
    df = reduce(df, rdc_table)

    base_col = ['SimId', 'AgentId']
    added_col = base_col + ['Prototype']
    df = merge(df, base_col, agents, added_col)

    return df
Exemple #8
0
def transactions_decayheat(evaler, senders=(), receivers=(), commodities=(), nucs=()):
    """
    Return the transation df, with the decayheat. Applying nuclides selection
    when required.

    Parameters
    ----------
    evaler : evaler
    senders :  of the sending facility
    receivers :  of the receiving facility
    commodities :  of the commodity exchanged
    nucs :  of nuclide to select.
    """

    df = transactions(evaler, senders, receivers, commodities)

    if len(nucs) != 0:
        nucs = format_nucs(nucs)

    compo = evaler.eval('DecayHeat')
    compo = reduce(compo, [['NucId', nucs]])

    base_col = ['SimId', 'ResourceId']
    added_col = base_col + ['NucId', 'DecayHeat']
    df = merge(df, base_col, compo, added_col)

    return df
Exemple #9
0
def get_power(evaler, facilities=()):
    """
    Shape the reduced Power Data Frame into a simple time serie. Applying
    facilities selection when required.

    Parameters
    ----------
    evaler : evaler
    facilities :  of the facility
    """

    # Get inventory table
    df = evaler.eval('TimeSeriesPower')
    agents = evaler.eval('AgentEntry')

    rdc_ = []  # because we want to get rid of the facility asap
    if len(facilities) != 0:
        agents = agents[agents['Prototype'].isin(facilities)]
        rdc_.append(['AgentId', agents['AgentId'].tolist()])
    else:
        wng_msg = "no faciity provided"
        warnings.warn(wng_msg, UserWarning)
    df = tools.reduce(df, rdc_)

    base_col = ['SimId', 'AgentId']
    added_col = base_col + ['Prototype']
    df = tools.merge(df, base_col, agents, added_col)

    df = df[['Time', 'Value']].groupby(['Time']).sum()
    df.reset_index(inplace=True)

    time = evaler.eval('TimeList')
    df = tools.add_missing_time_step(df, time)
    return df
Exemple #10
0
def get_power(evaler, facilities=()):
    """
    Shape the reduced Power Data Frame into a simple time serie. Applying
    facilities selection when required.

    Parameters
    ----------
    evaler : evaler
    facilities :  of the facility
    """

    # Get inventory table
    df = evaler.eval('TimeSeriesPower')
    agents = evaler.eval('AgentEntry')

    rdc_ = []  # because we want to get rid of the facility asap
    if len(facilities) != 0:
        agents = agents[agents['Prototype'].isin(facilities)]
        rdc_.append(['AgentId', agents['AgentId'].tolist()])
    else:
        wng_msg = "no faciity provided"
        warnings.warn(wng_msg, UserWarning)
    df = tools.reduce(df, rdc_)

    base_col = ['SimId', 'AgentId']
    added_col = base_col + ['Prototype']
    df = tools.merge(df, base_col, agents, added_col)

    df = df[['Time', 'Value']].groupby(['Time']).sum()
    df.reset_index(inplace=True)

    time = evaler.eval('TimeList')
    df = tools.add_missing_time_step(df, time)
    return df