Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 20, 2024
1 parent b42be43 commit d70824e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,22 @@ def load_costs(tech_costs, config, elec_config, Nyears=1): # 1
"""
costs = pd.read_csv(tech_costs, index_col=["technology", "parameter"]).sort_index()

if os.path.basename(os.getcwd()) == 'pypsa-earth':
cooking = os.path.join(os.getcwd(), 'resources', config['clean_cooking']['cooking_costs'])
if os.path.basename(os.getcwd()) == "pypsa-earth":
cooking = os.path.join(
os.getcwd(), "resources", config["clean_cooking"]["cooking_costs"]
)

else:
script_directory = os.path.dirname(os.path.abspath(__file__))
root_directory = os.path.abspath(os.path.join(script_directory, '..'))
cooking = os.path.join(root_directory, 'resources', config['clean_cooking']['cooking_costs'])
root_directory = os.path.abspath(os.path.join(script_directory, ".."))
cooking = os.path.join(
root_directory, "resources", config["clean_cooking"]["cooking_costs"]
)

cooking = pd.read_csv(cooking).set_index(["technology", "parameter"]).sort_index()

costs = pd.concat([costs, cooking], ignore_index=False)


# correct units to MW and EUR
costs.loc[costs.unit.str.contains("/kW"), "value"] *= 1e3
costs.unit = costs.unit.str.replace("/kW", "/MW")
Expand Down Expand Up @@ -829,7 +832,6 @@ def add_nice_carrier_names(n, config):
# Snakemake imports:
demand_profiles = snakemake.input["demand_profiles"] # demand profiles loaded


costs = load_costs(
snakemake.input.tech_costs,
snakemake.params.costs,
Expand Down

0 comments on commit d70824e

Please sign in to comment.