Fix missing seasonal capacity
Some units don't have seasonal capacity values. Replace with nameplate
capacity, but not if any generators within the unit do have a seasonal
capacity. This avoids issues where one generator within the unit is given
all of the seasonal capacity.
@@ -722,6 +722,33 @@ def supplement_generator_860_data(
.merge(bga[bga_cols], on=["plant_id_eia", "generator_id"], how="left")
)
+ gens_860_model.loc[gens_860_model.unit_id_pudl.isnull(), "unit_id_pudl"] = (
+ gens_860_model.loc[gens_860_model.unit_id_pudl.isnull(), "plant_id_eia"].astype(
+ str
+ )
+ + "_"
+ + gens_860_model.loc[
+ gens_860_model.unit_id_pudl.isnull(), "generator_id"
+ ].astype(str)
+ ).to_numpy()
+
+ # Where summer/winter capacity values are missing set equal to nameplate capacity,
+ # but only if all generators within a unit are missing the capacity value
+ check_units = gens_860_model.loc[
+ gens_860_model[settings["capacity_col"]].isna()
+ ].groupby(["plant_id_eia", "unit_id_pudl"])
+ for (plant_id, unit_id), _df in check_units:
+ if _df[settings["capacity_col"]].isna().all():
+ gens_860_model.loc[
+ (gens_860_model["plant_id_eia"] == plant_id)
+ & (gens_860_model["unit_id_pudl"] == unit_id),
+ settings["capacity_col"],
+ ] = gens_860_model.loc[
+ (gens_860_model["plant_id_eia"] == plant_id)
+ & (gens_860_model["unit_id_pudl"] == unit_id),
+ "capacity_mw",
+ ]
+
merged_capacity = gens_860_model.groupby("technology_description")[
settings["capacity_col"]
].sum()
