singularity-energy / open-grid-emissions

Tools for producing high-quality hourly generation and emissions data for U.S. electric grids
MIT License
67 stars 4 forks source link

Identify mismatch between input and allocated EIA-923 at plant/fuel level #350

Closed rouille closed 3 months ago

rouille commented 3 months ago

Purpose

Look for difference in the input and allocated EI-923 data at the plant/fuel level. This was previously done at the plant level only. Closes CAR-3506

What the code is doing

Group the input and allocated data frames by plant_id_eia and energy_source_code. Derive their symmetric difference in plant/fuel combination. It appears that among the 469 plant/fuel combinations that are in one of the data frames but not in both only 3 entries located in the input EIA-923 data frame have non-zero net generation and/or fuel consumed.

Testing

Manually tested

Where to look

All the code is in the check_allocated_gf_matches_input_gf function of the oge.validation module

Usage Example/Visuals

Outputs (data frames have been truncated by hand for the PR):

024-03-11 12:11:50 [WARNING] oge.oge.validation:79 There are 469 plant/fuel combinations that are either in EIA-923 Input or allocated EIA-923 but not in both
2024-03-11 12:11:50 [WARNING] oge.oge.validation:87 There are 60 plant/fuel combinations in EIA-923 Input but not in allocated EIA-923 : 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
65940        SUN                                0.0                  0.0                                  0.0    CISO
55067        NG                                 0.0                  0.0                                  0.0     PJM
568          KER                                0.0                  0.0                                  0.0    ISNE
54103        NG                                 0.0                  0.0                                  0.0    MISO
50300        NG                                 0.0                  0.0                                  0.0    CISO
9864         RFO                                0.0                  0.0                                  0.0    ISNE
3753         DFO                                0.0                  0.0                                  0.0    ISNE
58256        MWH                              -83.0                  0.0                                  0.0     PNM
3319         BIT                                0.0                  0.0                                  0.0      SC
50535        WND                                0.0                  0.0                                  0.0    CISO
63875        SUN                                0.0                  0.0                                  0.0    CISO
64709        SUN                                0.0                  0.0                                  0.0     PJM
10186        NG                                 0.0                  0.0                                  0.0    ISNE
59825        WND                             9972.0              34024.0                              34024.0    CPLE
...
2024-03-11 12:11:50 [WARNING] oge.oge.validation:98 There are 409 plant/fuel combinations in allocated EIA-923 but not in EIA-923 Input: 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
63996        MWH                                0.0                  0.0                                  0.0     FPC
64315        MWH                                0.0                  0.0                                  0.0    ERCO
10685        NG                                 0.0                  0.0                                  0.0    CISO
10434        NG                                 0.0                  0.0                                  0.0     TEC
66181        MWH                                0.0                  0.0                                  0.0    ISNE
52054        WAT                                0.0                  0.0                                  0.0    MISO
6181         SUB                                0.0                  0.0                                  0.0    ERCO
65813        MWH                                0.0                  0.0                                  0.0    ERCO
54855        NG                                 0.0                  0.0                                  0.0     PJM
64915        MWH                                0.0                  0.0                                  0.0    ERCO
66181        SUN                                0.0                  0.0                                  0.0    ISNE
58263        OBG                                0.0                  0.0                                  0.0     PJM
2554         BIT                                0.0                  0.0                                  0.0    NYIS
...
2024-03-11 12:11:50 [WARNING] oge.oge.validation:122 There are 7 plant/fuel combinations with non-zero net generation or fuel consumed that are different in aloocated EIA-923 and EIA-923 Input
2024-03-11 12:11:50 [WARNING] oge.oge.validation:131 Percentage Difference:
2024-03-11 12:11:50 [WARNING] oge.oge.validation:132 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                        8.704314e-02             0.000000                             0.000000    SWPP
10613        WDS                       1.171735e-16             0.056065                             0.558523    NBSO
54724        GEO                      -1.000000e+00            -1.000000                            -1.000000     IID
58256        MWH                      -1.000000e+00             0.000000                             0.000000     PNM
59817        SUN                      -1.000000e+00            -1.000000                            -1.000000    PACE
59825        WND                      -1.000000e+00            -1.000000                            -1.000000    CPLE
65498        WND                      -1.000000e+00            -1.000000                            -1.000000    MISO
2024-03-11 12:11:50 [WARNING] oge.oge.validation:135 EIA-923 Input Totals:
2024-03-11 12:11:50 [WARNING] oge.oge.validation:136 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                             413.588              14274.0                              14274.0    SWPP
10613        WDS                          31047.793             913514.0                              91699.0    NBSO
54724        GEO                          98804.000             337120.0                             337120.0     IID
58256        MWH                            -83.000                  0.0                                  0.0     PNM
59817        SUN                             98.000                336.0                                336.0    PACE
59825        WND                           9972.000              34024.0                              34024.0    CPLE
65498        WND                           1158.000               3950.0                               3950.0    MISO
2024-03-11 12:11:50 [WARNING] oge.oge.validation:142 Allocated Totals:
2024-03-11 12:11:50 [WARNING] oge.oge.validation:143 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                             449.588              14274.0                              14274.0    SWPP
10613        WDS                          31047.793             964730.0                             142915.0    NBSO
54724        GEO                              0.000                  0.0                                  0.0     IID
58256        MWH                              0.000                  0.0                                  0.0     PNM
59817        SUN                              0.000                  0.0                                  0.0    PACE
59825        WND                              0.000                  0.0                                  0.0    CPLE
65498        WND                              0.000                  0.0                                  0.0    MISO

Review estimate

10min

Future work

N/A

Checklist

rouille commented 3 months ago

Thanks, Ben! Looks like there's a lot of ESCs that are getting added or removed, but most of these have zero gen and fuel consumption. I think at this point we only care about whether there is a fuel missing in one dataset that has a non-zero allocation in another dataset, so for example in the first output dataframe, we'd want to print 58256 MWH and 59825 WND but not any of the other ones that are all zeros. Are all of the non-zero mismatches from your first two tables reflected in the bottom three? It appears that at least 58256 and 59285 are. If so, maybe we just keep the original three bottom dataframe outputs and not print the top two if they repeat the same information?

Yes, all non-zero mismatches in the first two tables are listed in the bottom 3 tables. More specifically, there are only 3 non-zero (either generation or fuel consumed or both) entries in the first table (the two you quoted + 59825 that was truncated), all entries in the second table are zero. The other 4 entries in the last 3 tables have the same (plant_eia_id, energy_source_code) but different value for generation, fuel consumed or both).

I will not print the first two tables but if you agree I will quote the number of non-zero entries vs zero entries for both tables.

grgmiller commented 3 months ago

I will not print the first two tables but if you agree I will quote the number of non-zero entries vs zero entries for both tables.

Sure, that sounds great to me

grgmiller commented 3 months ago

Closes https://github.com/singularity-energy/open-grid-emissions/issues/321

@rouille could you please also take a look at the plant mentioned in this issue (50900 in 2020) to see if this new warning catches anything here?

rouille commented 3 months ago

I will not print the first two tables but if you agree I will quote the number of non-zero entries vs zero entries for both tables.

Sure, that sounds great to me

Done. This is now the output we get:

2024-03-18 09:42:42 [WARNING] oge.oge.validation:79 There are 469 plant/fuel combinations that are either in EIA-923 Input or allocated EIA-923 but not in both
2024-03-18 09:42:42 [WARNING] oge.oge.validation:94 There are 60 plant/fuel combinations in EIA-923 Input but not in allocated EIA-923. There are 3 rows with non-zero or missing values
2024-03-18 09:42:42 [WARNING] oge.oge.validation:110 There are 409 plant/fuel combinations in allocated EIA-923 but not in EIA-923 Input. There are 0 rows with non-zero or missing values
2024-03-18 09:42:42 [WARNING] oge.oge.validation:130 There are 7 plant/fuel combinations with non-zero (missing) net generation or fuel consumed that are different in aloocated EIA-923 and EIA-923 Input
2024-03-18 09:42:42 [WARNING] oge.oge.validation:139 Percentage Difference:
2024-03-18 09:42:42 [WARNING] oge.oge.validation:140 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                        8.704314e-02             0.000000                             0.000000    SWPP
10613        WDS                       1.171735e-16             0.056065                             0.558523    NBSO
54724        GEO                      -1.000000e+00            -1.000000                            -1.000000     IID
58256        MWH                      -1.000000e+00             0.000000                             0.000000     PNM
59817        SUN                      -1.000000e+00            -1.000000                            -1.000000    PACE
59825        WND                      -1.000000e+00            -1.000000                            -1.000000    CPLE
65498        WND                      -1.000000e+00            -1.000000                            -1.000000    MISO
2024-03-18 09:42:42 [WARNING] oge.oge.validation:143 EIA-923 Input Totals:
2024-03-18 09:42:42 [WARNING] oge.oge.validation:144 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                             413.588              14274.0                              14274.0    SWPP
10613        WDS                          31047.793             913514.0                              91699.0    NBSO
54724        GEO                          98804.000             337120.0                             337120.0     IID
58256        MWH                            -83.000                  0.0                                  0.0     PNM
59817        SUN                             98.000                336.0                                336.0    PACE
59825        WND                           9972.000              34024.0                              34024.0    CPLE
65498        WND                           1158.000               3950.0                               3950.0    MISO
2024-03-18 09:42:42 [WARNING] oge.oge.validation:150 Allocated Totals:
2024-03-18 09:42:42 [WARNING] oge.oge.validation:151 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1316         NG                             449.588              14274.0                              14274.0    SWPP
10613        WDS                          31047.793             964730.0                             142915.0    NBSO
54724        GEO                              0.000                  0.0                                  0.0     IID
58256        MWH                                NaN                  NaN                                  NaN     PNM
59817        SUN                              0.000                  0.0                                  0.0    PACE
59825        WND                                NaN                  NaN                                  NaN    CPLE
65498        WND                                NaN                  NaN                                  NaN    MISO
rouille commented 3 months ago

Closes #321

@rouille could you please also take a look at the plant mentioned in this issue (50900 in 2020) to see if this new warning catches anything here?

I ran the validation for 2020 and plant 50900 is not caught:

2024-03-18 10:16:11 [WARNING] oge.oge.validation:80 There are 375 plant/fuel combinations that are either in EIA-923 Input or allocated EIA-923 but not in both
2024-03-18 10:16:11 [WARNING] oge.oge.validation:95 There are 49 plant/fuel combinations in EIA-923 Input but not in allocated EIA-923. There are 3 rows with non-zero or missing values
2024-03-18 10:16:11 [WARNING] oge.oge.validation:111 There are 326 plant/fuel combinations in allocated EIA-923 but not in EIA-923 Input. There are 0 rows with non-zero or missing values
2024-03-18 10:16:11 [WARNING] oge.oge.validation:131 There are 6 plant/fuel combinations with non-zero (missing) net generation or fuel consumed that are different in aloocated EIA-923 and EIA-923 Input
2024-03-18 10:16:11 [WARNING] oge.oge.validation:140 Percentage Difference:
2024-03-18 10:16:11 [WARNING] oge.oge.validation:141 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1404         NG                                -1.0                 -1.0                                 -1.0    MISO
50766        GEO                               -1.0                 -1.0                                 -1.0     IID
54724        GEO                               -1.0                 -1.0                                 -1.0     IID
58256        MWH                               -1.0                  0.0                                  0.0     PNM
59395        NG                                -1.0                 -1.0                                 -1.0    CISO
             OBG                               -1.0                 -1.0                                 -1.0    CISO
2024-03-18 10:16:11 [WARNING] oge.oge.validation:144 EIA-923 Input Totals:
2024-03-18 10:16:11 [WARNING] oge.oge.validation:145 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1404         NG                             574.000               8107.0                               8107.0    MISO
50766        GEO                          98652.000             864881.0                             864881.0     IID
54724        GEO                          92218.000             808476.0                             808476.0     IID
58256        MWH                           -651.000                  0.0                                  0.0     PNM
59395        NG                           15616.345             192675.0                             192675.0    CISO
             OBG                            217.715               2687.0                               2687.0    CISO
2024-03-18 10:16:11 [WARNING] oge.oge.validation:151 Allocated Totals:
2024-03-18 10:16:11 [WARNING] oge.oge.validation:152 
                                 net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu ba_code
plant_id_eia energy_source_code                                                                                      
1404         NG                                 0.0                  0.0                                  0.0    MISO
50766        GEO                                0.0                  0.0                                  0.0     IID
54724        GEO                                0.0                  0.0                                  0.0     IID
58256        MWH                                NaN                  NaN                                  NaN     PNM
59395        NG                                 NaN                  NaN                                  NaN    CISO
             OBG                                NaN                  NaN                                  NaN    CISO

If I look at plant 50900 before at after allocation, I don't see any difference: Before:

                    net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu
energy_source_code                                                                              
BIT                         105215.258            3987865.0                            1399645.0
BLQ                         395340.884           15056080.0                            5286858.0
DFO                             74.779               3056.0                               1006.0
NG                          179337.462            6918596.0                            2405170.0
RFO                           2817.516             114434.0                              38142.0
WDS                         150504.101            5646554.0                            2008289.0

After:

                    net_generation_mwh  fuel_consumed_mmbtu  fuel_consumed_for_electricity_mmbtu
energy_source_code                                                                              
BIT                         105215.258            3987865.0                            1399645.0
BLQ                         395340.884           15056080.0                            5286858.0
DFO                             74.779               3056.0                               1006.0
NG                          179337.462            6918596.0                            2405170.0
RFO                           2817.516             114434.0                              38142.0
WDS                         150504.101            5646554.0                            2008289.0
grgmiller commented 3 months ago

If I look at plant 50900 before at after allocation, I don't see any difference:

Oh maybe this has already been fixed then and was an old issue