diff --git a/src/oge/helpers.py b/src/oge/helpers.py index 392a988..1bd2840 100644 --- a/src/oge/helpers.py +++ b/src/oge/helpers.py @@ -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( @@ -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