Food API - CompteCO2/Carbon-Weight Wiki

Class: default

Type aliases

Types

Ƭ Types: Object

Type declaration

Name Type
ComsumptionR ComsumptionR
ConsumptionT ConsumptionT
DataE DataE
FoodE FoodE
WasteE WasteE

Functions

buildData

Const buildData(dataR): DataI

Transform raw data factors from ADEME to the ones used by the calculator

Parameters

Name Type Description
dataR DataR the raw data coming from the .json referenced sources

Returns

DataI

the factors computed (averages/sums) to be used by the calculator

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new default(dataSet, data)

warning Should not be used : please use the static build method using dataset enum type DataE

Parameters

Name Type
dataSet ADEME_2022
data DataI

Properties

avgEmission

Private avgEmission: undefined | ComsumptionR


data

Private data: DataI


dataSet

Private dataSet: ADEME_2022

Methods

getData

getData(): DataI

Return the current data constants loaded

Returns

DataI

constant data loaded


getDataset

getDataset(): ADEME_2022

Return the inner data set name

Returns

ADEME_2022

constant data loaded


getEmissionAvg

getEmissionAvg(): ComsumptionR

Return the average co2 estimation from eating habits in kgCO2e/year.

description It takes the average adult consumption of different foods expressed in g/day from trusted source. The formulat we use is as simple as (where frequency is given by week) :

  • emission = SUM[(dailyAvg * 365) / 1000 * carbonEmissionFactor][kgco2e/year]
  • (365[g/day]) / 1000 * [kgCO2e/kg]

The waste:

  • waste = SUM[(daily * 365) / 1000 * wasteRatioFactor * wasteEmissionFactor][kgco2e/year]
  • (365[g/day]) / 1000 * [kgPackaging/kg] * [kgCO2e/kgPackaging]

warning Implementation is defined as a lazy singleton that compute only once.

Returns

ComsumptionR

The estimated co2 emission in kgCO2e/year


getEmissionEstimated

getEmissionEstimated(consumption): ComsumptionR

Compute a rough co2 estimation from eating habits in kgCO2e/year

description Your food carbon footprint is by design a best estimate. This approximation still allows you to get an order of magnitude and act.

The formula we use is as simple as (where frequency is given by week) :

  • emission = SUM[(weaklyConsumed * averageWeight * 52) / 1000 * carbonEmissionFactor][kgco2e/year]
  • (52[g/week]) / 1000 * [kgCO2e/kg]

The waste:

  • waste = SUM[(weaklyConsumed * averageWeight * 52) / 1000 * wasteRatioFactor * wasteEmissionFactor][kgco2e/year]
  • (52[g/week]) / 1000 * [kgPackaging/kg] * [kgCO2e/kgPackaging]

Parameters

Name Type Description
consumption ConsumptionT consumed products in meal/week

Returns

ComsumptionR

the estimated emission emissions in kgCO2e/year { -1, -1 } in case of error


build

Static build(dataset): default

Create a calculator instance from dataset

Parameters

Name Type
dataset ADEME_2022

Returns

default

new House calculator - Throw error if dataset not loaded.