How to use the bw2io.package.BW2Package function in bw2io

To help you get started, we’ve selected a few bw2io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pjamesjoyce / lcopt / lcopt / bw2_import.py View on Github external
def create_LcoptModel_from_BW2Package(import_filename, autosetup=True):
    
    import_data = BW2Package.load_file(import_filename)
    orig_db = import_data[0]['data']
    db_name = import_data[0]['name']
    model = LcoptModel(db_name, autosetup=autosetup)
    db = deepcopy(orig_db)

    temp_param_set = []
    temp_production_param_set = []

    for k, v in db.items():
        exchanges = []
        production_amount = v.get('production amount', 1)

        if production_amount != 1:
            print("NOTE: Production amount for {} is not 1 unit ({})".format(v['name'], production_amount, production_amount))

        temp_production_param_set.append({'of': v['name'], 'amount': production_amount})