Skip to content

Commit

Permalink
Merge branch 'master' into sync_food
Browse files Browse the repository at this point in the history
  • Loading branch information
paulboosz committed Sep 26, 2024
2 parents 5d82af3 + 7992844 commit 80160d6
Show file tree
Hide file tree
Showing 20 changed files with 428 additions and 562 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## [2.3.0](https://github.com/MTES-MCT/ecobalyse/compare/v2.2.0...v2.3.0) (2024-09-25)


### Features

* add link to changelog in app footer. ([#748](https://github.com/MTES-MCT/ecobalyse/issues/748)) ([efe88f5](https://github.com/MTES-MCT/ecobalyse/commit/efe88f57d4f61e74e84f62c5334a89d36fd767ee))
* airTransportRatio should depend on durability ([#757](https://github.com/MTES-MCT/ecobalyse/issues/757)) ([a0761d1](https://github.com/MTES-MCT/ecobalyse/commit/a0761d169469fddff7b9158f21de26d96a98ae0f))
* displayName in the textile explorer, reordered columns ([#737](https://github.com/MTES-MCT/ecobalyse/issues/737)) ([65d0ed5](https://github.com/MTES-MCT/ecobalyse/commit/65d0ed547566c193c5617147a35604e26b0bbe6d))


### Bug Fixes

* **api:** handle ingredient plane transport in food POST api. ([#769](https://github.com/MTES-MCT/ecobalyse/issues/769)) ([62587e2](https://github.com/MTES-MCT/ecobalyse/commit/62587e23593e459d66726b2221932092393790e5))
* check db integrity after building it ([#753](https://github.com/MTES-MCT/ecobalyse/issues/753)) ([5b41ef6](https://github.com/MTES-MCT/ecobalyse/commit/5b41ef6a6e1d4e799ed2abe7f21a321a87f9ae83))
* check uniqueness of JSON db primary keys at build time. ([#766](https://github.com/MTES-MCT/ecobalyse/issues/766)) ([0927954](https://github.com/MTES-MCT/ecobalyse/commit/0927954dfe472557f0e7c2e5e4aa24d1ce8572c2))
* decode and validate all optionals. ([#764](https://github.com/MTES-MCT/ecobalyse/issues/764)) ([87a7c6a](https://github.com/MTES-MCT/ecobalyse/commit/87a7c6af3e6edc12c2daa36192ad7f18fdefc444))
* encode physicalDurability parameter. ([#751](https://github.com/MTES-MCT/ecobalyse/issues/751)) ([f6750b8](https://github.com/MTES-MCT/ecobalyse/commit/f6750b8aea6dc0a4500a23465bfdbc0f0b627743))
* fix github CI python build setup. ([#762](https://github.com/MTES-MCT/ecobalyse/issues/762)) ([ea2cd9f](https://github.com/MTES-MCT/ecobalyse/commit/ea2cd9ff566129081ccf37caef25377717933c9d))
* fixed brightway explorer notebook error (wrong key) ([#745](https://github.com/MTES-MCT/ecobalyse/issues/745)) ([bc436c2](https://github.com/MTES-MCT/ecobalyse/commit/bc436c2d1520efb9de269cdadccf6587d1904468))
* in brightway explorer: improve display of compartment categories, if any ([#754](https://github.com/MTES-MCT/ecobalyse/issues/754)) ([757d5a6](https://github.com/MTES-MCT/ecobalyse/commit/757d5a6b50363995011e23bd5719adedb44d296f))
* stricter validation of POST json body passed to the textile API. ([#760](https://github.com/MTES-MCT/ecobalyse/issues/760)) ([a85bd8a](https://github.com/MTES-MCT/ecobalyse/commit/a85bd8aa506ce87b9b1310b6a4a933a591ce442e))
* **textile:** distribution step had no inland road transports added. ([#761](https://github.com/MTES-MCT/ecobalyse/issues/761)) ([d789d7d](https://github.com/MTES-MCT/ecobalyse/commit/d789d7d63a3dede6a4c2b07d43f6f43b9328a519))
* Update export outside of EU probability. ([#765](https://github.com/MTES-MCT/ecobalyse/issues/765)) ([c3fd9f2](https://github.com/MTES-MCT/ecobalyse/commit/c3fd9f2d5d0cc01232b31f9aa1ef657b33796292))

## [2.2.0](https://github.com/MTES-MCT/ecobalyse/compare/v2.1.1...v2.2.0) (2024-09-12)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ecobalyse",
"version": "2.2.0",
"version": "2.3.0",
"description": "Accélérer l'affichage environnemental de la filière textile française",
"author": "Ecobalyse <[email protected]>",
"license": "MIT",
Expand Down
44 changes: 22 additions & 22 deletions public/data/textile/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.270519,
"waste": 0.21292,
"alias": null
},
{
Expand Down Expand Up @@ -756,7 +756,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.270519,
"waste": 0.21292,
"alias": null
},
{
Expand Down Expand Up @@ -794,7 +794,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.270519,
"waste": 0.21292,
"alias": null
},
{
Expand Down Expand Up @@ -832,7 +832,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0319569,
"waste": 0.03097,
"alias": null
},
{
Expand Down Expand Up @@ -870,7 +870,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0319569,
"waste": 0.03097,
"alias": null
},
{
Expand Down Expand Up @@ -908,7 +908,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0319569,
"waste": 0.03097,
"alias": null
},
{
Expand Down Expand Up @@ -946,7 +946,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0319569,
"waste": 0.03097,
"alias": null
},
{
Expand Down Expand Up @@ -984,7 +984,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0765978,
"waste": 0.07115,
"alias": null
},
{
Expand Down Expand Up @@ -1022,7 +1022,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.538462,
"waste": 0.35,
"alias": null
},
{
Expand Down Expand Up @@ -1060,7 +1060,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.538462,
"waste": 0.35,
"alias": null
},
{
Expand Down Expand Up @@ -1098,7 +1098,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.201201,
"waste": 0.1675,
"alias": null
},
{
Expand Down Expand Up @@ -1136,7 +1136,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.105105,
"waste": 0.09511,
"alias": null
},
{
Expand Down Expand Up @@ -1174,7 +1174,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.221094,
"waste": 0.18106,
"alias": null
},
{
Expand Down Expand Up @@ -1212,7 +1212,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.0582011,
"waste": 0.055,
"alias": null
},
{
Expand Down Expand Up @@ -1250,7 +1250,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.631206,
"waste": 0.38696,
"alias": null
},
{
Expand Down Expand Up @@ -1288,7 +1288,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0.21716,
"waste": 0.17842,
"alias": null
},
{
Expand Down Expand Up @@ -1326,7 +1326,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 8.64,
"waste": 0.0576,
"waste": 0.05446,
"alias": "knitting-mix"
},
{
Expand Down Expand Up @@ -1364,7 +1364,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 6.06443,
"waste": 0.00502513,
"waste": 0.005,
"alias": "knitting-fully-fashioned"
},
{
Expand Down Expand Up @@ -1402,7 +1402,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 13.2112,
"waste": 0.00502513,
"waste": 0.005,
"alias": "knitting-seamless"
},
{
Expand Down Expand Up @@ -1440,7 +1440,7 @@
"heat_MJ": 0,
"elec_pppm": 0.0003145,
"elec_MJ": 0,
"waste": 0.0667,
"waste": 0.06253,
"alias": "weaving"
},
{
Expand Down Expand Up @@ -2694,7 +2694,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 4.194,
"waste": 0.0417,
"waste": 0.04003,
"alias": "knitting-straight"
},
{
Expand Down Expand Up @@ -2732,7 +2732,7 @@
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 4.25101,
"waste": 0.0351967,
"waste": 0.034,
"alias": "knitting-circular"
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Food/Ingredient.elm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ decodeIngredient processes =
|> Pipe.required "id" decodeId
|> Pipe.required "inedible_part" Split.decodeFloat
|> Pipe.required "name" Decode.string
|> Pipe.required "raw_to_cooked_ratio" (Unit.decodeRatio { percentage = False })
|> Pipe.required "raw_to_cooked_ratio" Unit.decodeRatio
|> Pipe.required "transport_cooling" decodeTransportCooling
|> Pipe.required "visible" Decode.bool

Expand Down
76 changes: 0 additions & 76 deletions src/Data/Impact.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module Data.Impact exposing
, parseTrigram
, per100grams
, perKg
, setEcotoxWeighting
, stepsColors
, stepsImpactsAsChartEntries
, sumEcosystemicImpacts
Expand Down Expand Up @@ -507,81 +506,6 @@ computeAggregatedScore definitions getter (Impacts impacts) =
|> Definition.foldl (\_ -> Quantity.plus) Quantity.zero


minEcotoxWeighting : Unit.Ratio
minEcotoxWeighting =
Unit.ratio 0


maxEcotoxWeighting : Unit.Ratio
maxEcotoxWeighting =
Unit.ratio 0.25


{-| Set the ecotoxicity weighting (EtfC) then redistribute other Ecoscore weightings
accordingly. The methodology and formulas are described in this card:
<https://www.notion.so/Rendre-param-trable-la-pond-ration-de-l-cotox-894d42e217c6448a883346203dff8db4>
FIXME: ensure the card contents are moved to the public documentation eventually
-}
setEcotoxWeighting : Unit.Ratio -> Definitions -> Definitions
setEcotoxWeighting (Unit.Ratio weighting) definitions =
let
defsToUpdate =
[ Definition.Acd
, Definition.Fru
, Definition.Fwe
, Definition.Ior
, Definition.Ldu
, Definition.Mru
, Definition.Ozd
, Definition.Pco
, Definition.Pma
, Definition.Swe
, Definition.Tre
, Definition.Wtu
]

cleanWeighting =
weighting
|> clamp (Unit.ratioToFloat minEcotoxWeighting) (Unit.ratioToFloat maxEcotoxWeighting)
in
definitions
-- Start with updating EtfC with the provided ratio
|> Definition.update Definition.EtfC
(\({ ecoscoreData } as definition) ->
{ definition
| ecoscoreData =
ecoscoreData
|> Maybe.map (\data -> { data | weighting = Unit.ratio cleanWeighting })
}
)
-- Then redistribute the other weightings accordingly
|> Definition.map
(\trg def ->
if List.member trg defsToUpdate then
let
pefWeighting =
def.pefData
|> Maybe.map .weighting
|> Maybe.withDefault (Unit.ratio 0)
|> Unit.ratioToFloat
in
{ def
| ecoscoreData =
def.ecoscoreData
|> Maybe.map
(\ecoscoreData ->
{ ecoscoreData
-- = (PEF weighting for this trigram) * (78.94% - custom weighting) / 73.05%
| weighting = Unit.ratio (pefWeighting * (0.7894 - cleanWeighting) / 0.7305)
}
)
}

else
def
)



-- Parser

Expand Down
5 changes: 3 additions & 2 deletions src/Data/Impact/Definition.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Data.Impact.Definition exposing
, update
)

import Data.Split as Split exposing (Split)
import Data.Unit as Unit
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Extra as DE
Expand All @@ -35,7 +36,7 @@ import Json.Encode as Encode
type alias AggregatedScoreData =
{ color : String
, normalization : Unit.Impact
, weighting : Unit.Ratio
, weighting : Split
}


Expand Down Expand Up @@ -554,7 +555,7 @@ decodeAggregatedScoreData =
Decode.map3 AggregatedScoreData
(Decode.field "color" Decode.string)
(Decode.field "normalization" Unit.decodeImpact)
(Decode.field "weighting" (Unit.decodeRatio { percentage = True }))
(Decode.field "weighting" Split.decodeFloat)


decodeDefinition : String -> Decoder Definition
Expand Down
Loading

0 comments on commit 80160d6

Please sign in to comment.