6
6
##############################################################################
7
7
# REQUIRED MODULES
8
8
##############################################################################
9
+ """Add docstring."""
10
+
9
11
import pandas as pd
10
12
import numpy as np
11
13
from electricitylci .globals import data_dir , output_dir
12
14
import electricitylci .PhysicalQuantities as pq
13
15
import electricitylci .cems_data as cems
14
16
import electricitylci .eia923_generation as eia923
15
17
import electricitylci .eia860_facilities as eia860
16
- import fedelemflowlist
17
18
from electricitylci .model_config import model_specs
18
19
19
20
import logging
@@ -87,8 +88,10 @@ def generate_plant_emissions(year):
87
88
"WO" : "OIL" ,
88
89
"Mixed Fuel Type" : "MIXED" ,
89
90
}
91
+
90
92
91
93
def emissions_check_gen_fuel (df ):
94
+ """Add docstring."""
92
95
emissions_check = eia923_gen_fuel_sub_agg .merge (
93
96
df , on = "plant_id" , how = "left"
94
97
)
@@ -122,8 +125,10 @@ def emissions_check_gen_fuel(df):
122
125
)
123
126
124
127
return emissions_check
128
+
125
129
126
130
def emissions_check_boiler (df ):
131
+ """Add docstring."""
127
132
df_list = [
128
133
eia923_gen_fuel_boiler_agg ,
129
134
df ,
@@ -198,8 +203,9 @@ def emissions_check_boiler(df):
198
203
199
204
return emissions_check
200
205
201
- def eia_gen_fuel_co2_ch4_n2o_emissions (eia923_gen_fuel ):
202
206
207
+ def eia_gen_fuel_co2_ch4_n2o_emissions (eia923_gen_fuel ):
208
+ """Add docstring."""
203
209
emissions = pd .DataFrame ()
204
210
205
211
for row in ef_co2_ch4_n2o .itertuples ():
@@ -235,8 +241,9 @@ def eia_gen_fuel_co2_ch4_n2o_emissions(eia923_gen_fuel):
235
241
236
242
return emissions_agg
237
243
238
- def eia_boiler_co2_ch4_n2o_emissions (eia923_boiler ):
239
244
245
+ def eia_boiler_co2_ch4_n2o_emissions (eia923_boiler ):
246
+ """Add docstring."""
240
247
emissions = pd .DataFrame ()
241
248
242
249
for row in ef_co2_ch4_n2o .itertuples ():
@@ -306,9 +313,10 @@ def eia_boiler_co2_ch4_n2o_emissions(eia923_boiler):
306
313
emissions_agg ["plant_id" ] = emissions_agg ["plant_id" ].astype (str )
307
314
308
315
return emissions_agg
316
+
309
317
310
318
def eia_gen_fuel_net_gen (eia923_gen_fuel ):
311
-
319
+ """Add docstring."""
312
320
net_gen_monthly = [
313
321
"netgen_january" ,
314
322
"netgen_february" ,
@@ -357,10 +365,11 @@ def eia_gen_fuel_net_gen(eia923_gen_fuel):
357
365
].astype (str )
358
366
359
367
return eia_923_gen_fuel_agg
368
+
360
369
361
370
def eia_gen_fuel_so2_emissions (eia923_gen_fuel_sub ):
362
-
363
- # emissions = pd.DataFrame()
371
+ """Add docstring."""
372
+ emissions = pd .DataFrame ()
364
373
emissions = eia923_gen_fuel_sub .merge (
365
374
ef_so2 .loc [ef_so2 ["Boiler_Firing_Type_Code" ] == "None" , :],
366
375
left_on = ["reported_prime_mover" , "reported_fuel_type_code" ],
@@ -415,9 +424,10 @@ def eia_gen_fuel_so2_emissions(eia923_gen_fuel_sub):
415
424
emissions_agg ["plant_id" ] = emissions_agg ["plant_id" ].astype (str )
416
425
417
426
return emissions_agg
427
+
418
428
419
429
def eia_boiler_so2_emissions (eia923_boiler_firing_type ):
420
-
430
+ """Add docstring."""
421
431
fuel_heating_value_monthly = [
422
432
"mmbtu_per_unit_january" ,
423
433
"mmbtu_per_unit_february" ,
@@ -605,10 +615,11 @@ def eia_boiler_so2_emissions(eia923_boiler_firing_type):
605
615
)
606
616
607
617
return emissions_agg
618
+
608
619
609
620
def eia_gen_fuel_nox_emissions (eia923_gen_fuel_sub ):
610
-
611
- # emissions = pd.DataFrame()
621
+ """Add docstring."""
622
+ emissions = pd .DataFrame ()
612
623
emissions = eia923_gen_fuel_sub .merge (
613
624
ef_nox ,
614
625
left_on = ["reported_fuel_type_code" , "reported_prime_mover" ],
@@ -636,14 +647,18 @@ def eia_gen_fuel_nox_emissions(eia923_gen_fuel_sub):
636
647
emissions_agg ["plant_id" ] = emissions_agg ["plant_id" ].astype (str )
637
648
638
649
return emissions_agg
650
+
639
651
640
652
def eia_boiler_nox (row ):
653
+ """Add docstring."""
641
654
if row ["nox_emission_rate_entire_year_lbs_mmbtu" ] > 0 :
642
655
return row ["NOx Based on Annual Rate (lbs)" ]
643
656
else :
644
657
return row ["NOx (lbs)" ]
645
658
659
+
646
660
def eia_boiler_nox_emissions (eia923_boiler_firing_type ):
661
+ """Add docstring."""
647
662
fuel_heat_quantity_monthly = [
648
663
"MMBtu January" ,
649
664
"MMBtu February" ,
@@ -702,6 +717,7 @@ def eia_boiler_nox_emissions(eia923_boiler_firing_type):
702
717
emissions_agg = emissions_agg .rename (columns = {"NOx_lbs" : "NOx (lbs)" })
703
718
return emissions_agg
704
719
720
+
705
721
def eia_wtd_sulfur_content (eia923_boiler ):
706
722
"""This function determines the weighted average sulfur content of all reported fuel types
707
723
reported in EIA-923 Monthly Boiler Fuel Consumption and Emissions Time Series File.
@@ -787,13 +803,17 @@ def eia_wtd_sulfur_content(eia923_boiler):
787
803
788
804
return sulfur_content_agg
789
805
806
+
790
807
def eia_primary_fuel (row ):
808
+ """Add docstring."""
791
809
if row ["Primary Fuel %" ] < model_specs .min_plant_percent_generation_from_primary_fuel_category / 100 :
792
810
return "Mixed Fuel Type"
793
811
else :
794
812
return row ["Primary Fuel" ]
795
813
814
+
796
815
def emissions_logic_CO2 (row ):
816
+ """Add docstring."""
797
817
if (
798
818
(
799
819
row ["ampd Heat Input (MMBtu)" ]
@@ -813,7 +833,9 @@ def emissions_logic_CO2(row):
813
833
row ["Source" ] = "ap42"
814
834
return row ["CO2 (Tons)" ], row ["Source" ]
815
835
836
+
816
837
def emissions_logic_SO2 (row ):
838
+ """Add docstring."""
817
839
if (
818
840
(
819
841
row ["ampd Heat Input (MMBtu)" ]
@@ -833,7 +855,9 @@ def emissions_logic_SO2(row):
833
855
row ["Source" ] = "ap42"
834
856
return row ["SO2 (lbs)" ], row ["Source" ]
835
857
858
+
836
859
def emissions_logic_NOx (row ):
860
+ """Add docstring."""
837
861
if (
838
862
(
839
863
row ["ampd Heat Input (MMBtu)" ]
0 commit comments