Skip to content

Commit

Permalink
fix: ignore only subplant/plant with zero generation and fuel consump…
Browse files Browse the repository at this point in the history
…tion when checking for missing BA and fuel category
  • Loading branch information
rouille committed Dec 7, 2024
1 parent 676953c commit d4101c0
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/oge/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,39 @@ def assign_fleet_to_subplant_data(
validate="m:1",
)

# check that there is no missing ba or fuel codes for subplants with nonzero gen
# for CEMS data, check only units that report positive gross generaiton
# check that there is no missing ba or fuel codes for subplants with nonzero
# generation and fuel consumption

# for CEMS data, check only units that report positive gross generaiton and fuel
# consumption
if "gross_generation_mwh" in subplant_data.columns:
missing_fleet_keys = subplant_data[
(
(subplant_data["gross_generation_mwh"] > 0)
| (subplant_data["fuel_consumed_mmbtu"] > 0)
)
]
missing_fleet_keys = missing_fleet_keys[
(
(subplant_data["ba_code"].isna())
| (subplant_data[fuel_category_col].isna())
& (subplant_data["gross_generation_mwh"] > 0)
)
]
# otherwise, check units that report non-zero net generation
# otherwise, check units that report non-zero net generation and fuel consumption
else:
missing_fleet_keys = subplant_data[
(
(subplant_data["net_generation_mwh"] != 0)
| (subplant_data["fuel_consumed_mmbtu"] != 0)
)
]
missing_fleet_keys = missing_fleet_keys[
(
(subplant_data["ba_code"].isna())
| (subplant_data[fuel_category_col].isna())
& (subplant_data["net_generation_mwh"] != 0)
)
]

if len(missing_fleet_keys) > 0:
logger.warning(
missing_fleet_keys.groupby(
Expand All @@ -334,16 +348,13 @@ def assign_fleet_to_subplant_data(
fuel_category_col,
],
dropna=False,
)[
[
"net_generation_mwh",
]
]
)[["net_generation_mwh", "fuel_consumed_mmbtu"]]
.sum()
.to_string()
)
raise UserWarning(
"The plant attributes table is missing ba_code or fuel_category data for some plants. This will result in incomplete power sector results."
"The plant attributes table is missing ba_code or fuel_category data for "
"some plants. This will result in incomplete power sector results."
)

return subplant_data
Expand Down

0 comments on commit d4101c0

Please sign in to comment.