Skip to content

Commit

Permalink
additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiFej committed Dec 13, 2024
1 parent 7674267 commit ef2d582
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/osemosys2iamc/resultify.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,14 @@ def calculate_trade(results: dict, techs: List) -> pd.DataFrame:

def extract_results(df: pd.DataFrame, technologies: Optional[List] = None, fuels: Optional[List] = None) -> pd.DataFrame:
if technologies and "TECHNOLOGY" in df.columns:
mask = df.TECHNOLOGY.isin(technologies)
mask = df["TECHNOLOGY"].isin(technologies)
return df[mask]
elif fuels and "FUEL" in df.columns:
mask = df.FUEL.isin(fuels)
mask = df["FUEL"].isin(fuels)
return df[mask]
else:
return df


def load_config(filepath: str) -> Dict:

with open(filepath, "r") as configfile:
Expand Down Expand Up @@ -329,10 +328,8 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame
results_path, result["osemosys_param"], config["region"]
)

try:
technologies = result.get("technology", None)
except KeyError:
technologies = None
technologies = result.get("technology", None)
fuels = result.get("fuel", None)

unit = result["unit"]
if "fuel" in result.keys():
Expand Down Expand Up @@ -362,7 +359,6 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame
demands = result["demand"]
data = filter_final_energy(results, demands)
else:
fuels = result.get("fuel", None)
data = extract_results(results, technologies, fuels)

elif isinstance(result["osemosys_param"], list):
Expand Down

0 comments on commit ef2d582

Please sign in to comment.