[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
d2018e1088
commit
4a1933f49a
@ -40,7 +40,6 @@ Outputs:
|
||||
References
|
||||
----------
|
||||
[1] Staffell et al., Energy & Environmental Science 11 (2012): A review of domestic heat pumps, https://doi.org/10.1039/C2EE22653G.
|
||||
|
||||
"""
|
||||
|
||||
import xarray as xr
|
||||
|
@ -3,7 +3,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""
|
||||
This rule builds heat demand time series using heating degree day (HDD) approximation.
|
||||
This rule builds heat demand time series using heating degree day (HDD)
|
||||
approximation.
|
||||
|
||||
Snapshots are resampled to daily time resolution and ``Atlite.convert.heat_demand`` is used to convert ambient temperature from the default weather cutout to heat demand time series for the respective cutout.
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""
|
||||
Build total energy demands and carbon emissions per country using JRC IDEES, eurostat, and EEA data.
|
||||
|
||||
Build total energy demands and carbon emissions per country using JRC IDEES,
|
||||
eurostat, and EEA data.
|
||||
|
||||
- Country-specific data is read in :func:`build_eurostat`, :func:`build_idees` and `build_swiss`.
|
||||
- :func:`build_energy_totals` then combines energy data from Eurostat, Swiss, and IDEES data and :func:`rescale_idees_from_eurostat` rescales IDEES data to match Eurostat data.
|
||||
@ -41,6 +41,7 @@ Outputs
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
from functools import partial
|
||||
from typing import List
|
||||
|
||||
import country_converter as coco
|
||||
import geopandas as gpd
|
||||
@ -48,7 +49,6 @@ import numpy as np
|
||||
import pandas as pd
|
||||
from _helpers import configure_logging, mute_print, set_scenario_config
|
||||
from tqdm import tqdm
|
||||
from typing import List
|
||||
|
||||
cc = coco.CountryConverter()
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -73,8 +73,8 @@ def cartesian(s1: pd.Series, s2: pd.Series) -> pd.DataFrame:
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
|
||||
>>> s2 = pd.Series([4, 5, 6], index=['d', 'e', 'f'])
|
||||
>>> s1 = pd.Series([1, 2, 3], index=["a", "b", "c"])
|
||||
>>> s2 = pd.Series([4, 5, 6], index=["d", "e", "f"])
|
||||
>>> cartesian(s1, s2)
|
||||
d e f
|
||||
a 4 5 6
|
||||
@ -83,6 +83,7 @@ def cartesian(s1: pd.Series, s2: pd.Series) -> pd.DataFrame:
|
||||
"""
|
||||
return pd.DataFrame(np.outer(s1, s2), index=s1.index, columns=s2.index)
|
||||
|
||||
|
||||
def reverse(dictionary: dict) -> dict:
|
||||
"""
|
||||
Reverses the keys and values of a dictionary.
|
||||
@ -99,7 +100,7 @@ def reverse(dictionary: dict) -> dict:
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> d = {'a': 1, 'b': 2, 'c': 3}
|
||||
>>> d = {"a": 1, "b": 2, "c": 3}
|
||||
>>> reverse(d)
|
||||
{1: 'a', 2: 'b', 3: 'c'}
|
||||
"""
|
||||
@ -174,7 +175,12 @@ def eurostat_per_country(input_eurostat: str, country: str) -> pd.DataFrame:
|
||||
return pd.concat(sheet)
|
||||
|
||||
|
||||
def build_eurostat(input_eurostat: str, countries: List[str], nprocesses: int=1, disable_progressbar: bool=False) -> pd.DataFrame:
|
||||
def build_eurostat(
|
||||
input_eurostat: str,
|
||||
countries: List[str],
|
||||
nprocesses: int = 1,
|
||||
disable_progressbar: bool = False,
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Return multi-index for all countries' energy data in TWh/a.
|
||||
|
||||
@ -270,7 +276,6 @@ def build_swiss() -> pd.DataFrame:
|
||||
"""
|
||||
Return a pd.DataFrame of Swiss energy data in TWh/a.
|
||||
|
||||
|
||||
Returns
|
||||
--------
|
||||
pd.DataFrame
|
||||
@ -519,9 +524,11 @@ def idees_per_country(ct: str, base_dir: str) -> pd.DataFrame:
|
||||
|
||||
return pd.DataFrame(ct_totals)
|
||||
|
||||
|
||||
def build_idees(countries: List[str]) -> pd.DataFrame:
|
||||
"""
|
||||
Build energy totals from IDEES database for the given list of countries using :func:`idees_per_country`.
|
||||
Build energy totals from IDEES database for the given list of countries
|
||||
using :func:`idees_per_country`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -569,9 +576,15 @@ def build_idees(countries: List[str]) -> pd.DataFrame:
|
||||
return totals
|
||||
|
||||
|
||||
def build_energy_totals(countries: List[str], eurostat: pd.DataFrame, swiss: pd.DataFrame, idees: pd.DataFrame) -> pd.DataFrame:
|
||||
def build_energy_totals(
|
||||
countries: List[str],
|
||||
eurostat: pd.DataFrame,
|
||||
swiss: pd.DataFrame,
|
||||
idees: pd.DataFrame,
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Combine energy totals for the specified countries from Eurostat, Swiss, and IDEES data.
|
||||
Combine energy totals for the specified countries from Eurostat, Swiss, and
|
||||
IDEES data.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -843,9 +856,11 @@ def build_district_heat_share(countries: List[str], idees: pd.DataFrame) -> pd.S
|
||||
return district_heat_share
|
||||
|
||||
|
||||
def build_eea_co2(input_co2: str, year: int = 1990, emissions_scope: str = "CO2") -> pd.DataFrame:
|
||||
def build_eea_co2(
|
||||
input_co2: str, year: int = 1990, emissions_scope: str = "CO2"
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Calculate CO2 emissions for a given year based on EEA data in Mt
|
||||
Calculate CO2 emissions for a given year based on EEA data in Mt.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -923,7 +938,8 @@ def build_eea_co2(input_co2: str, year: int = 1990, emissions_scope: str = "CO2"
|
||||
|
||||
def build_eurostat_co2(eurostat: pd.DataFrame, year: int = 1990) -> pd.Series:
|
||||
"""
|
||||
Calculate CO2 emissions for a given year based on Eurostat fuel consumption data and fuel-specific emissions.
|
||||
Calculate CO2 emissions for a given year based on Eurostat fuel consumption
|
||||
data and fuel-specific emissions.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -965,7 +981,9 @@ def build_eurostat_co2(eurostat: pd.DataFrame, year: int = 1990) -> pd.Series:
|
||||
return eurostat_year.multiply(specific_emissions).sum(axis=1)
|
||||
|
||||
|
||||
def build_co2_totals(countries: List[str], eea_co2: pd.DataFrame, eurostat_co2: pd.DataFrame) -> pd.DataFrame:
|
||||
def build_co2_totals(
|
||||
countries: List[str], eea_co2: pd.DataFrame, eurostat_co2: pd.DataFrame
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Combine CO2 emissions data from EEA and Eurostat for a list of countries.
|
||||
|
||||
@ -1014,7 +1032,9 @@ def build_co2_totals(countries: List[str], eea_co2: pd.DataFrame, eurostat_co2:
|
||||
return co2
|
||||
|
||||
|
||||
def build_transport_data(countries: List[str], population: pd.DataFrame, idees: pd.DataFrame) -> pd.DataFrame:
|
||||
def build_transport_data(
|
||||
countries: List[str], population: pd.DataFrame, idees: pd.DataFrame
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Build transport data for a set of countries based on IDEES data.
|
||||
|
||||
@ -1100,9 +1120,7 @@ def build_transport_data(countries: List[str], population: pd.DataFrame, idees:
|
||||
|
||||
|
||||
def rescale_idees_from_eurostat(
|
||||
idees_countries: List[str],
|
||||
energy: pd.DataFrame,
|
||||
eurostat: pd.DataFrame
|
||||
idees_countries: List[str], energy: pd.DataFrame, eurostat: pd.DataFrame
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Takes JRC IDEES data from 2015 and rescales it by the ratio of the Eurostat
|
||||
@ -1303,7 +1321,8 @@ def rescale_idees_from_eurostat(
|
||||
|
||||
def update_residential_from_eurostat(energy: pd.DataFrame) -> pd.DataFrame:
|
||||
"""
|
||||
Updates energy balances for residential from disaggregated data from Eurostat by mutating input data DataFrame.
|
||||
Updates energy balances for residential from disaggregated data from
|
||||
Eurostat by mutating input data DataFrame.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -37,7 +37,6 @@ Notes:
|
||||
References:
|
||||
-----------
|
||||
- "Mapping and analyses of the current and future (2020 - 2030) heating/cooling fuel deployment (fossil/renewables)" (https://energy.ec.europa.eu/publications/mapping-and-analyses-current-and-future-2020-2030-heatingcooling-fuel-deployment-fossilrenewables-1_en)
|
||||
|
||||
"""
|
||||
import country_converter as coco
|
||||
import numpy as np
|
||||
|
@ -27,8 +27,10 @@ idx = pd.IndexSlice
|
||||
|
||||
def approximate_heat_demand(energy_totals: pd.DataFrame, hdd: pd.DataFrame):
|
||||
"""
|
||||
Approximate heat demand for a set of countries based on energy totals and heating degree days (HDD).
|
||||
A polynomial regression of heat demand on HDDs is performed on the data from 2007 to 2021. Then, for 2022 and 2023, the heat demand is estimated from known HDDs based on the regression.
|
||||
Approximate heat demand for a set of countries based on energy totals and
|
||||
heating degree days (HDD). A polynomial regression of heat demand on HDDs
|
||||
is performed on the data from 2007 to 2021. Then, for 2022 and 2023, the
|
||||
heat demand is estimated from known HDDs based on the regression.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -34,7 +34,6 @@ Outputs
|
||||
|
||||
- ``resources/temp_soil_<scope>_elec_s<simpl>_<clusters>.nc``:
|
||||
- ``resources/temp_air_<scope>_elec_s<simpl>_<clusters>.nc`
|
||||
|
||||
"""
|
||||
|
||||
import atlite
|
||||
|
Loading…
Reference in New Issue
Block a user