

DataFrame( data = data, index = index)ĭef prepare_setup( client: olca. With open( file_path, 'r', encoding = 'cp1252') as stream: assumption: not more than 5 sets - if there are more, the row index and the csv file can be changed """ index =

""" Read the given parameter table into a pandas data frame where the parameter names are mapped to the index. now() - start)ĭef read_parameters( file_path: 'file\path') -> pandas. id, parameter_set)Įxport_and_dispose( client, result, excel_file) # we store the Excel file under # `output/_.xlsx` excel_file = 'output/%s_%d.xlsx' % ( system. run calculation for parameter set %i' % parameter_set) Set_parameters( calculation_setup, parameters, parameter_set) product_system = system for parameter_set in range( 0, parameters. Print( 'Run calculations for product system %s (%s)' %Ĭalculation_setup. # we run a calculation for each combination of parameter set and product # system that is in the database for system in client. # we prepare a calculation setup for the given LCIA method and reuse it # for the different product systems in the database calculation_setup = prepare_setup( client, 'The Name of the LCIA method') # first we read the parameter sets they are stored in a data frame where # each column is a different parameter set # 1st column: parameter UUID # 2nd column: parameter name # last column: process name, for documentation parameters = read_parameters( # make sure that you started an IPC server with the specific database in # openLCA (Window > Developer Tools > IPC Server) client = olca.

# the Excel files with the results are written to the `output` folder if not os. Import csv import os import sys import olca import pandas import arrow as ar def main(): Execute the script in an external Python IDE such as P圜harm or similar. Then, start the IPC server in openLCA with port 8080. You can also extend the number of parameters sets (in the script and, correspondingly, in the csv file). Create the csv file with UUID of parameter, name of parameter, then the parameter values in different columns, one per set. To use it, adapt the LCIA method name and the paths to the csv file and to the Excel file. The calculations are done for all parameter sets in the csv file. It calculates all product systems existing in the selected database with an LCIA methodįrom this database that is identified by name. This script uses the IPC server of openLCA for connecting via Python to openLCA. Main() Calculate a product system with many different parameter values that are read from a csv file, and store the results in Excel # load the flows and write them to a CSV file flows = FlowDao( db). Sql = ''' SELECT DISTINCT f.id FROM tbl_flows f INNER JOIN tbl_exchanges e ON f.id = e.f_flow WHERE f.flow_type = 'ELEMENTARY_FLOW' ''' def collect_ids( r): Global db # collect the IDs of the used elementary flows # via an SQL query ids = set() util import Categories # set the path to the resulting CSV file here CSV_FILE = 'C:/Users/ms/Desktop/used_elem_flows.csv' def main(): database import FlowDao, NativeSql from org. getForName( 'Europe EI 99 E/E '))įor i in provider. withCosts = True method_dao = ImpactMethodDao( db) # load the product system db_dir = File( 'C:/Users/Besitzer/openLCA-data-1.4/databases/openlca_lcia_methods_1_5_5') matrix import NwSetTable if _name_ = '_main_': results import ContributionResultProvider from org.

math import CalculationSetup, SystemCalculator from org. database import ProductSystemDao, Entit圜ache,\ close() Using the formula interpreterįrom java. Provider = ContributionResultProvider( result, e_cache) # calculation setup = CalculationSetup( system)Ĭalculator = SystemCalculator( m_cache, solver) # caches, native lib., solver m_cache = MatrixCache. # load the product system db_dir = File( 'C:/Users/Besitzer/openLCA-data-1.4/databases/ei_3_3_apos_dbv4') results import ContributionResultProvider if _name_ = '_main_': database import ProductSystemDao, Entit圜ache from org.
