Skip to content

Commit

Permalink
timex_lca -> bw_timex
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoDiepers committed Jun 7, 2024
1 parent 4a2f3bc commit 71fb32d
Show file tree
Hide file tree
Showing 38 changed files with 371 additions and 377 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI

on:
push:
branches: [main, develop]
branches: [main, dev]
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

We welcome contributions! If you have any questions, [open a discussion](https://github.com/TimoDiepers/timex/discussions) or [get in touch directly with the `timex_lca` developers ](mailto:[email protected])
We welcome contributions! If you have any questions, [open a discussion](https://github.com/TimoDiepers/timex/discussions) or [get in touch directly with the `bw_timex` developers ](mailto:[email protected])


## Contributing to the code, examples or documentation
Expand All @@ -12,10 +12,10 @@ If you want to contribute to the development our code with a new feature, want t
Something is not working as expected? You have two options:

### 🥈 Report an error
Please open a new issue in the `timex_lca` [repository](https://github.com/TimoDiepers/timex/issues), describing the error and where you found it.
A member of the timex_lca developer community will then take care of the issue, but it may take some time for your issue to be resolved.
Please open a new issue in the `bw_timex` [repository](https://github.com/TimoDiepers/timex/issues), describing the error and where you found it.
A member of the bw_timex developer community will then take care of the issue, but it may take some time for your issue to be resolved.

### 🥇 Fix an error yourself
If you have a solution to the error, you can [create a fork](https://github.com/TimoDiepers/timex/forks) of the `timex_lca` repository, make your changes and [create a pull request](https://github.com/TimoDiepers/timex/pulls). The developers will assess the changes and be eternally grateful!
If you have a solution to the error, you can [create a fork](https://github.com/TimoDiepers/timex/forks) of the `bw_timex` repository, make your changes and [create a pull request](https://github.com/TimoDiepers/timex/pulls). The developers will assess the changes and be eternally grateful!

[code of conduct]: codeofconduct
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<h1>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/_static/logo_dark_nomargins.svg" height="50">
<img alt="timex_lca logo" src="docs/_static/logo_light_nomargins.svg" height="50">
<source media="(prefers-color-scheme: dark)" srcset="docs/_static/bw_timex_dark_nomargins.svg" height="50">
<img alt="bw_timex logo" src="docs/_static/bw_timex_light_nomargins.svg" height="50">
</picture>
</h1>

[![Read the Docs](https://img.shields.io/readthedocs/timex?label=documentation)](https://timex.readthedocs.io/en/latest/)
[![PyPI - Version](https://img.shields.io/pypi/v/timex-lca?color=%2300549f)](https://pypi.org/project/timex-lca/)
[![Conda Version](https://img.shields.io/conda/v/diepers/timex_lca?label=conda)](https://anaconda.org/diepers/timex_lca)
![Conda - License](https://img.shields.io/conda/l/diepers/timex_lca)
[![Conda Version](https://img.shields.io/conda/v/diepers/bw_timex?label=conda)](https://anaconda.org/diepers/bw_timex)
![Conda - License](https://img.shields.io/conda/l/diepers/bw_timex)

> ℹ️ _This package is still under development and some functionalities may change in the future._
This is a python package for time-explicit Life Cycle Assessment that helps you assess the environmental impacts of products and processes over time. `timex_lca` builds on top of the [Brightway LCA framework](https://docs.brightway.dev/en/latest).
This is a python package for time-explicit Life Cycle Assessment that helps you assess the environmental impacts of products and processes over time. `bw_timex` builds on top of the [Brightway LCA framework](https://docs.brightway.dev/en/latest).

## Features:
This package enables you to account for:
- **Timing of processes** throughout the supply chain (e.g., end-of-life treatment occurs 20 years after construction)
- **Variable** and/or **evolving** supply chains & technologies (e.g., increasing shares of renewable electricity in the future)
- **Timing of emissions** (by applying dynamic characterization functions)

You can define temporal distributions for process and emission exchanges, which are then *automatically* propagated through the supply chain and mapped to corresponding time-explicit databases. The resulting time-explicit LCI reflects the current technology status within the production system at the actual time of each process. Also, `timex_lca` keeps track of the timing of emissions which means that you can apply dynamic characterization functions.
You can define temporal distributions for process and emission exchanges, which are then *automatically* propagated through the supply chain and mapped to corresponding time-explicit databases. The resulting time-explicit LCI reflects the current technology status within the production system at the actual time of each process. Also, `bw_timex` keeps track of the timing of emissions which means that you can apply dynamic characterization functions.

## Use cases:
`timex_lca` is ideal for cases with:
`bw_timex` is ideal for cases with:
- **Variable** or strongly **evolving production systems**
- **Long-lived** products
- **Biogenic** carbon
Expand Down
4 changes: 2 additions & 2 deletions timex_lca/__init__.py → bw_timex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .timex_lca import TimexLCA
from .bw_timex import TimexLCA
from .matrix_modifier import MatrixModifier
from .edge_extractor import EdgeExtractor
from .timeline_builder import TimelineBuilder
from .dynamic_biosphere_builder import DynamicBiosphereBuilder
from .dynamic_characterization import DynamicCharacterization

__version__ = '0.1.2'
__version__ = '0.1.3'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(

if not characterization_function_dict:
warnings.warn(
f"No custom dynamic characterization functions provided. Using default dynamic characterization functions based on IPCC AR6 meant to work with biosphere3 flows. The flows that are characterized are based on the selection of the initially chosen impact category: {self.method}. You can look up the mapping in the timex_lca.dynamic_characterizer.characterization_function_dict."
f"No custom dynamic characterization functions provided. Using default dynamic characterization functions based on IPCC AR6 meant to work with biosphere3 flows. The flows that are characterized are based on the selection of the initially chosen impact category: {self.method}. You can look up the mapping in the bw_timex.dynamic_characterizer.characterization_function_dict."
)
self.add_default_characterization_functions()

Expand Down Expand Up @@ -121,7 +121,7 @@ def characterize_dynamic_inventory(

if metric == "GWP":
warnings.warn(
"Using timex_lca's default CO2 characterization function for GWP reference."
"Using bw_timex's default CO2 characterization function for GWP reference."
)

time_res_dict = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions timex_lca/timex_lca.py → bw_timex/timex_lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from datetime import datetime
from typing import Optional, Callable
from bw2data import ( # for prepare_timex_lca_inputs
from bw2data import ( # for prepare_bw_timex_inputs
Database,
Method,
Normalization,
Expand Down Expand Up @@ -43,7 +43,7 @@ class TimexLCA:
resulting emissions. As such, it combines prospective and dynamic LCA approaches.
TimexLCA first calculates a static LCA, which informs a priority-first graph traversal. From the graph traversal,
temporal relationships between exchanges and processes are derived. Based on the timing of the processes, timex_lca
temporal relationships between exchanges and processes are derived. Based on the timing of the processes, bw_timex
matches the processes at the intersection between foreground and background to the best available background
databases. This temporal relinking is achieved by using datapackages to add new time-specific processes. The new
processes and their exchanges to other technosphere processes or biosphere flows extent the technopshere and
Expand All @@ -62,13 +62,13 @@ class TimexLCA:
>>> method = ("some_method_family", "some_category", "some_method") #replace here with your method
>>> database_date_dict = {'my_database': datetime.strptime("2020", "%Y"),
'my_foreground_database':'dynamic'} #replace here with your database dates
>>> timex_lca = TimexLCA(demand, method, database_date_dict)
>>> timex_lca.build_timeline() # you can pass many optional arguments here, also for the graph traversal
>>> timex_lca.lci()
>>> timex_lca.static_lcia()
>>> timex_lca.static_score
>>> timex_lca.dynamic_lcia(metric="radiative_forcing") # different metrics can be used, e.g. "GWP", "radiative_forcing"
>>> timex_lca.dynamic_score
>>> bw_timex = TimexLCA(demand, method, database_date_dict)
>>> bw_timex.build_timeline() # you can pass many optional arguments here, also for the graph traversal
>>> bw_timex.lci()
>>> bw_timex.static_lcia()
>>> bw_timex.static_score
>>> bw_timex.dynamic_lcia(metric="radiative_forcing") # different metrics can be used, e.g. "GWP", "radiative_forcing"
>>> bw_timex.dynamic_score
""" """"""

Expand Down Expand Up @@ -175,7 +175,7 @@ def build_timeline(
See also
--------
timex_lca.timeline_builder.TimelineBuilder: Class that builds the timeline.
bw_timex.timeline_builder.TimelineBuilder: Class that builds the timeline.
"""
if not edge_filter_function:
Expand Down Expand Up @@ -257,7 +257,7 @@ def lci(self, build_dynamic_biosphere: Optional[bool] = True) -> None:
self.build_datapackage()
) # this contains the matrix modifications

self.fu, self.data_objs, self.remapping = self.prepare_timex_lca_inputs(
self.fu, self.data_objs, self.remapping = self.prepare_bw_timex_inputs(
demand=self.demand,
method=self.method,
demand_timing_dict=self.demand_timing_dict,
Expand Down Expand Up @@ -341,7 +341,7 @@ def dynamic_lcia(
See also
--------
timex_lca.dynamic_characterization.DynamicCharacterization: Class that characterizes the dynamic inventory.
bw_timex.dynamic_characterization.DynamicCharacterization: Class that characterizes the dynamic inventory.
"""

if not hasattr(self, "dynamic_inventory"):
Expand Down Expand Up @@ -397,7 +397,7 @@ def build_datapackage(self) -> list:
See also
--------
timex_lca.matrix_modifier.MatrixModifier: Class that handles the technosphere and biosphere matrix modifications.
bw_timex.matrix_modifier.MatrixModifier: Class that handles the technosphere and biosphere matrix modifications.
"""
# mapping of the demand id to demand time
self.demand_timing_dict = self.create_demand_timing_dict()
Expand Down Expand Up @@ -432,7 +432,7 @@ class and then multiplying it with the dynamic supply array. The dynamic invento
See also
--------
timex_lca.dynamic_biosphere_builder.DynamicBiosphereBuilder: Class for creating the dynamic biosphere matrix and inventory.
bw_timex.dynamic_biosphere_builder.DynamicBiosphereBuilder: Class for creating the dynamic biosphere matrix and inventory.
"""

if not hasattr(self, "lca"):
Expand Down Expand Up @@ -654,7 +654,7 @@ def prepare_static_lca_inputs(

return indexed_demand, data_objs, remapping_dicts

def prepare_timex_lca_inputs(
def prepare_bw_timex_inputs(
self,
demand=None,
method=None,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion dev/calculate_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"data = pd.read_csv('/Users/timodiepers/Documents/Coding/timex/timex_lca/data/hodnebrog20.csv', usecols=[\"CASRN\", \"Molar mass\", \"Lifetime (yr)\", \"RE (W m-2 ppb-1)\"]).dropna()"
"data = pd.read_csv('/Users/timodiepers/Documents/Coding/timex/bw_timex/data/hodnebrog20.csv', usecols=[\"CASRN\", \"Molar mass\", \"Lifetime (yr)\", \"RE (W m-2 ppb-1)\"]).dropna()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion dev/old_tests/old_t_bioflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import bw2data as bd
import bw2calc as bc
import numpy as np
from timex_lca import MedusaLCA
from bw_timex import MedusaLCA
from tests.databases import db_abc_loopA_with_biosphere_tds_CO2_and_CH4
from datetime import datetime

Expand Down
Loading

0 comments on commit 71fb32d

Please sign in to comment.