Skip to content

Commit

Permalink
Added doc for interpolated activities
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaeljolivet committed Apr 23, 2024
1 parent 9696972 commit e128d89
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ lead by [ADEME](https://www.ademe.fr/).

It is distributed under the [BSD License](./LICENSE)

# Mailing list

Please register to this dedicated mailing list to discuss the evolutions of this library and be informed of future releases :

[[email protected]](https://groupes.minesparis.psl.eu/wws/subscribe/lca_algebraic)


# Documentation

Full documentation and example notebooks are [hosted on **readthedocs**](https://lca-algebraic.readthedocs.io/)
6 changes: 6 additions & 0 deletions doc/source/api/activities.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ brightway.

```{eval-rst}
.. autofunction:: lca_algebraic.printAct
```

## interpolate_activities()

```{eval-rst}
.. autofunction:: lca_algebraic.interpolate_activities
```
52 changes: 39 additions & 13 deletions lca_algebraic/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,45 @@ def interpolate_activities(
add_zero=False,
):
"""
Creates a linear virtual activity being a linear interpolation between several activities,
based on the values of a given parameter.
This is useful to produce a continuous parametrized activity based on the scale of the system,
given that you have dicrete activities coresponding to
discrete values of the parameter.
:param db_name: Name of user DB (string)
:param act_name: Name of the new activity
:param param: Parameter to use [ParamDef]
:param act_per_value : Dictionnary of value => activitiy [Dict]
:param add_zero: If True add the "Zero" point to the data. Usefull for linear interoplation of a single activity / point
:return: the new activity
Creates a virtual activity being a linear interpolation between several activities,
based on the value of a parameter.
The result activity is a piecewize linear function of input activities.
This is useful to produce a continuous parametrized activity based on the scale of the system,
Given that you have discrete activities corresponding to discrete values of the parameter.
Parameters
----------
db_name:
Name of user DB (string)
act_name:
Name of the new activity
param:
Parameter controlling the interpolation
act_per_value:
Dictionnary of value => activitiy [Dict]
add_zero:
If True add the "Zero" point to the data.
Useful for linear interpolation of a single activity / point
Returns
-------
The new activity
Examples
--------
>>> interpolated_inverter = interpolate_activities(
>>> db_name=USER_DB,
>>> act_name="interpolated_inverter",
>>> param=power_param, #power parameter, in kW
>>> act_per_value={ # Those are activities found in the background database
>>> .5: inverter_500W,
>>> 2: inverter_2KW,
>>> 50:inverter_50KW,
>>> 100:inverter_100KW},
>>> add_zero=True):
"""

# Add "Zero" to the list
Expand Down

0 comments on commit e128d89

Please sign in to comment.