brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 40 forks source link

Reparametrize lognormals for ecospold2 imports #213

Closed Loisel closed 11 months ago

Loisel commented 11 months ago

By the definition of the ecospold2 format, the mean of a lognormal distribution of an exchange is not equal to the amount specified for that exchange, see issue https://github.com/brightway-lca/brightway2-calc/issues/76.

This PR adds a strategy which sets loc for lognormal distributions on imported databases such that the expected value (mean) of the resulting distribution is equal to the (static) amount specified for that exchange. More precisely,

$$ \mu = \log a - \frac {\sigma^2} 2 $$

where $a$ is the (static) amount and $\sigma$ is scale, i.e., the standard deviation of the underlying normal distribution.

The strategy is not applied by default but only if a specific flag (reparametrize_lognormals=True) is provided when initializing an instance of SingleOutputEcospold2Importer.