|
| 1 | +# ced.py (lciafmt) |
| 2 | +# !/usr/bin/env python3 |
| 3 | +# coding=utf-8 |
| 4 | +""" |
| 5 | +Generate method for Cumulative Energy Demand (CED) |
| 6 | +""" |
| 7 | + |
| 8 | +import numpy as np |
| 9 | +import pandas as pd |
| 10 | + |
| 11 | +import lciafmt |
| 12 | +from lciafmt.util import store_method |
| 13 | + |
| 14 | + |
| 15 | +def get() -> pd.DataFrame(): |
| 16 | + |
| 17 | + inv_orig = lciafmt.get_method(method_id = 'FEDEFL_INV', subset = ['ced']) |
| 18 | + inv = inv_orig.copy() |
| 19 | + inv['Indicator'] = '' |
| 20 | + inv['Method'] = 'Cumulative Energy Demand' |
| 21 | + |
| 22 | + conditions = [ |
| 23 | + inv['Flowable'].isin(['Wood, primary forest']), |
| 24 | + inv['Flowable'].isin(['Biomass', 'Softwood', 'Hardwood', 'Wood']), |
| 25 | + inv['Flowable'].isin(['Energy, hydro']), |
| 26 | + inv['Flowable'].str.contains('|'.join(['wind', 'solar', 'geothermal'])), |
| 27 | + inv['Flowable'].str.contains('Uranium'), |
| 28 | + inv['Flowable'].str.contains('|'.join(['Coal', 'Oil', 'Crude', |
| 29 | + 'gas', 'Methane'])), |
| 30 | + ] |
| 31 | + |
| 32 | + indicators = ['Non-renewable, biomass', |
| 33 | + 'Renewable, biomass', |
| 34 | + 'Renewable, water', |
| 35 | + 'Renewable, wind, solar, geothermal', |
| 36 | + 'Non-renewable, nuclear', |
| 37 | + 'Non-renewable, fossil', |
| 38 | + ] |
| 39 | + inv['Indicator'] = np.select(conditions, indicators, default='') |
| 40 | + |
| 41 | + ## Original CED Method included the |
| 42 | + # "Energy, fossil, unspecified" technosphere flow; |
| 43 | + # this has been dropped |
| 44 | + # https://www.lcacommons.gov/lca-collaboration/National_Renewable_Energy_Laboratory/USLCI_Database_Public/dataset/FLOW/46dc4693-2f24-39d2-b69f-dd059737fd5e |
| 45 | + |
| 46 | + ## Original CED Method used HHV for biomass/wood flows |
| 47 | + # Some wood flows were removed after the original method in FEDEFLv1.0.8 |
| 48 | + |
| 49 | + # Dropped flows from FEDEFL inv method: "Hydrogen", "Energy, heat" |
| 50 | + inv = inv.query('Indicator != ""').reset_index(drop=True) |
| 51 | + |
| 52 | + return inv |
| 53 | + |
| 54 | + |
| 55 | +if __name__ == "__main__": |
| 56 | + method = lciafmt.Method.CED |
| 57 | + df = get() |
| 58 | + store_method(df, method) |
| 59 | + lciafmt.util.save_json(method, df) |
| 60 | + # lciafmt.util.save_json(method, df, write_flows=True) |
0 commit comments