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")
HEAT = importr('heat')

# Global variables
seed(12345)
store = HDFStore('materials.h5')
D = store["elements"]
# Definition of possible construction periods as define in the regional
# material catalogue.
years = ["bis 1918", "bis 1948", "1949 bis 1957",
         "1958 bis 1968", "1969 bis 1978"]

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

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])]


def get_masea_uval(component, verbose=False):
    """Get MASEA based u-value for given component."""
    if verbose:
        print(component)
    MaterialsToGet = robjects.StrVector(component["name"].tolist())
    Thicknes = robjects.FloatVector(component["Thickness"].div(100).tolist())
    Layers = HEAT.getLayers(MaterialsToGet, Thicknes)
    if verbose: