Skip to content

Commit

Permalink
update electricity and add new countries
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBresson committed Aug 4, 2021
1 parent f159a5a commit 1e45350
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 37 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ Any Contribution is welcome!

Please read [this](/CONTRIBUTING.md) if you want to contribute.

### Lint + typescript :
### Tests + Lint + typescript :

`npm run lint`
and :
`npm run format`
`yarn test`
`yarn lint`
`yarn tsc`
`yarn format`

## Workflow

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carbon-footprint",
"version": "1.5.4",
"version": "1.6.0",
"description": "Calculate your carbon footprint. Food, transport, purchases, fashion, electricity and digital activities like streaming.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/electricity/electricity.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export enum ElectricityType {
portugal = 'portugal',
netherlands = 'netherlands',
belgium = 'belgium',
//to be removed at some point
danmark = 'danmark',
denmark = 'denmark',
germany = 'germany',
poland = 'poland',
italy = 'italy',
Expand All @@ -35,4 +37,10 @@ export enum ElectricityType {
uruguay = 'uruguay',
brazil = 'brazil',
australia = 'australia',
russia = 'russia',
india = 'india',
nigeria = 'nigeria',
canada = 'canada',
iceland = 'iceland',
israel = 'israel',
}
85 changes: 53 additions & 32 deletions src/electricity/electricity.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,64 @@
/* Unit of exported constant : kgCO鈧俥q/J */

/* source in kgCO鈧俥q/kWh : https://github.com/carbonalyser/Carbonalyser */
/* source : https://github.com/carbonalyser/Carbonalyser - kgCO鈧俥q/kWh */
const europe = 0.276;
const usa = 0.493;
const china = 0.681;
const world = 0.519;

/* Source : https://www.electricitymap.org - 28th of April 2020 */
/* Source : https://www.electricitymap.org - 4th of August 2021 - kgCO鈧俥q/kWh */

/* Europe in kgCO鈧俥q/kWh */
const france = 0.031;
const uk = 0.231;
const ireland = 0.477;
/* Asia */
const russia = (0.373 + 0.465) / 2;
const india = (0.643 + 0.473 + 0.097) / 3;
const israel = 0.58;
const turkey = 0.394;

/* Africa */
const nigeria = 0.49;

/* North America */
const canada = (0.04 + 0.506 + 0.02 + 0.03 + 0.509) / 5;
const iceland = 0.028;

/* Europe */
const france = 0.035;
const uk = 0.313;
const ireland = 0.472;
const spain = 0.138;
const portugal = 0.105;
const netherlands = 0.434;
const belgium = 0.172;
const danmark = 0.226;
const germany = 0.33;
const poland = 0.66;
const italy = 0.386;
const turkey = 0.322;
const finland = 0.162;
const norway = 0.036;
const czechia = 0.446;
const austria = 0.153;
const serbia = 0.517;
const slovenia = 0.078;
const hungary = 0.177;
const slovakia = 0.234;
const ukraine = 0.213;
const romania = 0.184;
const portugal = 0.296;
const netherlands = 0.466;
const belgium = 0.09;
//to be removed at some point
const danmark = 0.192;
const denmark = 0.192;
const germany = 0.304;
const poland = 0.725;
const italy = (0.249 + 0.237 + 0.452 + 0.449 + 0.354 + 0.52) / 6;
const finland = 0.094;
const norway = (0.026 + 0.031 + 0.039 + 0.029 + 0.033) / 5;
const czechia = 0.406;
const austria = 0.096;
const serbia = 0.548;
const slovenia = 0.278;
const hungary = 0.217;
const slovakia = 0.226;
const ukraine = 0.242;
const romania = 0.275;
const moldava = 0.667;
const estonia = 0.193;
const latvia = 0.243;
const lithuania = 0.183;
const estonia = 0.46;
const latvia = 0.44;
const lithuania = 0.361;

/* South America in kgCO鈧俥q/kWh */
const peru = 0.026;
const bolivia = 0.512;
const argentina = 0.299;
const uruguay = 0.03;
const brazil = 0.086;
const bolivia = 0.377;
const argentina = 0.33;
const uruguay = 0.33;
const brazil = (0.282 + 0.196 + 0.261 + 0.276) / 4;

/* Oceania in kgCO鈧俥q/kWh */
const australia = 0.571;
const australia = (0.708 + 0.303 + 0.641 + 0.455 + 0.22) / 5;

const toJoules = (x: number) => (x / 3.6) * Math.pow(10, -6);

Expand All @@ -61,6 +75,7 @@ export default {
netherlands: toJoules(netherlands),
belgium: toJoules(belgium),
danmark: toJoules(danmark),
denmark: toJoules(denmark),
germany: toJoules(germany),
poland: toJoules(poland),
italy: toJoules(italy),
Expand All @@ -85,4 +100,10 @@ export default {
uruguay: toJoules(uruguay),
brazil: toJoules(brazil),
australia: toJoules(australia),
russia: toJoules(russia),
india: toJoules(india),
nigeria: toJoules(nigeria),
canada: toJoules(canada),
iceland: toJoules(iceland),
israel: toJoules(israel),
};

0 comments on commit 1e45350

Please sign in to comment.