Skip to content

Build solar thermal profiles

build_solar_thermal_profiles(pop_map, cutout, outp_path)

build per unit solar thermal time availability profiles and save them to a file

Parameters:

Name Type Description Default
population_map DataFrame

DataFrame with the population map

required
outp_path PathLike

Path to the output file

required
Source code in workflow/scripts/build_solar_thermal_profiles.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def build_solar_thermal_profiles(
    pop_map: pd.DataFrame, cutout: atlite.Cutout, outp_path: os.PathLike
) -> None:
    """build per unit solar thermal time availability profiles and save them to a file

    Args:
        population_map (pd.DataFrame): DataFrame with the population map
        outp_path (os.PathLike): Path to the output file
    """
    pop_matrix = sp.sparse.csr_matrix(pop_map.T)
    index = pop_map.columns
    index.name = "provinces"

    st = cutout.solar_thermal(
        orientation={
            "slope": float(snakemake.config["solar_thermal_angle"]),
            "azimuth": 180.0,
        },
        matrix=pop_matrix,
        index=index,
    )

    st["time"] = (
        pd.DatetimeIndex(st["time"], tz="UTC").tz_convert(TIMEZONE).tz_localize(None).values
    )

    with pd.HDFStore(outp_path, mode="w", complevel=4) as store:
        store["solar_thermal_profiles"] = st.to_pandas().divide(pop_map.sum())