Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Oct 2, 2024
2 parents f661db4 + fa35707 commit 646fed6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
6 changes: 5 additions & 1 deletion premise/electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
uuid,
ws,
)
from .utils import get_efficiency_solar_photovoltaics, rescale_exchanges, get_water_consumption_factors
from .utils import (
get_efficiency_solar_photovoltaics,
get_water_consumption_factors,
rescale_exchanges,
)
from .validation import ElectricityValidation

POWERPLANT_TECHS = VARIABLES_DIR / "electricity_variables.yaml"
Expand Down
11 changes: 6 additions & 5 deletions premise/new_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,11 +926,14 @@ def update(self, sectors: [str, list, None] = None) -> None:
}

if isinstance(sectors, str):
description = f"Processing scenarios for sector '{sectors}'"
sectors = [
sectors,
]

if sectors is None:
elif isinstance(sectors, list):
description = f"Processing scenarios for {len(sectors)} sectors"
elif sectors is None:
description = "Processing scenarios for all sectors"
sectors = [s for s in list(sector_update_methods.keys())]

assert isinstance(sectors, list), "sector_name should be a list of strings"
Expand All @@ -943,9 +946,7 @@ def update(self, sectors: [str, list, None] = None) -> None:
[item for item in sectors if item not in sector_update_methods]
)

with tqdm(
total=len(self.scenarios), desc="Processing scenarios", ncols=70
) as pbar_outer:
with tqdm(total=len(self.scenarios), desc=description, ncols=70) as pbar_outer:
for scenario in self.scenarios:
# add database to scenarios
try:
Expand Down
24 changes: 13 additions & 11 deletions premise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@


def rescale_exchanges(
ds,
value,
technosphere_filters=None,
biosphere_filters=None,
remove_uncertainty=False,
ds,
value,
technosphere_filters=None,
biosphere_filters=None,
remove_uncertainty=False,
):
"""
Adapted from wurst's change_exchanges_by_constant_factor
Expand Down Expand Up @@ -87,9 +87,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):


def eidb_label(
scenario: dict,
version: str,
system_model: str = "cutoff",
scenario: dict,
version: str,
system_model: str = "cutoff",
) -> str:
"""
Return a label to name a scenario.
Expand Down Expand Up @@ -159,7 +159,9 @@ def get_water_consumption_factors() -> dict:
Return a dictionary from renewables/hydropower.yaml
with correction factors for hydropower datasets
"""
with open(DATA_DIR / "renewables" / "hydropower.yaml", "r", encoding="utf-8") as stream:
with open(
DATA_DIR / "renewables" / "hydropower.yaml", "r", encoding="utf-8"
) as stream:
water_consumption_factors = yaml.safe_load(stream)

return water_consumption_factors
Expand Down Expand Up @@ -246,8 +248,8 @@ def clear_existing_cache(all_versions: Optional[bool] = False, filter=None) -> N
f.unlink()
for f in DIR_CACHED_DB.glob("*")
if f.is_file()
and (all_versions or "".join(tuple(map(str, __version__))) not in f.name)
and (filter is None or filter in f.name)
and (all_versions or "".join(tuple(map(str, __version__))) not in f.name)
and (filter is None or filter in f.name)
]


Expand Down

0 comments on commit 646fed6

Please sign in to comment.