Spaces:
Sleeping
Sleeping
File size: 75,218 Bytes
333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab 3f6ab90 333dfab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
import streamlit as st
fuel_values = ["Coal", "Natural Gas", "Oil", "Renewable Energy", "Other"]
purchased_goods_values = ["Cement", "Plaster", "Paint", "Timber", "Concrete"]
supplier_values = ["Supplier C", "Supplier D", "Supplier E", "Supplier F", "Supplier G"]
scope_values = ["Electricity", "Natural Gas"]
material_inputs_values = ["Cotton", "Polymer", "Chemical A", "Chemical B"]
transport_values = ["Cotton", "Polymer", "Chemical A", "Chemical B"]
waste_output_values = ["Waste sent to landfill"]
categories = ["Category 1", "Category 2", "Category 3", "Category 4", "Category 5",
"Category 6", "Category 7", "Category 8", "Category 9", "Category 10",
"Category 11", "Category 12", "Category 13", "Category 14", "Category 15"]
def calculate_emissions_supplier_specific(purchased_goods_data):
total_emissions = sum([qty * emission_factor for _, _, qty, emission_factor in purchased_goods_data])
st.header(f"Total Emissions for Supplier-specific Method: {total_emissions} kg CO2e")
def calculate_emissions_hybrid(scope1_and_scope2_data, material_inputs_data, transport_data, waste_output_data):
scope1_and_scope2_emissions = sum([float(item['Amount (kWh)']) * float(item['Emission factor (kg CO2e/kWh)']) for item in scope1_and_scope2_data])
waste_output_emissions = sum([float(item['Amount (kg)']) * float(item['Emission factor (kg CO2e/kg of waste sent to landfill)']) for item in waste_output_data])
other_upstream_emissions = sum([float(item['Mass purchased (kg)']) * float(item['Emission factor (kg CO2e/kg)']) for item in material_inputs_data])
total_emissions = scope1_and_scope2_emissions + waste_output_emissions + other_upstream_emissions
transport_emissions_per_item = [
float(item['Distance of transport (km)']) * float(item1['Mass purchased (kg)']) * float(item['Vehicle type emission factor (kg CO2e/kg/km)'])
for item in transport_data for item1 in material_inputs_data if item["Purchased Goods"] == item1["Purchased Goods"]
]
for i, item in enumerate(transport_data):
st.header(f"Emissions for Purchased Item {i + 1}: {transport_emissions_per_item[i]} kg CO2e")
def calculate_emissions_hybrid_pro(tshirt_data, scope_data, waste_output_data):
scope1_and_scope2_emissions = sum([float(item['Amount (kWh)']) * float(item['Emission factor (kg CO2e/kWh)']) for item in scope_data])
waste_output_emissions = sum([float(item['Amount (kg)']) * float(item['Emission factor (kg CO2e/kg of waste sent to landfill)']) for item in waste_output_data])
other_upstream_emissions = sum([float(item['Number of t-shirts purchased']) * float(item['Cradle-to-gate process emission factor (kg CO2e/per t-shirt(excluding scopes)']) for item in tshirt_data])
total_emissions = scope1_and_scope2_emissions + waste_output_emissions + other_upstream_emissions
st.header(f"Total Emissions for HybridPro Method: {total_emissions} kg CO2e")
def collect_category_3_data():
st.header("Category 3: Fuel and Energy related activities not included in scope 1 and Scope 2")
method_options = ["Method 1: Upstream emissions of purchased fuels",
"Method 2: Upstream emissions of purchased electricity",
"Method 3: Transmission and distribution losses",
"Method 4: Emissions from power that is purchased and sold"]
selected_method = st.selectbox("Select Method", method_options)
if selected_method == "Method 1: Upstream emissions of purchased fuels":
fuel_data = dynamic_input_fields("Fuel Data", ["Fuel consumed (kWh)", "Upstream fuel emission factor (kg CO2e/kWh)"], ["Fuel consumed (kWh)", "Upstream fuel emission factor (kg CO2e/kWh)"])
calculate_emissions_category_3_method_1(fuel_data)
elif selected_method == "Method 2: Upstream emissions of purchased electricity":
selected_country = st.selectbox("Select country", ["Australia", "Canada", "India", "US", "Turkey"])
electricity_data = dynamic_input_fields("Electricity Data", ["Electricity"], ["Electricity"], country=selected_country)
steam_data = dynamic_input_fields("Steam Data", ["Steam"], ["Steam"], country=selected_country)
heating_data = dynamic_input_fields("Heating Data", ["Heating"], ["Heating"], country=selected_country)
cooling_data = dynamic_input_fields("Cooling Data", ["Cooling"], ["Cooling"], country=selected_country)
upstream_emission_factors = dynamic_input_fields("Upstream Emission Factors", ["Electricity", "Steam", "Heating", "Cooling"], ["Electricity", "Steam", "Heating", "Cooling"], country=selected_country)
calculate_emissions_category_3_method_2(electricity_data, steam_data, heating_data, cooling_data, upstream_emission_factors,selected_country)
elif selected_method == "Method 3: Transmission and distribution losses":
selected_country = st.selectbox("Select country", ["Australia", "Canada", "India", "US", "Turkey"])
electricity_data = dynamic_input_fields("Electricity Data", ["Electricity"], ["Electricity"], country=selected_country)
steam_data = dynamic_input_fields("Steam Data", ["Steam"], ["Steam"], country=selected_country)
heating_data = dynamic_input_fields("Heating Data", ["Heating"], ["Heating"], country=selected_country)
cooling_data = dynamic_input_fields("Cooling Data", ["Cooling"], ["Cooling"], country=selected_country)
t_and_d_loss_data = dynamic_input_fields("T&D Loss Data", ["Transmission"], ["Transmission"], country=selected_country)
upstream_emission_factors = dynamic_input_fields("Upstream Emission Factors", ["Electricity", "Steam", "Heating", "Cooling"], ["Electricity", "Steam", "Heating", "Cooling"], country=selected_country)
calculate_emissions_category_3_method_3(electricity_data,steam_data,heating_data,cooling_data,upstream_emission_factors, t_and_d_loss_data,selected_country)
elif selected_method == "Method 4: Emissions from power that is purchased and sold":
selected_country = st.selectbox("Select country", ["Australia", "Canada", "India", "US", "Turkey"])
electricity_data = dynamic_input_fields("Electricity Data", ["Electricity"], ["Electricity"],country=selected_country)
steam_data = dynamic_input_fields("Steam Data", ["Steam"], ["Steam"],country=selected_country)
heating_data = dynamic_input_fields("Heating Data", ["Heating"], ["Heating"],country=selected_country)
cooling_data = dynamic_input_fields("Cooling Data", ["Cooling"], ["Cooling"],country=selected_country)
upstream_emission_factors = dynamic_input_fields("Upstream Emission Factors", ["Electricity", "Steam", "Heating", "Cooling"], ["Country", "Electricity", "Steam", "Heating", "Cooling"], country=selected_country)
calculate_emissions_category_3_method_4(electricity_data,steam_data,heating_data,cooling_data,upstream_emission_factors,selected_country)
def calculate_emissions_category_3_method_1(fuel_data):
total_emissions = sum(
[
item["Fuel consumed (kWh)"] * (item["Upstream fuel emission factor (kg CO2e/kWh)"])
for item in fuel_data
]
)
st.header(f"Total Emissions for Upstream emissions of purchased fuels is {total_emissions} kg CO2e")
def calculate_emissions_category_3_method_2(electricity_data, steam_data, heating_data, cooling_data, upstream_emission_factor,selected_country):
country_electricity = next(item for item in electricity_data if item["Country"] == selected_country)["Electricity"]
country_steam = next(item for item in steam_data if item["Country"] == selected_country)["Steam"]
country_heating = next(item for item in heating_data if item["Country"] == selected_country)["Heating"]
country_cooling = next(item for item in cooling_data if item["Country"] == selected_country)["Cooling"]
country_factors = next(item for item in upstream_emission_factor if item["Country"] == selected_country)
total_emissions = (
country_electricity * country_factors["Electricity"]
+ country_steam * country_factors["Steam"]
+ country_heating * country_factors["Heating"]
+ country_cooling * country_factors["Cooling"]
)
st.header(f"Total Emissions for Upstream emissions of purchased electricity: {total_emissions} kg CO2e")
def calculate_emissions_category_3_method_3(electricity_data, steam_data, heating_data, cooling_data, upstream_emission_factors,t_and_d_loss, selected_country):
country_electricity = next(item for item in electricity_data if item["Country"] == selected_country)["Electricity"]
country_steam = next(item for item in steam_data if item["Country"] == selected_country)["Steam"]
country_heating = next(item for item in heating_data if item["Country"] == selected_country)["Heating"]
country_cooling = next(item for item in cooling_data if item["Country"] == selected_country)["Cooling"]
country_factors = next(item for item in upstream_emission_factors if item["Country"] == selected_country)
country_td = next(item for item in t_and_d_loss if item["Country"] == selected_country)
st.header(country_factors)
total_emissions = (
country_electricity * country_factors["Electricity"] * country_td["Transmission"]
+ country_steam * country_factors["Steam"] * country_td["Transmission"]
+ country_heating * country_factors["Heating"] * country_td["Transmission"]
+ country_cooling * country_factors["Cooling"] * country_td["Transmission"]
)
st.header(f"Total Emissions for Transmission and distribution losses: {total_emissions} kg CO2e")
def calculate_emissions_category_3_method_4(electricity_data, steam_data, heating_data, cooling_data, emission_factors, selected_country):
country_factors = next((item for item in emission_factors if item["Country"] == selected_country), None)
st.header(country_factors)
if country_factors is not None:
total_emissions = (
sum(item["Electricity"] * country_factors["Electricity"] for item in electricity_data)
+ sum(item["Steam"] * country_factors["Steam"] for item in steam_data)
+ sum(item["Heating"] * country_factors["Heating"] for item in heating_data)
+ sum(item["Cooling"] * country_factors["Cooling"] for item in cooling_data)
)
st.header(f"Total Emissions where power is purchased and sold: {total_emissions} kg CO2e")
else:
st.warning(f"No emission factors found for {selected_country} in emission_factors.")
def calculate_emissions_category_4_method_1(fuel_data, electricity_data, refrigerant_data, total_fuel_spend=None, total_distance_travelled=None):
fuel_emissions = sum([item["Fuel consumed (liters)"] * item["Emission factor (kg CO2e/liter)"] for item in fuel_data])
electricity_emissions = sum([item["Quantity of electricity consumed (kWh)"] * item["Emission factor for electricity grid (kg CO2e/kWh)"] for item in electricity_data])
refrigerant_emissions = sum([item["Refrigerant leakage (kg)"] * item["Global warming potential for refrigerant (kg CO2e)"] for item in refrigerant_data])
if total_fuel_spend:
quantities_of_fuel = sum([item["Total fuel spend ($)"] / item["Average fuel price ($/liter)"] for item in fuel_data])
fuel_emissions_from_spending = quantities_of_fuel * sum([item["Average fuel price ($/liter)"] * item["Emission factor (kg CO2e/liter)"] for item in fuel_data])
total_emissions = fuel_emissions + electricity_emissions + refrigerant_emissions + fuel_emissions_from_spending
elif total_distance_travelled:
quantities_of_fuel_consumed = sum([item["Total distance travelled (km)"] * item["Fuel efficiency of vehicle (liters/km)"] for item in fuel_data])
fuel_emissions_from_distance = quantities_of_fuel_consumed * sum([item["Emission factor for the fuel (kg CO2e/liter)"] for item in fuel_data])
total_emissions = fuel_emissions + electricity_emissions + refrigerant_emissions + fuel_emissions_from_distance
else:
total_emissions = fuel_emissions + electricity_emissions + refrigerant_emissions
st.header(f"Total Emissions for Fuel-based Method: {total_emissions} kg CO2e")
def calculate_emissions_category_4_method_2(fuel_data, average_efficiency_unladen, total_distance_travelled_unladen):
total_emissions_unladen = sum([item["Quantity of fuel consumed from backhaul"] * item["Emission factor for the fuel (kg CO2e/liter)"] for item in fuel_data])
total_emissions_unladen += sum([average_efficiency_unladen * total_distance_travelled_unladen * item["Emission factor for the fuel (kg CO2e/liter)"] for item in fuel_data])
st.header(f"Total Emissions for Unladen Backhaul: {total_emissions_unladen} kg CO2e")
def calculate_emissions_category_4_method_3(transport_data):
total_emissions_transport = sum([
item["Mass of goods purchased (tonnes)"] * item["Distance travelled in transport leg (km)"] * item["Emission factor of transport mode or vehicle type (kg CO2e/tonne-km)"]
for item in transport_data
])
st.header(f"Total Emissions for Transportation: {total_emissions_transport} kg CO2e")
def calculate_emissions_category_4_method_4(storage_data):
total_emissions_distribution = sum([
(
item["Fuel consumed (kWh)"] * item["Fuel emission factor (kg CO2e/kWh)"]
+ item["Electricity consumed (kWh)"] * item["Electricity emission factor (kg CO2e/kWh)"]
+ item["Refrigerant leakage (kg)"] * item["Refrigerant emission factor (kg CO2e/kg)"]
) * (
item["Volume of company A’s goods (m3)"] / item["Total volume of goods in storage facility (m3)"] if item["Total volume of goods in storage facility (m3)"] != 0 else 0
)
for item in storage_data
])
st.header(f"Total Emissions for Distribution: {total_emissions_distribution} kg CO2e")
def calculate_emissions_category_4_method_5(storage_data):
total_emissions_distribution = sum([
item["Volume of stored goods (m3)"] * item["Average number of days stored (days)"] * item["Emission factor for storage facility (kg CO2e/m3/day)"]
for item in storage_data
])
st.header(f"Total Emissions for Distribution (Method 5): {total_emissions_distribution} kg CO2e")
def calculate_emissions_category_5_method_1(waste_treatment_data):
total_emissions_category_5 = sum([
item["Allocated scope 1 and scope 2 emissions of waste treatment company"]
for item in waste_treatment_data
])
st.header(f"Total Emissions for Category 5 (Method 1): {total_emissions_category_5} kg CO2e")
def collect_category_4_method_1_data():
st.header("Category 4: Method 1 - Fuel-based Method")
fuel_data = dynamic_input_fields_with_emission_factor("Fuel Data", "Enter fuel data", ["Fuel consumed (liters)", "Emission factor (kg CO2e/liter)", "Total fuel spend ($)", "Average fuel price ($/liter)","Total distance travelled (km)"],
["Fuel consumed (liters)", "Emission factor (kg CO2e/liter)", "Total fuel spend ($)", "Average fuel price ($/liter)","Total distance travelled (km)"])
electricity_data = dynamic_input_fields_with_emission_factor("Electricity Data", "Enter electricity data", ["Quantity of electricity consumed (kWh)", "Emission factor for electricity grid (kg CO2e/kWh)"],
["Quantity of electricity consumed (kWh)", "Emission factor for electricity grid (kg CO2e/kWh)"])
refrigerant_data = dynamic_input_fields_with_emission_factor("Refrigerant Data", "Enter refrigerant data", ["Refrigerant leakage (kg)", "Global warming potential for refrigerant (kg CO2e)"],
["Refrigerant leakage (kg)", "Global warming potential for refrigerant (kg CO2e)"])
total_fuel_spend = st.checkbox("Calculate based on total fuel spend")
calculate_emissions_category_4_method_1(fuel_data, electricity_data, refrigerant_data, total_fuel_spend=total_fuel_spend)
def collect_category_4_method_2_data():
st.header("Category 4: Method 2 - Unladen Backhaul")
fuel_data = dynamic_input_fields_with_emission_factor("Fuel Data", "Enter fuel data", ["Quantity of fuel consumed from backhaul", "Emission factor for the fuel (kg CO2e/liter)"],
["Quantity of fuel consumed from backhaul", "Emission factor for the fuel (kg CO2e/liter)"])
average_efficiency_unladen = st.number_input("Average efficiency unladen", min_value=0.0, step=0.01, key="average_efficiency_unladen")
total_distance_travelled_unladen = st.number_input("Total distance travelled unladen (km)", min_value=0.0, step=0.01, key="total_distance_travelled_unladen")
calculate_emissions_category_4_method_2(fuel_data, average_efficiency_unladen, total_distance_travelled_unladen)
def collect_category_4_method_3_data():
st.header("Category 4: Method 3 - Transportation")
transport_data = dynamic_input_fields_with_emission_factor("Transport Data", "Enter transport data", ["Mass of goods purchased (tonnes)", "Distance travelled in transport leg (km)", "Emission factor of transport mode or vehicle type (kg CO2e/tonne-km)"],
["Mass of goods purchased (tonnes)", "Distance travelled in transport leg (km)", "Emission factor of transport mode or vehicle type (kg CO2e/tonne-km)"])
calculate_emissions_category_4_method_3(transport_data)
def collect_category_4_method_4_data():
st.header("Category 4: Method 4 - Distribution")
storage_data = dynamic_input_fields_with_emission_factor("Storage Data", "Enter storage data", ["Fuel consumed (kWh)", "Electricity consumed (kWh)", "Refrigerant leakage (kg)",
"Volume of company A’s goods (m3)", "Total volume of goods in storage facility (m3)",
"Fuel emission factor (kg CO2e/kWh)", "Electricity emission factor (kg CO2e/kWh)", "Refrigerant emission factor (kg CO2e/kg)"],
["Fuel consumed (kWh)", "Electricity consumed (kWh)", "Refrigerant leakage (kg)",
"Volume of company A’s goods (m3)", "Total volume of goods in storage facility (m3)",
"Fuel emission factor (kg CO2e/kWh)", "Electricity emission factor (kg CO2e/kWh)", "Refrigerant emission factor (kg CO2e/kg)"])
calculate_emissions_category_4_method_4(storage_data)
def collect_category_4_method_5_data():
st.header("Category 4: Method 5 - Distribution (Method 5)")
storage_data = dynamic_input_fields_with_emission_factor("Storage Data", "Enter storage data", ["Volume of stored goods (m3)", "Average number of days stored (days)", "Emission factor for storage facility (kg CO2e/m3/day)"],
["Volume of stored goods (m3)", "Average number of days stored (days)", "Emission factor for storage facility (kg CO2e/m3/day)"])
calculate_emissions_category_4_method_5(storage_data)
def get_input_category_5_method_1():
st.subheader("Method 1: CO2e emissions from waste generated in operations")
waste_treatment_data = dynamic_input_fields("Waste Treatment Provider", ["Allocated emissions"], ["Allocated scope 1 and scope 2 emissions of waste treatment company"])
calculate_emissions_category_5_method_1(waste_treatment_data)
def calculate_emissions_category_5_method_1(waste_treatment_data):
total_emissions = sum([item["Allocated emissions"] for item in waste_treatment_data])
st.header(f"Total Emissions for Method 1: {total_emissions} kg CO2e")
def get_input_category_5_method_2():
st.subheader("Method 2: CO2e emissions from waste generated in operations")
waste_type_data = dynamic_input_fields_with_emission_factor("Waste Type", "Enter waste type data",
["Waste produced (tonnes)", "Waste treatment", "Waste type and waste treatment specific emission factor"],
["Waste produced (tonnes)", "Waste treatment", "Waste type and waste treatment specific emission factor"])
calculate_emissions_category_5_method_2(waste_type_data)
def calculate_emissions_category_5_method_2(waste_type_data):
total_emissions = sum([
item["Waste produced (tonnes)"] * item["Waste type and waste treatment specific emission factor"]
for item in waste_type_data
])
st.header(f"Total Emissions for Method 2: {total_emissions} kg CO2e")
def get_input_category_5_method_3():
st.subheader("Method 3: Average Method - CO2e emissions from waste generated in operations")
waste_treatment_method_data = dynamic_input_fields_with_emission_factor("Waste Treatment Method", "Enter waste treatment method data",
["Total mass of waste (tonnes)", "Proportion (percent)", "Emission factor (kg CO2e/tonne)"],
["Total mass of waste (tonnes)", "Proportion (percent)", "Emission factor (kg CO2e/tonne)"])
calculate_emissions_category_5_method_3(waste_treatment_method_data)
def calculate_emissions_category_5_method_3(waste_treatment_method_data):
total_emissions = sum([
item["Total mass of waste (tonnes)"] * (item["Proportion (percent)"] / 100) * item["Emission factor (kg CO2e/tonne)"]
for item in waste_treatment_method_data
])
st.header(f"Total Emissions for Method 3: {total_emissions} kg CO2e")
def get_input_category_6_method_1():
st.subheader("Method 1: Distance-based Method - Business Travel Emissions")
road_travel_data = dynamic_input_fields_with_dropdown_int("Road Travel", "Select road travel data",
["Location", "Average employees per vehicle","Number of employees in group", "Car_type", "Distance (km)", "Emission factor (kg CO2e/vehicle-km)"],
["Location", "Average employees per vehicle", "Number of employees in group", "Car_type", "Distance (km)", "Emission factor (kg CO2e/vehicle-km)"])
air_travel_data = dynamic_input_fields_with_dropdown_int("Air Travel", "Select air travel data",
["Number of employees in group", "Flight type", "Distance (km)", "Emission factor (kg CO2e/passenger-km)"],
["Number of employees in group", "Flight type", "Distance (km)", "Emission factor (kg CO2e/passenger-km)"])
include_hotel = st.checkbox("Include Hotel Emissions (Optional)")
hotel_data = []
if include_hotel:
hotel_data = dynamic_input_fields("Hotel", ["Annual number of hotel nights", "Hotel emission factor (kg CO2e/night)"],
["Annual number of hotel nights", "Hotel emission factor (kg CO2e/night)"])
calculate_emissions_category_6_method_1(road_travel_data, air_travel_data, hotel_data)
def calculate_emissions_category_6_method_1(road_travel_data, air_travel_data, hotel_data):
road_travel_emissions = 0
for item in road_travel_data:
if item["Average employees per vehicle"] != 0:
road_travel_emissions += (item["Distance (km)"] / item["Average employees per vehicle"]) * item["Emission factor (kg CO2e/vehicle-km)"]
air_travel_emissions = sum([
item["Distance (km)"] * item["Emission factor (kg CO2e/passenger-km)"]
for item in air_travel_data
])
total_emissions = road_travel_emissions + air_travel_emissions
if hotel_data:
hotel_emissions = sum([
item["Annual number of hotel nights"] * item["Hotel emission factor (kg CO2e/night)"]
for item in hotel_data
])
total_emissions += hotel_emissions
st.header(f"Total Business Travel Emissions: {total_emissions} kg CO2e")
def get_input_category_7_method_1():
st.subheader("Method 1: Distance-based Method - Employee Travel Emissions")
employee_data = dynamic_input_fields_with_dropdown_int("Employee", "Select employee data",
["Rail commute (times per week)", "One way distance by rail (km)",
"Rail emission factor (kg CO2e/passenger-km)",
"Car commute (times per week)", "Car emission factor (kg CO2e/vehicle-km)",
"One way distance by car (km)"],
["Rail commute (times per week)", "One way distance by rail (km)",
"Rail emission factor (kg CO2e/passenger-km)",
"Car commute (times per week)", "Car emission factor (kg CO2e/vehicle-km)",
"One way distance by car (km)"])
telework_data = dynamic_input_fields_with_dropdown_int("Telework", "Select telework data",
["Quantities of energy consumed (kWh)", "Emission factor for energy source (kg CO2e/kWh)"],
["Quantities of energy consumed (kWh)", "Emission factor for energy source (kg CO2e/kWh)"])
calculate_emissions_category_7_method_1(employee_data, telework_data)
def calculate_emissions_category_7_method_1(employee_data, telework_data):
total_distance_rail = sum([
item["Rail commute (times per week)"] * 2 * 5 * item["One way distance by rail (km)"]
for item in employee_data
])
total_distance_car = sum([
item["Car commute (times per week)"] * 2 * 5 * item["One way distance by car (km)"]
for item in employee_data
])
total_emissions = sum([
(total_distance_rail * item["Rail emission factor (kg CO2e/passenger-km)"]) +
(total_distance_car * item["Car emission factor (kg CO2e/vehicle-km)"])
for item in employee_data
])
if telework_data:
total_emissions += sum([
item["Quantities of energy consumed (kWh)"] * item["Emission factor for energy source (kg CO2e/kWh)"]
for item in telework_data
])
st.header(f"Total Employee Travel Emissions (Method 1): {total_emissions} kg CO2e")
def get_input_category_7_method_2():
st.subheader("Method 2: Average-data Method - Employee Travel Emissions")
commute_data = dynamic_input_fields_with_dropdown_int("Commute Group", "Select commute group data",
["Percent of total commutes", "Average one-way distance (km)",
"Emission factor (kg CO2e/vehicle or passenger km)"],
["Percent of total commutes", "Average one-way distance (km)",
"Emission factor (kg CO2e/vehicle or passenger km)"])
total_employees = st.number_input("Enter the total number of employees:", min_value=1, step=1, key="total_employees")
calculate_emissions_category_7_method_2(commute_data, total_employees)
def calculate_emissions_category_7_method_2(commute_data, total_employees):
total_emissions = sum([
total_employees * (item["Percent of total commutes"] / 100) * 2 * 235 * item["Average one-way distance (km)"] *
item["Emission factor (kg CO2e/vehicle or passenger km)"]
for item in commute_data
])
st.header(f"Total Employee Travel Emissions (Method 2): {total_emissions} kg CO2e")
def get_input_category_8_method_1():
st.subheader("Method 1: Asset-specific method - Upstream Leased Assets Emissions")
asset_data = dynamic_input_fields("Upstream Leased Asset", ["Natural gas (kWh)", "Natural gas emission factor (kg CO2e/kWh)",
"Electricity (kWh)", "Electricity emission factor (kg CO2e/kWh)",
"Fugitive emissions", "Fugitive emission factor"],
["Natural gas (kWh)", "Natural gas emission factor (kg CO2e/kWh)",
"Electricity (kWh)", "Electricity emission factor (kg CO2e/kWh)",
"Fugitive emissions", "Fugitive emission factor"])
calculate_emissions_category_8_method_1(asset_data)
def calculate_emissions_category_8_method_1(asset_data):
total_emissions = sum([
(
item["Natural gas (kWh)"] * item["Natural gas emission factor (kg CO2e/kWh)"]
+ item["Electricity (kWh)"] * item["Electricity emission factor (kg CO2e/kWh)"]
+ item["Fugitive emissions"] * item["Fugitive emission factor"]
)
for item in asset_data
])
st.header(f"Total Emissions from Upstream Leased Assets (Asset-specific Method): {total_emissions} kg CO2e")
def calculate_emissions_category_8_method_2(lessor_data, leased_asset_data):
total_emissions = sum([
(
item["Fuel consumed (e.g., liter)"] * item["Emission factor for fuel source (e.g., kg CO2e/liter)"]
+ item["Refrigerant leakage (kg)"] * item["Emission factor for refrigerant (kg CO2e/kg)"]
+ item["Process emissions"]
+ item["Electricity, steam, heating, cooling consumed (e.g., kWh)"]
* item["Emission factor for electricity, steam, heating, cooling (e.g., kg CO2e/kWh)"]
)
for item in lessor_data
])
total_emissions_allocated = sum([
(item["Scope 1 and Scope 2 emissions of lessor (kg CO2e)"]
* item["Area, volume, quantity, etc., of the leased asset"]
/ item["Total area, volume, quantity, etc., of lessor assets"]) if item["Total area, volume, quantity, etc., of lessor assets"] != 0 else 0
for item in leased_asset_data
])
st.header(f"Total Emissions from Upstream Leased Assets (CO2e Emissions from Leased Assets Method): {total_emissions + total_emissions_allocated} kg CO2e")
def calculate_emissions_category_8_method_3(building_data):
total_emissions = sum([
item["Total floor space of building type (m2)"] * item["Average emission factor for building type (kg CO2e/m2/year)"]
for item in building_data
])
st.header(f"Total Emissions from Upstream Leased Assets (Average-data Method for Leased Buildings): {total_emissions} kg CO2e")
def calculate_emissions_category_8_method_4(asset_data):
total_emissions = sum([
item["Number of assets"] * item["Average emissions per asset type (kg CO2e/asset type/year)"]
for item in asset_data
])
st.header(f"Total Emissions from Upstream Leased Assets (Average-data Method for Other Leased Assets): {total_emissions} kg CO2e")
def get_input_category_8_method_2():
st.subheader("Method 2: CO2e emissions from leased assets - Upstream Leased Assets Emissions")
lessor_data = dynamic_input_fields("Lessor", ["Fuel consumed (e.g., liter)", "Emission factor for fuel source (e.g., kg CO2e/liter)",
"Refrigerant leakage (kg)", "Emission factor for refrigerant (kg CO2e/kg)",
"Process emissions", "Electricity, steam, heating, cooling consumed (e.g., kWh)",
"Emission factor for electricity, steam, heating, cooling (e.g., kg CO2e/kWh)"],
["Fuel consumed (e.g., liter)", "Emission factor for fuel source (e.g., kg CO2e/liter)",
"Refrigerant leakage (kg)", "Emission factor for refrigerant (kg CO2e/kg)",
"Process emissions", "Electricity, steam, heating, cooling consumed (e.g., kWh)",
"Emission factor for electricity, steam, heating, cooling (e.g., kg CO2e/kWh)"])
leased_asset_data = dynamic_input_fields("Leased Asset", ["Scope 1 and Scope 2 emissions of lessor (kg CO2e)",
"Area, volume, quantity, etc., of the leased asset",
"Total area, volume, quantity, etc., of lessor assets"],
["Scope 1 and Scope 2 emissions of lessor (kg CO2e)",
"Area, volume, quantity, etc., of the leased asset",
"Total area, volume, quantity, etc., of lessor assets"])
calculate_emissions_category_8_method_2(lessor_data, leased_asset_data)
def get_input_category_8_method_3():
st.subheader("Method 3: Average-data method for leased buildings - Upstream Leased Assets Emissions")
building_data = dynamic_input_fields("Building", ["Total floor space of building type (m2)",
"Average emission factor for building type (kg CO2e/m2/year)"],
["Total floor space of building type (m2)",
"Average emission factor for building type (kg CO2e/m2/year)"])
calculate_emissions_category_8_method_3(building_data)
def get_input_category_8_method_4():
st.subheader("Method 4: Average-data method for leased assets other than buildings - Upstream Leased Assets Emissions")
asset_data = dynamic_input_fields("Leased Asset", ["Number of assets", "Average emissions per asset type (kg CO2e/asset type/year)"],
["Number of assets", "Average emissions per asset type (kg CO2e/asset type/year)"])
calculate_emissions_category_8_method_4(asset_data)
def calculate_emissions_category_9_method_1(transportation_data):
total_emissions = sum([
item["Mass of goods sold (tonnes)"] * item["Total downstream distance transported (km)"]
* item["Emission factor (kg CO2e/tonne-km)"]
for item in transportation_data
])
st.header(f"Total Emissions from Downstream Transportation: {total_emissions} kg CO2e")
def get_input_category_9_method_1():
st.subheader("Method 1: Downstream Transportation Emissions")
transportation_data = dynamic_input_fields("Transportation", ["Mass of goods sold (tonnes)",
"Total downstream distance transported (km)",
"Transport mode or vehicle type",
"Emission factor (kg CO2e/tonne-km)"],
["Mass of goods sold (tonnes)",
"Total downstream distance transported (km)",
"Transport mode or vehicle type",
"Emission factor (kg CO2e/tonne-km)"])
calculate_emissions_category_9_method_1(transportation_data)
def get_input_category_10_method_1():
st.subheader("Method 1: Site-specific Method - Processing of Sold Intermediate Products")
fuel_data = dynamic_input_fields("Fuel", ["Quantity consumed (e.g., liter)", "Life cycle emission factor (kg CO2e/liter)"],
["Quantity consumed (e.g., liter)", "Life cycle emission factor (kg CO2e/liter)"])
electricity_data = dynamic_input_fields("Electricity", ["Quantity consumed (e.g., kWh)", "Life cycle emission factor (kg CO2e/kWh)"],
["Quantity consumed (e.g., kWh)", "Life cycle emission factor (kg CO2e/kWh)"])
refrigerant_data = dynamic_input_fields("Refrigerant", ["Quantity of leakage (kg)", "Global Warming Potential (kg CO2e/kg)"],
["Quantity of leakage (kg)", "Global Warming Potential (kg CO2e/kg)"])
process_emissions = st.number_input("Sum of Process Emissions (kg CO2e)", min_value=0.0, step=0.1)
include_waste = st.checkbox("Include Waste Emissions (Optional)")
waste_data = []
if include_waste:
waste_data = dynamic_input_fields("Waste", ["Mass of waste output (kg)", "Emission factor (kg CO2e/kg waste)"],
["Mass of waste output (kg)", "Emission factor (kg CO2e/kg waste)"])
calculate_emissions_category_10_method_1(fuel_data, electricity_data, refrigerant_data, process_emissions, waste_data)
def calculate_emissions_category_10_method_1(fuel_data, electricity_data, refrigerant_data, process_emissions, waste_data):
total_fuel_emissions = sum([
item["Quantity consumed (e.g., liter)"] * item["Life cycle emission factor (kg CO2e/liter)"]
for item in fuel_data
])
total_electricity_emissions = sum([
item["Quantity consumed (e.g., kWh)"] * item["Life cycle emission factor (kg CO2e/kWh)"]
for item in electricity_data
])
total_refrigerant_emissions = sum([
item["Quantity of leakage (kg)"] * item["Global Warming Potential (kg CO2e/kg)"]
for item in refrigerant_data
])
total_waste_emissions = 0.0
if waste_data:
total_waste_emissions = sum([
item["Mass of waste output (kg)"] * item["Emission factor (kg CO2e/kg waste)"]
for item in waste_data
])
total_emissions = total_fuel_emissions + total_electricity_emissions + total_refrigerant_emissions + process_emissions + total_waste_emissions
st.header(f"Total Emissions from Processing of Sold Intermediate Products (Method 1): {total_emissions} kg CO2e")
def get_input_category_10_method_2():
st.subheader("Method 2: Average-data Method - Processing of Sold Intermediate Products")
product_data = dynamic_input_fields("Intermediate Product", ["Mass of sold intermediate product (kg)", "Emission factor of processing stages (kg CO2e/kg of final product)"],
["Mass of sold intermediate product (kg)", "Emission factor of processing stages (kg CO2e/kg of final product)"])
calculate_emissions_category_10_method_2(product_data)
def calculate_emissions_category_10_method_2(product_data):
total_emissions = sum([
item["Mass of sold intermediate product (kg)"] * item["Emission factor of processing stages (kg CO2e/kg of final product)"]
for item in product_data
])
st.header(f"Total Emissions from Processing of Sold Intermediate Products (Method 2): {total_emissions} kg CO2e")
def get_input_category_11_method_1():
st.subheader("Method 1: Direct Use-phase Emissions from Products Consuming Energy (Fuels or Electricity) during Use")
product_data = dynamic_input_fields("Product", ["Total lifetime expected uses", "Number sold",
"Fuel consumed per use (kWh)", "Emission factor for fuel (kg CO2e/kWh)"],
["Total lifetime expected uses", "Number sold",
"Fuel consumed per use (kWh)", "Emission factor for fuel (kg CO2e/kWh)"])
include_electricity = st.checkbox("Include Electricity Emissions (Optional)")
electricity_data = []
if include_electricity:
electricity_data = dynamic_input_fields("Product Electricity", ["Electricity consumed per use (kWh)", "Emission factor for electricity (kg CO2e/kWh)"],
["Electricity consumed per use (kWh)", "Emission factor for electricity (kg CO2e/kWh)"])
refrigerant_data = dynamic_input_fields("Product Refrigerant", ["Refrigerant leakage per use (kg)", "Global Warming Potential (kg CO2e/kg)"],
["Refrigerant leakage per use (kg)", "Global Warming Potential (kg CO2e/kg)"])
calculate_emissions_category_11_method_1(product_data, electricity_data, refrigerant_data)
def calculate_emissions_category_11_method_1(product_data, electricity_data, refrigerant_data):
total_fuel_emissions = sum([
item["Total lifetime expected uses"] * item["Number sold"] * item["Fuel consumed per use (kWh)"] * item["Emission factor for fuel (kg CO2e/kWh)"]
for item in product_data
])
total_electricity_emissions = 0.0
if electricity_data:
total_electricity_emissions = sum([
item1["Total lifetime expected uses"] * item1["Number sold"] * item["Electricity consumed per use (kWh)"] * item["Emission factor for electricity (kg CO2e/kWh)"]
for item in electricity_data for item1 in product_data
])
total_refrigerant_emissions = sum([
item1["Total lifetime expected uses"] * item1["Number sold"] * item["Refrigerant leakage per use (kg)"] * item["Global Warming Potential (kg CO2e/kg)"]
for item in refrigerant_data for item1 in product_data
])
total_emissions = total_fuel_emissions + total_electricity_emissions + total_refrigerant_emissions
st.header(f"Total Emissions from Use of Sold Products (Method 1): {total_emissions} kg CO2e")
def get_input_category_11_method_2():
st.subheader("Method 2: Direct Use-phase Emissions from Combusted Fuels and Feedstocks")
fuel_data = dynamic_input_fields("Fuel/Feedstock", ["Total quantity sold (e.g., kWh)", "Combustion emission factor (kg CO2e/kWh)"],
["Total quantity sold (e.g., kWh)", "Combustion emission factor (kg CO2e/kWh)"])
calculate_emissions_category_11_method_2(fuel_data)
def calculate_emissions_category_11_method_2(fuel_data):
total_fuel_emissions = sum([
item["Total quantity sold (e.g., kWh)"] * item["Combustion emission factor (kg CO2e/kWh)"]
for item in fuel_data
])
st.header(f"Total Emissions from Use of Sold Products (Method 2): {total_fuel_emissions} kg CO2e")
def get_input_category_11_method_3():
st.subheader("Method 3: Direct Use-phase Emissions from Greenhouse Gases and Products Containing or Forming Greenhouse Gases")
ghg_data = dynamic_input_fields("GHG/Product Group", ["GHG contained per product", "Total Number of products sold",
"% of GHG released during lifetime use of product", "GWP of the GHG"],
["GHG contained per product", "Total Number of products sold",
"% of GHG released during lifetime use of product", "GWP of the GHG"])
calculate_emissions_category_11_method_3(ghg_data)
def calculate_emissions_category_11_method_3(ghg_data):
total_emissions = sum([
item["GHG contained per product"] * item["Total Number of products sold"] *
item["% of GHG released during lifetime use of product"] * item["GWP of the GHG"]
for item in ghg_data
])
st.header(f"Total Emissions from Use of Sold Products (Method 3): {total_emissions} kg CO2e")
def get_input_category_11_method_4():
st.subheader("Method 4: Indirect Use-phase CO2e Emissions of Products")
use_scenario_data = dynamic_input_fields("Use Scenario", ["% of total lifetime uses", "Number sold",
"Fuel consumed per use (e.g., kWh)", "Emission factor for fuel (e.g., kg CO2e/kWh)"],
["% of total lifetime uses", "Number sold",
"Fuel consumed per use (e.g., kWh)", "Emission factor for fuel (e.g., kg CO2e/kWh)"])
include_electricity = st.checkbox("Include Electricity Emissions (Optional)")
electricity_data = []
if include_electricity:
electricity_data = dynamic_input_fields("Use Scenario electricity", ["% of total lifetime uses", "Number sold",
"Electricity consumed per use (kWh)", "Emission factor for electricity (kg CO2e/kWh)"],
["% of total lifetime uses", "Number sold",
"Electricity consumed per use (kWh)", "Emission factor for electricity (kg CO2e/kWh)"])
refrigerant_data = dynamic_input_fields("Use Scenario refrigerant", ["% of total lifetime uses", "Number sold",
"Refrigerant leakage per use (kg)", "Emission factor for refrigerant (kg CO2e/kg)"],
["% of total lifetime uses", "Number sold",
"Refrigerant leakage per use (kg)", "Emission factor for refrigerant (kg CO2e/kg)"])
ghg_data = dynamic_input_fields("Use Scenario ghg data", ["% of total lifetime uses", "Number sold",
"GHG emitted indirectly (kg)", "GWP of the GHG"],
["% of total lifetime uses", "Number sold",
"GHG emitted indirectly (kg)", "GWP of the GHG"])
calculate_emissions_category_11_method_4(use_scenario_data, electricity_data, refrigerant_data, ghg_data)
def calculate_emissions_category_11_method_4(use_scenario_data, electricity_data, refrigerant_data, ghg_data):
total_fuel_emissions = sum([
item["% of total lifetime uses"] * item["Number sold"] * item["Fuel consumed per use (e.g., kWh)"] * item["Emission factor for fuel (e.g., kg CO2e/kWh)"]
for item in use_scenario_data
])
total_electricity_emissions = 0.0
if electricity_data:
total_electricity_emissions = sum([
item["% of total lifetime uses"] * item["Number sold"] * item["Electricity consumed per use (kWh)"] * item["Emission factor for electricity (kg CO2e/kWh)"]
for item in electricity_data
])
total_refrigerant_emissions = sum([
item["% of total lifetime uses"] * item["Number sold"] * item["Refrigerant leakage per use (kg)"] * item["Emission factor for refrigerant (kg CO2e/kg)"]
for item in refrigerant_data
])
total_ghg_emissions = sum([
item["% of total lifetime uses"] * item["Number sold"] * item["GHG emitted indirectly (kg)"] * item["GWP of the GHG"]
for item in ghg_data
])
total_emissions = total_fuel_emissions + total_electricity_emissions + total_refrigerant_emissions + total_ghg_emissions
st.header(f"Total Emissions from Use of Sold Products (Method 4): {total_emissions} kg CO2e")
def get_input_category_11_method_5():
st.subheader("Method 5: Use-phase CO2e Emissions of Sold Intermediate Products")
intermediate_product_data = dynamic_input_fields("Intermediate Product", ["Total intermediate products sold",
"Total lifetime uses of final sold product",
"Emissions per use of sold intermediate product (kg CO2e/use)"],
["Total intermediate products sold",
"Total lifetime uses of final sold product",
"Emissions per use of sold intermediate product (kg CO2e/use)"])
calculate_emissions_category_11_method_5(intermediate_product_data)
def calculate_emissions_category_11_method_5(intermediate_product_data):
total_emissions = sum([
item["Total intermediate products sold"] * item["Total lifetime uses of final sold product"] *
item["Emissions per use of sold intermediate product (kg CO2e/use)"]
for item in intermediate_product_data
])
st.header(f"Total Emissions from Use of Sold Products (Method 5): {total_emissions} kg CO2e")
def get_input_category_12_method_1():
st.subheader("Category 12: End-of-Life Treatment of Sold Products - Method 1: Waste-type-specific method")
waste_data = dynamic_input_fields("Waste Treatment Method", ["Total mass of sold products and packaging (kg)",
"Proportion of waste produced (%)",
"Emission factor of waste treatment method (kg CO2e/kg)"],
["Total mass of sold products and packaging (kg)",
"Proportion of waste produced (%)",
"Emission factor of waste treatment method (kg CO2e/kg)"])
calculate_emissions_category_12_method_1(waste_data)
def calculate_emissions_category_12_method_1(waste_data):
total_emissions = sum([
item["Total mass of sold products and packaging (kg)"] *
(item["Proportion of waste produced (%)"] / 100) *
item["Emission factor of waste treatment method (kg CO2e/kg)"]
for item in waste_data
])
st.header(f"Total CO2e Emissions from End-of-Life Treatment of Sold Products (Method 1): {total_emissions} kg CO2e")
def get_input_category_13():
st.subheader("Category 13: Downstream Leased Assets")
leased_assets_data = dynamic_input_fields("Lessee", ["Scope 1 and Scope 2 emissions (kg CO2e)",
"Physical area of the leased asset (e.g., area, volume)"],
["Scope 1 and Scope 2 emissions (kg CO2e)",
"Physical area of the leased asset (e.g., area, volume)"])
calculate_emissions_category_13(leased_assets_data)
def calculate_emissions_category_13(leased_assets_data):
total_physical_area = calculate_total_physical_area(leased_assets_data)
total_emissions = sum([
item["Scope 1 and Scope 2 emissions (kg CO2e)"] *
(item["Physical area of the leased asset (e.g., area, volume)"] / total_physical_area) if total_physical_area!=0 else 0
for item in leased_assets_data
])
st.header(f"Total CO2e Emissions from Leased Assets (Category 13): {total_emissions} kg CO2e")
def calculate_total_physical_area(leased_assets_data):
return sum([item["Physical area of the leased asset (e.g., area, volume)"] for item in leased_assets_data])
def get_input_category_14_method_1():
st.subheader("Category 14: Franchises - Method 1: Franchise-specific method")
franchise_data = dynamic_input_fields("Franchise", ["Scope 1 emissions (kg CO2e)", "Scope 2 emissions (kg CO2e)"],
["Scope 1 emissions (kg CO2e)", "Scope 2 emissions (kg CO2e)"])
calculate_emissions_category_14_method_1(franchise_data)
def calculate_emissions_category_14_method_1(franchise_data):
total_emissions = sum([
item["Scope 1 emissions (kg CO2e)"] + item["Scope 2 emissions (kg CO2e)"]
for item in franchise_data
])
st.header(f"Total CO2e Emissions from Franchises (Method 1): {total_emissions} kg CO2e")
def get_input_category_14_method_2():
st.subheader("Category 14: Franchises - Method 2: Allocating emissions from franchise buildings")
franchise_building_data = dynamic_input_fields("Franchise Building",
["Energy use from franchise (kWh)", "Franchise's area (m2)",
"Building's total area (m2)", "Building's occupancy rate"],
["Energy use from franchise (kWh)", "Franchise's area (m2)",
"Building's total area (m2)", "Building's occupancy rate"])
calculate_emissions_category_14_method_2(franchise_building_data)
def calculate_emissions_category_14_method_2(franchise_building_data):
total_emissions = sum([
item["Energy use from franchise (kWh)"] *
(item["Franchise's area (m2)"] / item["Building's total area (m2)"] * item["Building's occupancy rate"]) if item["Building's total area (m2)"] * item["Building's occupancy rate"] !=0 else 0
for item in franchise_building_data
])
st.header(f"Total CO2e Emissions from Franchises (Method 2): {total_emissions} kg CO2e")
def get_input_category_14_method_3():
st.subheader("Category 14: Franchises - Method 3: Extrapolating emissions from sample groups")
franchise_groups_data = dynamic_input_fields("Franchise Group", ["Total emissions from sampled franchises within group",
"Total number of franchises within group",
"Number of franchises sampled within group"],
["Total emissions from sampled franchises within group",
"Total number of franchises within group",
"Number of franchises sampled within group"])
calculate_emissions_category_14_method_3(franchise_groups_data)
def calculate_emissions_category_14_method_3(franchise_groups_data):
total_emissions = sum([
(item["Total emissions from sampled franchises within group"] / item["Total number of franchises within group"]) *
item["Number of franchises sampled within group"] if item["Total number of franchises within group"]!=0 else 0
for item in franchise_groups_data
])
st.header(f"Total CO2e Emissions from Franchises (Method 3): {total_emissions} kg CO2e")
def get_input_category_14_method_4():
st.subheader("Category 14: Franchises - Method 4: Average data method for leased buildings (if floor space data is available)")
building_types_data = dynamic_input_fields("Building Type", ["Total floor space of building type (m2)",
"Average emission factor for building type (kg CO2e/m2/year)"],
["Total floor space of building type (m2)",
"Average emission factor for building type (kg CO2e/m2/year)"])
calculate_emissions_category_14_method_4(building_types_data)
def calculate_emissions_category_14_method_4(building_types_data):
total_emissions = sum([
item["Total floor space of building type (m2)"] * item["Average emission factor for building type (kg CO2e/m2/year)"]
for item in building_types_data
])
st.header(f"Total CO2e Emissions from Franchises (Method 4): {total_emissions} kg CO2e")
def get_input_category_14_method_5():
st.subheader("Category 14: Franchises - Method 5: Average data method for other asset types or for leased buildings where floor space data is not available")
building_asset_types_data = dynamic_input_fields("Building/Asset Type", ["Number of buildings or assets",
"Average emissions per building or asset type per year (kg CO2e/building or asset type/year)"],
["Number of buildings or assets",
"Average emissions per building or asset type per year (kg CO2e/building or asset type/year)"])
calculate_emissions_category_14_method_5(building_asset_types_data)
def calculate_emissions_category_14_method_5(building_asset_types_data):
total_emissions = sum([
item["Number of buildings or assets"] * item["Average emissions per building or asset type per year (kg CO2e/building or asset type/year)"]
for item in building_asset_types_data
])
st.header(f"Total CO2e Emissions from Franchises (Method 5): {total_emissions} kg CO2e")
def get_input_category_15_method_1():
st.subheader("Category 15: Investments - Method 1: Investment-specific method for equity investments")
equity_investment_data = dynamic_input_fields("Equity Investment",
["Scope 1 and scope 2 emissions of investee company (tonnes CO2e)",
"Reporting company’s share of equity (%)"],
["Scope 1 and scope 2 emissions of investee company (tonnes CO2e)",
"Reporting company’s share of equity (%)"])
calculate_emissions_category_15_method_1(equity_investment_data)
def calculate_emissions_category_15_method_1(equity_investment_data):
total_emissions = sum([
item["Scope 1 and scope 2 emissions of investee company (tonnes CO2e)"] *
(item["Reporting company’s share of equity (%)"] / 100)
for item in equity_investment_data
])
st.header(f"Total CO2e Emissions from Investments (Method 1): {total_emissions} tonnes CO2e")
def get_input_category_15_method_2():
st.subheader("Category 15: Investments - Method 2: Average data method for equity investments")
equity_investment_average_data = dynamic_input_fields("Equity Investment Average Data",
["Investee company total revenue ($)",
"Emission factor for investee’s sector (kg CO2e/$ revenue)",
"Reporting company’s share of equity (%)"],
["Investee company total revenue ($)",
"Emission factor for investee’s sector (kg CO2e/$ revenue)",
"Reporting company’s share of equity (%)"])
calculate_emissions_category_15_method_2(equity_investment_average_data)
def calculate_emissions_category_15_method_2(equity_investment_average_data):
total_emissions = sum([
(item["Investee company total revenue ($)"] * item["Emission factor for investee’s sector (kg CO2e/$ revenue)"]) *
(item["Reporting company’s share of equity (%)"] / 100)
for item in equity_investment_average_data
])
st.header(f"Total CO2e Emissions from Investments (Method 2): {total_emissions} tonnes CO2e")
def get_input_category_15_method_3():
st.subheader("Category 15: Investments - Method 3: Project-specific method for project finance and debt investments")
project_finance_data = dynamic_input_fields("Project Finance",
["Scope 1 and scope 2 emissions of relevant project (tonnes CO2e)",
"Value of debt investment ($)", "Total project costs (total equity plus debt) ($)",
"Share of total project costs (%)"],
["Scope 1 and scope 2 emissions of relevant project (tonnes CO2e)",
"Value of debt investment ($)", "Total project costs (total equity plus debt) ($)",
"Share of total project costs (%)"])
calculate_emissions_category_15_method_3(project_finance_data)
def calculate_emissions_category_15_method_3(project_finance_data):
total_emissions = sum([
item["Scope 1 and scope 2 emissions of relevant project (tonnes CO2e)"] *
(item["Share of total project costs (%)"] / 100)
for item in project_finance_data
])
st.header(f"Total CO2e Emissions from Investments (Method 3): {total_emissions} tonnes CO2e")
def get_input_category_15_method_4():
st.subheader("Category 15: Investments - Method 4: Average-data method for project finance and debt investments")
project_finance_average_data = dynamic_input_fields("Project Finance Average Data",
["Project construction cost or project revenue in reporting year ($ million)",
"Emission factor of relevant construction or operating sector (kg CO2e/$ revenue)",
"Share of total project costs (value of debt investment / total equity plus debt) (%)"],
["Project construction cost or project revenue in reporting year ($ million)",
"Emission factor of relevant construction or operating sector (kg CO2e/$ revenue)",
"Share of total project costs (value of debt investment / total equity plus debt) (%)"])
calculate_emissions_category_15_method_4(project_finance_average_data)
def calculate_emissions_category_15_method_4(project_finance_average_data):
total_emissions = sum([
((item["Project construction cost or project revenue in reporting year ($ million)"] *
item["Emission factor of relevant construction or operating sector (kg CO2e/$ revenue)"]) *
item["Share of total project costs (value of debt investment / total equity plus debt) (%)"] / 100)
for item in project_finance_average_data
])
st.header(f"Total CO2e Emissions from Investments (Method 4): {total_emissions} tonnes CO2e")
def main():
st.title("CO2 Emission Calculator")
selected_category = st.selectbox("Select Category", categories)
if selected_category in ["Category 1", "Category 2"]:
method_options = ["Supplier Specific Method", "Hybrid Method", "HybridPro Method"]
method = st.selectbox("Select Method", method_options)
if method == "Supplier Specific Method":
st.header("Supplier Specific Method")
num_items = st.number_input("Number of items", min_value=1, step=1)
purchased_goods_data = []
for i in range(num_items):
goods = st.selectbox(f"Purchased Goods {i + 1}", purchased_goods_values, key=f"goods_{i}")
supplier = st.selectbox(f"Supplier {i + 1}", supplier_values, key=f"supplier_{i}")
qty = st.number_input(f"Qty Purchased (kg) {i + 1}", min_value=0.0, step=0.01, key=f"qty_{i}")
emission_factor = st.number_input(f"Supplier-specific Emission Factor (kg CO2e/kg) {i + 1}", min_value=0.0, step=0.01, key=f"emission_factor_{i}")
purchased_goods_data.append((goods, supplier, qty, emission_factor))
calculate_emissions_supplier_specific(purchased_goods_data)
elif method == "Hybrid Method":
st.header("Hybrid Method")
scope1_and_scope2_data = dynamic_input_fields_with_dropdown("Scope 1 and Scope 2 data from supplier B relating to production of purchased goods", "Enter scope 1 and scope 2 data", scope_values, ["Category","Amount (kWh)", "Emission factor (kg CO2e/kWh)"])
material_inputs_data = dynamic_input_fields_with_dropdown("Material inputs of purchased goods", "Enter material input data", material_inputs_values, ["Purchased Goods", "Mass purchased (kg)", "Emission factor (kg CO2e/kg)"])
transport_data = dynamic_input_fields_with_dropdown("Transport of material inputs to supplier B", "Enter transport data", transport_values, ["Purchased Goods", "Distance of transport (km)", "Vehicle type emission factor (kg CO2e/kg/km)"])
waste_output_data = dynamic_input_fields_with_emission_factor("Waste outputs by supplier B relating to production of purchased goods", "Enter waste output data", waste_output_values, ["Amount (kg)", "Emission factor (kg CO2e/kg of waste sent to landfill)"])
calculate_emissions_hybrid(scope1_and_scope2_data, material_inputs_data, transport_data, waste_output_data)
elif method == "HybridPro Method":
scope_data = dynamic_input_fields_with_dropdown("Scope 1 and Scope 2 data from supplier B", "Enter scope data", scope_values, ["Category","Amount (kWh)", "Emission factor (kg CO2e/kWh)"])
tshirt_data = dynamic_input_fields_with_emission_factor("T-shirts", "Enter T-shirt data", purchased_goods_values,
["Number of t-shirts purchased",
"Cradle-to-gate process emission factor (kg CO2e/per t-shirt)","Cradle-to-gate process emission factor (kg CO2e/per t-shirt(excluding scopes)"])
waste_output_data = dynamic_input_fields_with_emission_factor("Waste outputs by supplier B", "Enter waste output data", waste_output_values,
["Amount (kg)", "Emission factor (kg CO2e/kg of waste sent to landfill)"])
calculate_emissions_hybrid_pro(tshirt_data, scope_data, waste_output_data)
elif selected_category=="Category 3":
collect_category_3_data()
elif selected_category == "Category 4":
method_options = ["Method 1: Fuel-based Method", "Method 2: Unladen Backhaul", "Method 3: Transportation", "Method 4: Distribution", "Method 5: Distribution"]
selected_method = st.selectbox("Select Method for Category 4", method_options)
if selected_method == "Method 1: Fuel-based Method":
collect_category_4_method_1_data()
elif selected_method == "Method 2: Unladen Backhaul":
collect_category_4_method_2_data()
elif selected_method == "Method 3: Transportation":
collect_category_4_method_3_data()
elif selected_method == "Method 4: Distribution":
collect_category_4_method_4_data()
elif selected_method == "Method 5: Distribution":
collect_category_4_method_5_data()
elif selected_category == "Category 5":
method_options = ["Method 1: Waste Operations using scope", "Method 2: Waste operations using produce", "Method 3: Average Method"]
selected_method = st.selectbox("Select Method for Category 5", method_options)
if selected_method == "Method 1: Waste Operations using scope":
get_input_category_5_method_1()
elif selected_method == "Method 2: Waste operations using produce":
get_input_category_5_method_2()
elif selected_method == "Method 3: Average Method":
get_input_category_5_method_3()
elif selected_category == "Category 6":
get_input_category_6_method_1()
elif selected_category == "Category 7":
method_options = ["Method 1: Standard method", "Method 2: Average Method"]
selected_method = st.selectbox("Select Method for Category 7", method_options)
if selected_method == "Method 1: Standard method":
get_input_category_7_method_1()
elif selected_method == "Method 2: Average Method":
get_input_category_7_method_2()
elif selected_category == "Category 8":
method_options = ["Method 1: Asset specific", "Method 2: Leased assets", "Method 3: Average method for leased assets","Method 4: Average method for leased buildings"]
selected_method = st.selectbox("Select Method for Category 8", method_options)
if selected_method == "Method 1: Asset specific":
get_input_category_8_method_1()
elif selected_method == "Method 2: Leased assets":
get_input_category_8_method_2()
elif selected_method == "Method 3: Average method for leased assets":
get_input_category_8_method_3()
elif selected_method == "Method 4: Average method for leased buildings":
get_input_category_8_method_4()
elif selected_category == "Category 9":
get_input_category_9_method_1()
elif selected_category == "Category 10":
method_options = ["Method 1: Site-specific", "Method 2: Average specific"]
selected_method = st.selectbox("Select Method for Category 10", method_options)
if selected_method == "Method 1: Site-specific":
get_input_category_10_method_1()
elif selected_method == "Method 2: Average specific":
get_input_category_10_method_2()
elif selected_category == "Category 11":
method_options = ["Method 1: Direct energy consumption", "Method 2: Combusted Fuels", "Method 3: Greenhouse gases","Method 4: Indirect use","Method 5: Sold-intermediate products"]
selected_method = st.selectbox("Select Method for Category 11", method_options)
if selected_method == "Method 1: Direct energy consumption":
get_input_category_11_method_1()
elif selected_method == "Method 2: Combusted Fuels":
get_input_category_11_method_2()
elif selected_method == "Method 3: Greenhouse gases":
get_input_category_11_method_3()
elif selected_method == "Method 4: Indirect use":
get_input_category_11_method_4()
else:
get_input_category_11_method_5()
elif selected_category == "Category 12":
get_input_category_12_method_1()
elif selected_category == "Category 13":
get_input_category_13()
elif selected_category == "Category 14":
method_options = ["Method 1: Franchise-specific", "Method 2: Allocating emissions from franchise buildings that are not sub-metered", "Method 3: Extrapolating emissions from sample groups","Method 4: Average data method for leased buildings (if floor space data is available)","Method 5: Average data method for other asset types or for leased buildings where floor space data is not available"]
selected_method = st.selectbox("Select Method for Category 14", method_options)
if selected_method == "Method 1: Franchise-specific":
get_input_category_14_method_1()
elif selected_method == "Method 2: Allocating emissions from franchise buildings that are not sub-metered":
get_input_category_14_method_2()
elif selected_method == "Method 3: Extrapolating emissions from sample groups":
get_input_category_14_method_3()
elif selected_method == "Method 4: Average data method for leased buildings (if floor space data is available)":
get_input_category_14_method_4()
else:
get_input_category_14_method_5()
else:
method_options = ["Method 1: Investment-specific method for calculating emissions from equity investments", "Method 2: Average data method ", "Method 3: Project-specific method for calculating emissions from project finance and debt investments with known use of proceeds","Method 4: Average-data method for calculating emissions from project finance and debt investments with known use of proceeds"]
selected_method = st.selectbox("Select Method for Category 14", method_options)
if selected_method == "Method 1: Investment-specific method for calculating emissions from equity investments":
get_input_category_15_method_1()
elif selected_method == "Method 2: Average data method ":
get_input_category_15_method_2()
elif selected_method == "Method 3: Project-specific method for calculating emissions from project finance and debt investments with known use of proceeds":
get_input_category_15_method_3()
elif selected_method == "Method 4: Average-data method for calculating emissions from project finance and debt investments with known use of proceeds":
get_input_category_15_method_4()
def dynamic_input_fields(label, values, headings, country=None):
num_items = st.number_input(f"**Number of {label} items**", min_value=1, step=1, key=f"{label}_num_items")
input_fields = []
for i in range(num_items):
st.subheader(f"{label} {i + 1}")
input_data = {}
if country:
input_data["Country"] = country
for value, heading in zip(values, headings):
key = f"{label}_{i}_{value}_{heading}"
input_data[value] = st.number_input(f"{heading} {i + 1}", min_value=0.0, step=0.01, key=key)
input_fields.append(input_data)
return input_fields
def dynamic_input_fields_with_dropdown(label, prompt, values, headings):
num_items = st.number_input(f"**Number of {label} items**", min_value=1, step=1, key=f"{label}_num_items")
input_fields = []
for i in range(num_items):
st.subheader(f"{label} {i + 1}")
input_data = {}
input_data[headings[0]] = st.selectbox(f"{headings[0]} {i + 1}", values, key=f"{label}_{i}_{headings[0]}")
for heading in headings[1:]:
input_data[heading] = st.number_input(f"{heading} {i + 1}", min_value=0.0, step=0.01, key=f"{label}_{i}_{heading}")
input_fields.append(input_data)
return input_fields
def dynamic_input_fields_with_emission_factor(label, prompt, values, headings):
num_items = st.number_input(f"**Number of {label} items**", min_value=1, step=1, key=f"{label}_num_items")
input_fields = []
for i in range(num_items):
st.subheader(f"{label} {i + 1}")
input_data = {}
for heading in headings:
input_data[heading] = st.number_input(f"{heading} {i + 1}", min_value=0.0, step=0.01, key=f"{label}_{i}_{heading}")
input_fields.append(input_data)
return input_fields
def dynamic_input_fields_with_dropdown_int(label, prompt, values, headings):
num_items = st.number_input(f"**Number of {label} items**", min_value=1, step=1, key=f"{label}_num_items")
input_fields = []
dropdown_options = {
"Location": ["US", "Aus"],
"Car_type": ["Hybrid", "Gasoline", "4 wheel"],
}
for i in range(num_items):
st.subheader(f"{label} {i + 1}")
input_data = {}
for j, heading in enumerate(headings):
if heading in dropdown_options:
input_data[heading] = st.selectbox(f"{heading} {i + 1}", dropdown_options[heading], key=f"{label}_{i}_{heading}")
else:
input_data[heading] = st.number_input(f"{heading} {i + 1}", min_value=0, step=1, key=f"{label}_{i}_{heading}")
input_fields.append(input_data)
return input_fields
if __name__ == "__main__":
main()
|