Metadata-Version: 2.1
Name: dynamic_characterization
Version: 0.0.4
Summary: Collection of dynamic characterization functions for life cycle inventories with temporal information
Author-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
Maintainer-email: Timo Diepers <timo.diepers@ltt.rwth-aachen.de>
Project-URL: source, https://github.com/TimoDiepers/dynamic_characterization
Project-URL: homepage, https://github.com/TimoDiepers/dynamic_characterization
Project-URL: tracker, https://github.com/TimoDiepers/dynamic_characterization/issues
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: bw2data
Provides-Extra: dev
Requires-Dist: build ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pylint ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest-randomly ; extra == 'dev'
Requires-Dist: setuptools ; extra == 'dev'
Provides-Extra: testing
Requires-Dist: dynamic-characterization ; extra == 'testing'
Requires-Dist: pytest ; extra == 'testing'
Requires-Dist: pytest-cov ; extra == 'testing'
Requires-Dist: python-coveralls ; extra == 'testing'

# dynamic_characterization

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

This is a collection of dynamic characterization functions for life cycle inventories with temporal information. 

Here's an overview of what is currently included:

| impact category | metric | covered emissions | source
|-------|----------|----------|--|
| climate change | radiative forcing | CO2, CH4 |[bw_temporalis](https://github.com/brightway-lca/bw_temporalis/tree/main)|
| climate change | radiative forcing | 247 GHGs from [IPCC AR6 Ch.7](https://www.ipcc.ch/report/ar6/wg1/chapter/chapter-7/) |[bw_timex](https://github.com/brightway-lca/bw_timex/tree/main)|

## What do dynamic characterization functions do?

The functions are meant to work with a common input format of the dynamic inventory, collected in a pandas DataFrame that looks like this:

| date | amount | flow | activity |
|-------|-------|------|----------|
| 101   | 33    | 1    | 2        |
| 312   | 21    | 4    | 2        |

Each function takes one row of this dynamic inventory dataframe (i.e. one emission at one point in time) and transform it according to some metric. The output generated by applying a very simple function to both rows of the input dataframe could look like:

| date | amount | flow | activity |
|------|--------|------|----------|
| 101  | 33     | 1    | 2        |
| 102  | 31     | 1    | 2        |
| 103  | 31     | 1    | 2        |
| 312  | 21     | 4    | 2        |
| 313  | 20     | 4    | 2        |
| 314  | 19     | 4    | 2        |

## What do dynamic characterization functions look like?

Here's an example of what such a function could look like:

```python
def characterize_something(series, period: int = 100, cumulative=False) -> pd.DataFrame:
    date_beginning: np.datetime64 = series.date.to_numpy()
    dates_characterized: np.ndarray = date_beginning + np.arange(
        start=0, stop=period, dtype="timedelta64[Y]"
    ).astype("timedelta64[s]")

    # let's assume some simple decay function
    decay_multipliers: list = np.array(
        [
            1.234 * (1 - np.exp(-year / 56.789))
            for year in range(period)
        ]
    )

    forcing = np.array(series.amount * decay_multipliers, dtype="float64")

    if not cumulative:
        forcing = np.diff(forcing, prepend=0)

    return pd.DataFrame(
        {
            "date": np.array(dates_characterized, dtype="datetime64[s]"),
            "amount": forcing,
            "flow": series.flow,
            "activity": series.activity,
        }
    )
````

## Installation

You can install `dynamic_characterization` via [pip] from [PyPI]:

```console
$ pip install dynamic_characterization
```

Alternatively, you can also use conda:

```console
$ conda install -c diepers dynamic_characterization
```

## Contributing

Contributions are very welcome.
To learn more, see the [Contributor Guide][Contributor Guide].

## License

Distributed under the terms of the [BSD 3 Clause license][License],
_dynamic_characterization_ is free and open source software.

## Issues

If you encounter any problems,
please [file an issue][Issue Tracker] along with a detailed description.

## Support

If you have any questions or need help, do not hesitate to contact Timo Diepers ([timo.diepers@ltt.rwth-aachen.de](mailto:timo.diepers@ltt.rwth-aachen.de))

<!-- github-only -->

[command-line reference]: https://dynamic-characterization.readthedocs.io/en/latest/usage.html
[License]: https://github.com/TimoDiepers/dynamic_characterization/blob/main/LICENSE
[Contributor Guide]: https://github.com/TimoDiepers/dynamic_characterization/blob/main/CONTRIBUTING.md
[Issue Tracker]: https://github.com/TimoDiepers/dynamic_characterization/issues
