From a8f69821dc5b79c826ae3da09b256b41422abe96 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 12:51:41 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/add_electricity.py | 29 ++++++++++++++++++----------- scripts/solve_network.py | 1 - 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 43e148af..5a517544 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -385,25 +385,28 @@ def attach_conventional_generators( ppl["efficiency"] = ppl.efficiency.fillna(ppl.efficiency_r) if unit_commitment is not None: - committable_attrs = ppl.carrier.isin(unit_commitment).to_frame('committable') + committable_attrs = ppl.carrier.isin(unit_commitment).to_frame("committable") for attr in unit_commitment.index: - default = pypsa.components.component_attrs['Generator'].default[attr] - committable_attrs[attr] = ppl.carrier.map(unit_commitment.loc[attr]).fillna(default) + default = pypsa.components.component_attrs["Generator"].default[attr] + committable_attrs[attr] = ppl.carrier.map(unit_commitment.loc[attr]).fillna( + default + ) else: committable_attrs = {} - if fuel_price is not None: - fuel_price = (fuel_price.assign(OCGT=fuel_price['gas'], - CCGT=fuel_price['gas']) - .drop("gas", axis=1)) + fuel_price = fuel_price.assign( + OCGT=fuel_price["gas"], CCGT=fuel_price["gas"] + ).drop("gas", axis=1) missing_carriers = list(carriers - set(fuel_price)) fuel_price = fuel_price.assign(**costs.fuel[missing_carriers]) fuel_price = fuel_price.reindex(ppl.carrier, axis=1) fuel_price.columns = ppl.index marginal_cost = fuel_price.div(ppl.efficiency).add(ppl.carrier.map(costs.VOM)) else: - marginal_cost = ppl.carrier.map(costs.VOM) + ppl.carrier.map(costs.fuel) / ppl.efficiency + marginal_cost = ( + ppl.carrier.map(costs.VOM) + ppl.carrier.map(costs.fuel) / ppl.efficiency + ) # Define generators using modified ppl DataFrame caps = ppl.groupby("carrier").p_nom.sum().div(1e3).round(2) @@ -422,7 +425,7 @@ def attach_conventional_generators( capital_cost=ppl.capital_cost, build_year=ppl.datein.fillna(0).astype(int), lifetime=(ppl.dateout - ppl.datein).fillna(np.inf), - **committable_attrs + **committable_attrs, ) for carrier in set(conventional_params) & carriers: @@ -771,8 +774,12 @@ if __name__ == "__main__": unit_commitment = None if params.conventional["dynamic_fuel_price"]: - monthly_fuel_price = pd.read_csv(snakemake.input.fuel_price, index_col=0, header=0) - monthly_fuel_price.index = pd.date_range(start=n.snapshots[0], end=n.snapshots[-1], freq='MS') + monthly_fuel_price = pd.read_csv( + snakemake.input.fuel_price, index_col=0, header=0 + ) + monthly_fuel_price.index = pd.date_range( + start=n.snapshots[0], end=n.snapshots[-1], freq="MS" + ) fuel_price = monthly_fuel_price.reindex(n.snapshots).fillna(method="ffill") else: fuel_price = None diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 94cb6056..6f02d56f 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -149,7 +149,6 @@ def prepare_network( planning_horizons=None, co2_sequestration_potential=None, ): - if "clip_p_max_pu" in solve_opts: for df in ( n.generators_t.p_max_pu,