T-reX ===== .. py:module:: T-reX Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/T-reX/CustomConfig/index /autoapi/T-reX/ExchangeEditor/index /autoapi/T-reX/ExplodeDatabase/index /autoapi/T-reX/FutureScenarios/index /autoapi/T-reX/MakeCustomDatabase/index /autoapi/T-reX/MethodEditor/index /autoapi/T-reX/SearchMaterial/index /autoapi/T-reX/SearchWaste/index /autoapi/T-reX/VerifyDatabase/index /autoapi/T-reX/config/index /autoapi/T-reX/config_backup/index /autoapi/T-reX/main/index Functions --------- .. autoapisummary:: T-reX.run T-reX.config_setup T-reX.config_reload T-reX.config_reset T-reX.ExchangeEditor T-reX.ExplodeDatabase T-reX.MakeFutureScenarios T-reX.dbWriteExcel T-reX.dbExcel2BW T-reX.AddMethods T-reX.DeleteMethods T-reX.CheckMethods T-reX.SearchMaterial T-reX.SearchWaste T-reX.VerifyDatabase Package Contents ---------------- .. py:function:: run() Main function serving as the wrapper for the T-reX tool. This function coordinates the various components of the tool, including: creating future scenario databases, setting up and processing each database for waste and material footprinting, and combining results into a custom database. adding LCIA methods to the project for each of the waste/material flows. The function supports various modes of operation based on the settings in `config/user_settings.py`. Specifications for material and waste searches can be customised in `queries_materials`. .. py:function:: config_setup() Copies the config files to the current working directory and adds the config directory to sys.path args: None returns: None .. py:function:: config_reload() Copies the config files back to the package directory. The user will need to restart the python session to reload the T-reX module with the updated configuration files args: None returns: None .. py:function:: config_reset() Reset config to defaults that are stored in the root directory of the package args: None returns: None .. py:function:: ExchangeEditor(project_T_reX, db_name, db_T_reX_name) Append relevant exchanges from `db_T_reX` to each activity in `db_name` identified by `WasteAndMaterialSearch()`. This function modifies the specified project's database by appending exchanges from the `db_T_reX` to activities identified by `WasteAndMaterialSearch()`. The appended exchanges mirror the quantity and unit of the original technosphere waste and material exchange. :param str project_T_reX: Name of the Brightway2 project to be modified. :param str db_name: Name of the database within the project where activities and exchanges are stored. :param str db_T_reX_name: Name of the database containing waste and material exchange details. :returns: None. Modifies the given Brightway2 project by appending exchanges and logs statistics about the added exchanges. :rtype: None :raises Exception: If any specified process or exchange is not found in the database. .. py:function:: ExplodeDatabase(db_name) Explode a Brightway2 database into a single-level list of all exchanges using wurst. :param str db_name: Name of the Brightway2 database to be exploded. :returns: None The function saves the output to a file and logs the operation, but does not return any value. :rtype: None .. py:function:: MakeFutureScenarios() Main function to run the FutureScenarios module. Only activated if `use_premise` is set to True in `user_settings.py`. Calls the `FutureScenarios` function to create new databases based on the list of scenarios and settings specified in `user_settings.py`. .. py:function:: dbWriteExcel() Create an xlsx file representing a custom Brightway2 database. This function generates an Excel file which represents a custom database for Brightway2, using predefined directory and database settings. :return: Path to the generated xlsx file. .. py:function:: dbExcel2BW() Import the custom database (created by dbWriteExcel) into Brightway2. This function imports a custom Brightway2 database from an Excel file into the Brightway2 software, making it available for further environmental impact analysis. :return: None .. py:function:: AddMethods() Add methods to the specified project based on entries in the custom biosphere database. :param project_T_reX: Name of the project. :param db_T_reX_name: Name of the database. .. py:function:: DeleteMethods() Delete methods associated with the "WasteAndMaterial Footprint" in the specified project. :param project_T_reX: Name of the project. .. py:function:: CheckMethods() Check methods associated with the "WasteAndMaterial Footprint" in the specified project. :param project_T_reX: Name of the project. .. py:function:: SearchMaterial(db_name, project_T_reX=project_T_reX) Search for materials in a specified database and extract related information. This function takes a database name as input, sets the project to the respective database, and looks for activities involving a predefined list of materials. It extracts relevant details of these activities, such as ISIC and CPC classifications, and saves the details to a CSV file. It also extracts related material exchanges and saves them to another CSV file. :param db_name: The name of the database to search in. :param project_T_reX: The Brightway2 project to set as current for the search. :return: None :raises Exception: If there is any error in reading the materials list from the file. .. py:function:: SearchWaste(db_name, dir_searchwaste_results=dir_searchwaste_results) Load data from '_exploded.pickle', run search queries, and produce result CSVs and log entries. This function processes waste-related data from a given database and runs predefined queries to identify relevant waste exchanges. The results are saved in CSV files and log entries are created for each search operation. :param str db_name: The database name to be used in the search operation. Note: The queries are defined in `config/queries_waste.py`. .. py:function:: VerifyDatabase(project_name, database_name, check_material=True, check_waste=True, log=True) Verifies a database within a given project in Brightway2 by calculating LCA scores for random activities using selected methods. This function assesses the integrity and validity of a specified database within a Brightway2 project. It performs LCA calculations on random activities using Waste Footprint and Material Demand Footprint methods, and logs the results. :param str project_name: The name of the Brightway2 project. :param str database_name: The name of the database to be verified. :param bool check_material: If True, checks for Material Demand Footprint methods. :param bool check_waste: If True, checks for Waste Footprint methods. :param bool log: If True, logs the results. :return: Exit code (0 for success, 1 for failure).