T-reX

Subpackages

Submodules

Package Contents

Functions

run()

Main function serving as the wrapper for the T-reX tool.

config_setup()

Copies the config files to the current working directory and adds the config directory to sys.path

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

config_reset()

Reset config to defaults that are stored in the root directory of the package

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().

ExplodeDatabase

ExplodeDatabase Module

MakeFutureScenarios()

Main function to run the FutureScenarios module.

dbWriteExcel()

Create an xlsx file representing a custom Brightway2 database.

dbExcel2BW()

Import the custom database (created by dbWriteExcel) into Brightway2.

AddMethods()

Add methods to the specified project based on entries in the custom biosphere database.

DeleteMethods()

Delete methods associated with the "WasteAndMaterial Footprint" in the specified project.

CheckMethods()

Check methods associated with the "WasteAndMaterial Footprint" in the specified project.

SearchMaterial(db_name[, project_T_reX])

Search for materials in a specified database and extract related information.

SearchWaste(db_name[, dir_searchwaste_results])

Load data from '<db name>_exploded.pickle', run search queries, and produce

VerifyDatabase(project_name, database_name[, ...])

Verifies a database within a given project in Brightway2 by calculating LCA scores

T-reX.run()[source]

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.

T-reX.config_setup()[source]

Copies the config files to the current working directory and adds the config directory to sys.path args: None returns: None

T-reX.config_reload()[source]

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

T-reX.config_reset()[source]

Reset config to defaults that are stored in the root directory of the package

args: None returns: None

T-reX.ExchangeEditor(project_T_reX, db_name, db_T_reX_name)[source]

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.

Parameters:
  • project_T_reX (str) – Name of the Brightway2 project to be modified.

  • db_name (str) – Name of the database within the project where activities and exchanges are stored.

  • db_T_reX_name (str) – 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.

Return type:

None

Raises:

Exception – If any specified process or exchange is not found in the database.

T-reX.ExplodeDatabase(db_name)[source]

Explode a Brightway2 database into a single-level list of all exchanges using wurst.

Parameters:

db_name (str) – 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.

Return type:

None

T-reX.MakeFutureScenarios()[source]

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.

T-reX.dbWriteExcel()[source]

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.

Returns:

Path to the generated xlsx file.

T-reX.dbExcel2BW()[source]

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.

Returns:

None

T-reX.AddMethods()[source]

Add methods to the specified project based on entries in the custom biosphere database.

Parameters:
  • project_T_reX – Name of the project.

  • db_T_reX_name – Name of the database.

T-reX.DeleteMethods()[source]

Delete methods associated with the “WasteAndMaterial Footprint” in the specified project.

Parameters:

project_T_reX – Name of the project.

T-reX.CheckMethods()[source]

Check methods associated with the “WasteAndMaterial Footprint” in the specified project.

Parameters:

project_T_reX – Name of the project.

T-reX.SearchMaterial(db_name, project_T_reX=project_T_reX)[source]

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.

Parameters:
  • db_name – The name of the database to search in.

  • project_T_reX – The Brightway2 project to set as current for the search.

Returns:

None

Raises:

Exception – If there is any error in reading the materials list from the file.

T-reX.SearchWaste(db_name, dir_searchwaste_results=dir_searchwaste_results)[source]

Load data from ‘<db name>_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.

Parameters:

db_name (str) – The database name to be used in the search operation.

Note: The queries are defined in config/queries_waste.py.

T-reX.VerifyDatabase(project_name, database_name, check_material=True, check_waste=True, log=True)[source]

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.

Parameters:
  • project_name (str) – The name of the Brightway2 project.

  • database_name (str) – The name of the database to be verified.

  • check_material (bool) – If True, checks for Material Demand Footprint methods.

  • check_waste (bool) – If True, checks for Waste Footprint methods.

  • log (bool) – If True, logs the results.

Returns:

Exit code (0 for success, 1 for failure).