openlca2bw


Nameopenlca2bw JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/cyrillefrancois/openlca2bw
SummaryA Python package to extract and write an LCA database from OpenLCA to Brightway2
upload_time2023-11-09 12:35:59
maintainer
docs_urlNone
authorCyrille François
requires_python
licenseBSD-3
keywords open life-cycle analysis openlca brightway
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## OLCA2BW package



This is a Python package to import OpenLCA database to the brightway python environment



To install:



From Pypi



> pip install openlca2bw





From github



> pip install git+https://github.com/cyrillefrancois/openlca2bw



If folder downloaded 



> pip install path_to_setup_folder



for exemple C:/user/userprofile/document/openlca2bw



the main functions to import olca database to brightway are load_openLCA_IPC() (to import from IPC protocol) or load_openLCA_Json() (to import from a .zip json extraction)



## IPC protocol importation



The IPC connection is made by the OpenLCA software and allows ather software to access the database.

To import with IPC protocol, you need to lauch OpenLCA, to open your database and activate the IPC protocol from the OpenLCA software (Tool/Developer tools/IPC server)

The default port value is 8080



The load_openLCA_IPC() function has default values and can be run without entries, nontheless all processes will be stored in one unique bw2 database ('EcoInvent').

To split OpenLCA into several database you need to specify the databases you want to create and the OpenLCA folders related.

The format of "user_databases" entry is a dictionnary :



> user_databases = {'FirstDatabase': ['Folder1','Folder2',...],'SecondDatabase': 'Folder3','ThirdDatabase': List or single name}



With this example you will three databases in brightway that contains the processes contain in the specified folders.



Others options are available in this function:

- port: integer -> to specified the IPC port value if it is different than 8080

- project_name: string -> the name of the brightway project that will contain your openlca database

- overwrite: boolean -> True to overwrite an existing brightway project with the same name

- nonuser_db_name: string -> the name of the brightway database that will contain the nonuser database (processes that are not specified in the user_databases folders)

- check_nonuser_exc: boolean -> if True the program will check if all nonuser processes' exchanges have correct connexion, especially regarding unit conversion

- user_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related

- excluded_folders: list -> a list of openLCA folders names that will not be imported

- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) 

- selected_methods: list or all -> a list of LCIA methods in OpenLCA that will be imported. The default value is 'all' to import all methods present, an empty list not will import any method



> load_openLCA_IPC(port = 8080, project_name="Open_imports",overwrite=False, 

>                     nonuser_db_name = 'EcoInvent',check_nonuser_exc=False,

>                     user_databases={},excluded_folders=[], exclude_S=False, selected_methods= all)

                     

example to run function:

> import openlca2bw

>

> my_dict = {'FirstDatabase': ['Folder1','Folder2'],'SecondDatabase': 'Folder3'}

>

> #after activating IPC server from OpenLCA

>

> load_openLCA_IPC(project_name="Example_Name",user_databases=my_dict)

                     

The update_openLCA_IPC() function only import specified elements to an existing brightway project.

The update_databases dictionnary allows the user to specified the brightway databases that will be replaced.

It seems complicated to only import modification, so the program delete the previous database and load the new one with specified openLCA folders.



> update_openLCA_IPC(port = 8080, project_name="Open_imports",update_biosphere=False,update_methods=[],

>                     update_databases={}, exclude_S=False)



- port: integer -> to specified the IPC port value if it is different than 8080

- project_name: string -> the name of the brightway project that will be updated

- update_biosphere: boolean -> if True the program import all elementary flows and replace the existing 'biosphere3' database in brightway

- update_methods: list -> indicate in a list LCIA methods to be imported or updated. To import no method specify an empty list.The program will import LCIA methods and write the new methods or replace old ones if some differents are presents

- update_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related (see previous user_databases format)

- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) 



## JSON files importation



The JSON format is a commun format for same database and OpenLCA allows the exportation of database in this format (JSON-LD).

Compare the the IPC protocol, the JSON importation require export from OpenLCA that add significantly more time than IPC connexion, but JSON zip file can be send to others users.



The load_openLCA_Json() function work similarly than load_openLCA_IPC but the path to the zip file containing all JSON file need to be specified (path_zip)

To create a all new brightway project you need to export from OpenLCA all the flows, the processes, the LCIA methods and properties (unit, flows properties and locations)



Others options are available in this function:

- path_zip: string -> the complete path to your zip file or to the directory with all extrated folders. 

- project_name: string -> the name of the brightway project that will contain your openlca database

- overwrite: boolean -> True to overwrite an existing brightway project with the same name

- nonuser_db_name: string -> the name of the brightway database that will contain the nonuser database (processes that are not specified in the user_databases folders)

- check_nonuser_exc: boolean -> if True the program will check if all nonuser processes' exchanges have correct connexion, especially regarding unit conversion

- user_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related

- excluded_folders: list -> a list of openLCA folders names that will not be imported

- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) 

- selected_methods: list or all -> a list of LCIA methods in OpenLCA that will be imported. The default value is 'all' to import all methods present, an empty list not will import any method



>load_openLCA_Json(path_zip=str, project_name="Open_imports",overwrite=False, 

>                     nonuser_db_name = 'EcoInvent',check_nonuser_exc=False,

>                     user_databases={},excluded_folders=[], exclude_S=False, selected_methods = all) 



example to run function:

> import openlca2bw

>

> my_dict = {'FirstDatabase': ['Folder1','Folder2'],'SecondDatabase': 'Folder3'}

>

> #after exporting json zip from OpenLCA

>

> load_openLCA_Json(path_zip=r'C:\user\userprofile\document\olcaJSON.zip',user_databases=my_dict)



The update_openLCA_Json() function only import specified elements to an existing brightway project.

The update_databases dictionnary allows the user to specified the brightway databases that will be replaced.

It seems complicated to only import modification, so the program delete the previous database and load the new one with specified openLCA folders.

With this function no need to export the all database from OpenLCA, only modified element con be exported



> update_openLCA_Json(path_zip=str, project_name="Open_imports",update_biosphere=False,update_methods=[],

>                     update_databases={}, exclude_S=False)



- path_zip: string -> the complete path to your zip file

- project_name: string -> the name of the brightway project that will be updated

- update_biosphere: boolean -> if True the program import all elementary flows and replace the existing 'biosphere3' database in brightway

- update_methods: list -> indicate in a list LCIA methods to be imported or updated. To import no method specify an empty list.The program will import LCIA methods and write the new methods or replace old ones if some differents are presents

- update_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related (see previous user_databases format)

- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) 





OpenLCA has many specificities and this package may not handle all of them.

For instance, a technological exchange without a specified provider that can be satisfy by several activities is deleted frmo the activity (a single provider is retrieve). LCA model in OpenLCA need to be completly defined. 



                 

OpenLCA database has many exceptions and depending on your database some errors may araise. Feel free to share issues and potential correction.



Next steps for this package :

- Apply allocation factors when importing

- Write processes and data from brightway2 to OpenLCA

- Errors and exceptions corrections

- Computing and coding optimization


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cyrillefrancois/openlca2bw",
    "name": "openlca2bw",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "open life-cycle analysis,openLCA,brightway",
    "author": "Cyrille Fran\u00e7ois",
    "author_email": "cyrille.francois.pro@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b9/d6/44d400cd6c3fad34801f6f30aab559927a292151893d689dad060c389e47/openlca2bw-1.0.0.tar.gz",
    "platform": null,
    "description": "## OLCA2BW package\r\n\r\n\r\n\r\nThis is a Python package to import OpenLCA database to the brightway python environment\r\n\r\n\r\n\r\nTo install:\r\n\r\n\r\n\r\nFrom Pypi\r\n\r\n\r\n\r\n> pip install openlca2bw\r\n\r\n\r\n\r\n\r\n\r\nFrom github\r\n\r\n\r\n\r\n> pip install git+https://github.com/cyrillefrancois/openlca2bw\r\n\r\n\r\n\r\nIf folder downloaded \r\n\r\n\r\n\r\n> pip install path_to_setup_folder\r\n\r\n\r\n\r\nfor exemple C:/user/userprofile/document/openlca2bw\r\n\r\n\r\n\r\nthe main functions to import olca database to brightway are load_openLCA_IPC() (to import from IPC protocol) or load_openLCA_Json() (to import from a .zip json extraction)\r\n\r\n\r\n\r\n## IPC protocol importation\r\n\r\n\r\n\r\nThe IPC connection is made by the OpenLCA software and allows ather software to access the database.\r\n\r\nTo import with IPC protocol, you need to lauch OpenLCA, to open your database and activate the IPC protocol from the OpenLCA software (Tool/Developer tools/IPC server)\r\n\r\nThe default port value is 8080\r\n\r\n\r\n\r\nThe load_openLCA_IPC() function has default values and can be run without entries, nontheless all processes will be stored in one unique bw2 database ('EcoInvent').\r\n\r\nTo split OpenLCA into several database you need to specify the databases you want to create and the OpenLCA folders related.\r\n\r\nThe format of \"user_databases\" entry is a dictionnary :\r\n\r\n\r\n\r\n> user_databases = {'FirstDatabase': ['Folder1','Folder2',...],'SecondDatabase': 'Folder3','ThirdDatabase': List or single name}\r\n\r\n\r\n\r\nWith this example you will three databases in brightway that contains the processes contain in the specified folders.\r\n\r\n\r\n\r\nOthers options are available in this function:\r\n\r\n- port: integer -> to specified the IPC port value if it is different than 8080\r\n\r\n- project_name: string -> the name of the brightway project that will contain your openlca database\r\n\r\n- overwrite: boolean -> True to overwrite an existing brightway project with the same name\r\n\r\n- nonuser_db_name: string -> the name of the brightway database that will contain the nonuser database (processes that are not specified in the user_databases folders)\r\n\r\n- check_nonuser_exc: boolean -> if True the program will check if all nonuser processes' exchanges have correct connexion, especially regarding unit conversion\r\n\r\n- user_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related\r\n\r\n- excluded_folders: list -> a list of openLCA folders names that will not be imported\r\n\r\n- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) \r\n\r\n- selected_methods: list or all -> a list of LCIA methods in OpenLCA that will be imported. The default value is 'all' to import all methods present, an empty list not will import any method\r\n\r\n\r\n\r\n> load_openLCA_IPC(port = 8080, project_name=\"Open_imports\",overwrite=False, \r\n\r\n>                     nonuser_db_name = 'EcoInvent',check_nonuser_exc=False,\r\n\r\n>                     user_databases={},excluded_folders=[], exclude_S=False, selected_methods= all)\r\n\r\n                     \r\n\r\nexample to run function:\r\n\r\n> import openlca2bw\r\n\r\n>\r\n\r\n> my_dict = {'FirstDatabase': ['Folder1','Folder2'],'SecondDatabase': 'Folder3'}\r\n\r\n>\r\n\r\n> #after activating IPC server from OpenLCA\r\n\r\n>\r\n\r\n> load_openLCA_IPC(project_name=\"Example_Name\",user_databases=my_dict)\r\n\r\n                     \r\n\r\nThe update_openLCA_IPC() function only import specified elements to an existing brightway project.\r\n\r\nThe update_databases dictionnary allows the user to specified the brightway databases that will be replaced.\r\n\r\nIt seems complicated to only import modification, so the program delete the previous database and load the new one with specified openLCA folders.\r\n\r\n\r\n\r\n> update_openLCA_IPC(port = 8080, project_name=\"Open_imports\",update_biosphere=False,update_methods=[],\r\n\r\n>                     update_databases={}, exclude_S=False)\r\n\r\n\r\n\r\n- port: integer -> to specified the IPC port value if it is different than 8080\r\n\r\n- project_name: string -> the name of the brightway project that will be updated\r\n\r\n- update_biosphere: boolean -> if True the program import all elementary flows and replace the existing 'biosphere3' database in brightway\r\n\r\n- update_methods: list -> indicate in a list LCIA methods to be imported or updated. To import no method specify an empty list.The program will import LCIA methods and write the new methods or replace old ones if some differents are presents\r\n\r\n- update_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related (see previous user_databases format)\r\n\r\n- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) \r\n\r\n\r\n\r\n## JSON files importation\r\n\r\n\r\n\r\nThe JSON format is a commun format for same database and OpenLCA allows the exportation of database in this format (JSON-LD).\r\n\r\nCompare the the IPC protocol, the JSON importation require export from OpenLCA that add significantly more time than IPC connexion, but JSON zip file can be send to others users.\r\n\r\n\r\n\r\nThe load_openLCA_Json() function work similarly than load_openLCA_IPC but the path to the zip file containing all JSON file need to be specified (path_zip)\r\n\r\nTo create a all new brightway project you need to export from OpenLCA all the flows, the processes, the LCIA methods and properties (unit, flows properties and locations)\r\n\r\n\r\n\r\nOthers options are available in this function:\r\n\r\n- path_zip: string -> the complete path to your zip file or to the directory with all extrated folders. \r\n\r\n- project_name: string -> the name of the brightway project that will contain your openlca database\r\n\r\n- overwrite: boolean -> True to overwrite an existing brightway project with the same name\r\n\r\n- nonuser_db_name: string -> the name of the brightway database that will contain the nonuser database (processes that are not specified in the user_databases folders)\r\n\r\n- check_nonuser_exc: boolean -> if True the program will check if all nonuser processes' exchanges have correct connexion, especially regarding unit conversion\r\n\r\n- user_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related\r\n\r\n- excluded_folders: list -> a list of openLCA folders names that will not be imported\r\n\r\n- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) \r\n\r\n- selected_methods: list or all -> a list of LCIA methods in OpenLCA that will be imported. The default value is 'all' to import all methods present, an empty list not will import any method\r\n\r\n\r\n\r\n>load_openLCA_Json(path_zip=str, project_name=\"Open_imports\",overwrite=False, \r\n\r\n>                     nonuser_db_name = 'EcoInvent',check_nonuser_exc=False,\r\n\r\n>                     user_databases={},excluded_folders=[], exclude_S=False, selected_methods = all) \r\n\r\n\r\n\r\nexample to run function:\r\n\r\n> import openlca2bw\r\n\r\n>\r\n\r\n> my_dict = {'FirstDatabase': ['Folder1','Folder2'],'SecondDatabase': 'Folder3'}\r\n\r\n>\r\n\r\n> #after exporting json zip from OpenLCA\r\n\r\n>\r\n\r\n> load_openLCA_Json(path_zip=r'C:\\user\\userprofile\\document\\olcaJSON.zip',user_databases=my_dict)\r\n\r\n\r\n\r\nThe update_openLCA_Json() function only import specified elements to an existing brightway project.\r\n\r\nThe update_databases dictionnary allows the user to specified the brightway databases that will be replaced.\r\n\r\nIt seems complicated to only import modification, so the program delete the previous database and load the new one with specified openLCA folders.\r\n\r\nWith this function no need to export the all database from OpenLCA, only modified element con be exported\r\n\r\n\r\n\r\n> update_openLCA_Json(path_zip=str, project_name=\"Open_imports\",update_biosphere=False,update_methods=[],\r\n\r\n>                     update_databases={}, exclude_S=False)\r\n\r\n\r\n\r\n- path_zip: string -> the complete path to your zip file\r\n\r\n- project_name: string -> the name of the brightway project that will be updated\r\n\r\n- update_biosphere: boolean -> if True the program import all elementary flows and replace the existing 'biosphere3' database in brightway\r\n\r\n- update_methods: list -> indicate in a list LCIA methods to be imported or updated. To import no method specify an empty list.The program will import LCIA methods and write the new methods or replace old ones if some differents are presents\r\n\r\n- update_databases: dictionnary -> a dictionnary with keys representing the brightway databases names and the values for each key representing the list of openLCA folders related (see previous user_databases format)\r\n\r\n- exclude_S: boolean -> if True the program will not import nonuser processes that are System process (LCI) if a corresponding Unit process is available, the importation of a full System process databse is long (3 hours for EcoInvent) \r\n\r\n\r\n\r\n\r\n\r\nOpenLCA has many specificities and this package may not handle all of them.\r\n\r\nFor instance, a technological exchange without a specified provider that can be satisfy by several activities is deleted frmo the activity (a single provider is retrieve). LCA model in OpenLCA need to be completly defined. \r\n\r\n\r\n\r\n                 \r\n\r\nOpenLCA database has many exceptions and depending on your database some errors may araise. Feel free to share issues and potential correction.\r\n\r\n\r\n\r\nNext steps for this package :\r\n\r\n- Apply allocation factors when importing\r\n\r\n- Write processes and data from brightway2 to OpenLCA\r\n\r\n- Errors and exceptions corrections\r\n\r\n- Computing and coding optimization\r\n\r\n",
    "bugtrack_url": null,
    "license": "BSD-3",
    "summary": "A Python package to extract and write an LCA database from OpenLCA to Brightway2",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/cyrillefrancois/openlca2bw"
    },
    "split_keywords": [
        "open life-cycle analysis",
        "openlca",
        "brightway"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "295c6b5b48b5be80b7d74440492f54a3c713b10604249797c1779392fb7aa32a",
                "md5": "4ab71ab720de72608a2089f548fd6edb",
                "sha256": "3e2430f63c0f6ff7e5e1f9c948a41597f77c73a5c953d3fadf0a0dbc9637799b"
            },
            "downloads": -1,
            "filename": "openlca2bw-1.0.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4ab71ab720de72608a2089f548fd6edb",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 29857,
            "upload_time": "2023-11-09T12:35:57",
            "upload_time_iso_8601": "2023-11-09T12:35:57.357303Z",
            "url": "https://files.pythonhosted.org/packages/29/5c/6b5b48b5be80b7d74440492f54a3c713b10604249797c1779392fb7aa32a/openlca2bw-1.0.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b9d644d400cd6c3fad34801f6f30aab559927a292151893d689dad060c389e47",
                "md5": "ef11cb5c75c34ec8dc617a116310ee91",
                "sha256": "16607c4ac833d3dd838e1e6c39691ce360ea5fa1e13d3e486a10c62415a139c7"
            },
            "downloads": -1,
            "filename": "openlca2bw-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef11cb5c75c34ec8dc617a116310ee91",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 89789,
            "upload_time": "2023-11-09T12:35:59",
            "upload_time_iso_8601": "2023-11-09T12:35:59.221834Z",
            "url": "https://files.pythonhosted.org/packages/b9/d6/44d400cd6c3fad34801f6f30aab559927a292151893d689dad060c389e47/openlca2bw-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-09 12:35:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cyrillefrancois",
    "github_project": "openlca2bw",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "openlca2bw"
}
        
Elapsed time: 0.13734s