Life Cycle Assessment
- class gsa_framework.models.life_cycle_assessment.LCAModel(func_unit, method, write_dir, num_params=None, uncertain_exchanges_types=('tech', 'bio', 'cf'))
Class that implements basic LCA model which uses uncertainty in the background database.
- Parameters
func_unit (dict) – Dictionary of the form {bw_demand_activity: amount}.
method (tuple) – Tuple with an impact assessment method.
write_dir (str) – Directory where intermediate results will be stored.
num_params (int) – Number of parameters that can be influential, the rest are removed based on local sensitivity analysis.
lca (bw.LCA object) – Instance of an LCA class from brightway library.
- Returns
y – Returns LCIA scores when technosphere exchanges are sampled from their respective distributions.
- Return type
np.array of size [iterations, 1]
- get_LSA_params(var_threshold)
Get
params_yeswith a specific threshold.If the given threshold is being used for the first time,
params_yeswill be computed using the functionget_nonzero_paramsand saved to the LSA_scores directory, otherwise it is loaded which saves time.
- get_inputs_outputs_scores_from_files(path, files_sorted)
Get inputs, outputs and scores from multiple LSA_scores files.
- get_lsa_scores_dict(path, exchanges_type)
Retrieve scores_dict for tech, bio and cf exchanges.
- get_lsa_scores_pickle(path, uncertain_exchanges_types)
Get LCIA scores stored in the
path, where each parameter was sampled only few (eg 3-10) times.- Parameters
path (str) – Path that contains pickle files with LCIA scores, where each uncertain exchange in the technosphere is varied independently of all other exchanges but only few times. Needed to determine which exchanges do NOT change LCIA score of the given functional unit and method, and hence, can be disregarded in the GSA. Pickle files explicitly contain
(database, code)tuples for input and output activities, in order to most certainly define exchanges.- Returns
scores – Keys are indices of the exchanges as they appear in the models.tech_params, values are LCIA scores.
- Return type
dict
- get_lsa_scores_tech_files(path)
Function that finds all LSA_scores* files
- get_nonzero_params_from_var_threshold(scores_dict, var_threshold)
Given a dictionary of LSA scores, finds parameters that have variance below and above the threshold.
Variance of the LSA scores that is smaller than eg 1e-20 is due to numerical imprecision. That means,
params_nocan be disregarded in the subsequent GSA.- Parameters
scores_dict (dict) – Keys are indices of the exchanges as they appear in the models.tech_params, values are LCIA scores.
var_threshold (float) – Threshold for the variance of LSA scores.
- Returns
params_no (np.array) – Indices of exchanges (as in models.tech_params), where the variance of LSA scores is BELOW
var_threshold.params_yes (np.array) – Indices of exchanges (as in models.tech_params), where the variance of LSA scores is ABOVE
var_threshold.
- get_scores_dict_from_params(exchanges_type, scores, inputs, outputs=None)
Get scores_dict where keys are indices of exchanges in tech_params/bio_params/cf_params, and values are LSA scores.
- make_dirs()
Create subdirectories where intermediate results can be stored.