def computeEmbodiedEnergy():
    """Compute the embodied energy of buildings in file buildings.csv."""

    oeko = getData_oeko()
    OEKO = oeko[([((("WDVS" in o_name) & ("Steinwolle" in o_name)) |
                (("WDVS" in o_name) & ("EPS" in o_name) &
                    ("Daemmplatte" in o_name)) &
                ("End of life" not in o_name) | ("XPS" in o_name))
        for o_name in oeko.name])]

    masea = getData_masea()
    MASEA = masea[(masea.name == "Steinwolle_60") |
                  (masea.name == "EPS_040.15") |
                  (masea.name == "XPS_Deckschicht 3")]

    buildings = pd.read_csv("buildings.csv", index_col=0)
    buildings["shell_roof"] = buildings["shell"] - buildings["shell_wall"]

    for a, b, c in zip([610, 480, 482],
                       [69, 82, 165],
                       ["Steinwolle", "XPS", "EPS"]):
        pos1 = OEKO.loc[a]
        pos2 = MASEA.loc[b]
        for width in [0.12, 0.24]:
            buildings = getGEnergy(buildings, pos1, pos2, width, c,
                                   verbose=False)

    buildings.to_csv("buildings_genergy.csv")
"""

import pandas as pd
from pandas import HDFStore
from random import choice
# internal
from scripts.MASEA import getData_masea
from scripts.MASEA import masea_single
from scripts.MASEA import masea_multiple
from scripts.findMaterials import getMaterialIndex
from scripts.findMaterials import materials

store = HDFStore('materials.h5')

masea = getData_masea()


def getMasea(data_element, verbose=False, extra=False, weight=1, iterations=False, component_index=False, force_index=False):

    if not component_index:
        inx = 0
    else:
        inx = component_index
    layers = store["table_{}".format(data_element.iloc[inx, 1].split(".")[0])]
    layers.set_index("Material", inplace=True)
    thikness = layers["Width"]

    indexed_layers = pd.DataFrame(columns=[
        "Material", "Density", "Conductivity"])
    if verbose: