Skip to content

Commit

Permalink
Fix issue with marginal mix.
Browse files Browse the repository at this point in the history
Fix issue with losses dictionary.
  • Loading branch information
romainsacchi committed Feb 8, 2024
1 parent 2767b52 commit 2027fc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion premise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ("NewDatabase", "clear_cache", "get_regions_definition")
__version__ = (2, 0, 0, "dev0")
__version__ = (2, 0, 0, "dev1")


from .new_database import NewDatabase
Expand Down
11 changes: 6 additions & 5 deletions premise/electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_production_weighted_losses(
)

transf_loss += (
dict_loss["Transformation loss high voltage"]
dict_loss.get("Transformation loss high voltage", 0)
* dict_loss["Production volume"]
)

Expand Down Expand Up @@ -169,12 +169,13 @@ def get_production_weighted_losses(
"Production volume": 0,
},
)

transf_loss += (
dict_loss["Transformation loss medium voltage"]
dict_loss.get("Transformation loss medium voltage", 0)
* dict_loss["Production volume"]
)
distr_loss += (
dict_loss["Transmission loss to medium voltage"]
dict_loss.get("Transmission loss to medium voltage", 0)
* dict_loss["Production volume"]
)
cumul_prod += dict_loss["Production volume"]
Expand All @@ -195,11 +196,11 @@ def get_production_weighted_losses(
},
)
transf_loss += (
dict_loss["Transformation loss low voltage"]
dict_loss.get("Transformation loss low voltage", 0)
* dict_loss["Production volume"]
)
distr_loss += (
dict_loss["Transmission loss to low voltage"]
dict_loss.get("Transmission loss to low voltage", 0)
* dict_loss["Production volume"]
)
cumul_prod += dict_loss["Production volume"]
Expand Down
5 changes: 3 additions & 2 deletions premise/marginal_mixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def fetch_volume_change(data: xr.DataArray, start_year: int, end_year: int) -> n
"""
Calculate the volume change of a market.
"""

return (
(
data.sel(year=end_year).sum(dim="variables")
- data.sel(year=start_year).sum(dim="variables")
data.interp(year=end_year).sum(dim="variables")
- data.interp(year=start_year).sum(dim="variables")
)
/ (end_year - start_year)
).values
Expand Down
3 changes: 0 additions & 3 deletions premise/new_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import multiprocessing
import os
import pickle
import sys
from datetime import date
from functools import partial
from multiprocessing import Pool as ProcessPool
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool as Pool
from pathlib import Path
from typing import List, Union
Expand Down

0 comments on commit 2027fc2

Please sign in to comment.