Skip to content

Commit

Permalink
Moving CO2 model to shared space, preparing for electricitymaps#305
Browse files Browse the repository at this point in the history
  • Loading branch information
corradio committed Jan 26, 2017
1 parent d0f07b6 commit eda959a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git
*.tar.gz
*.json
*secrets*
*.env

datascience

web/node_modules
web/build
web/public/dist
web/world_*.json
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Consider [contributing](#contribute) or submit ideas, feature requests or bugs o
### GreenHouse Gas footprint calcuation and data source
The GreenHouse Gas (GHG) footprint of each country is measured from the perspective of a consumer. It represents the GHG footprint of 1 kWh consumed inside a given country, in the gCO2eq unit (meaning each GHG is converted to its CO2 equivalent in terms of global warming potential).

The GHG footprint of each production mode takes into account the construction of production units and their usual lifetimes as calculated by the 2014 IPCC report (see [wikipedia entry](https://en.wikipedia.org/wiki/Life-cycle_greenhouse-gas_emissions_of_energy_sources#2014_IPCC.2C_Global_warming_potential_of_selected_electricity_sources) and [co2eq.js#L1](https://github.com/corradio/electricitymap/blob/master/web/app/co2eq.js)).
The GHG footprint of each production mode takes into account the construction of production units and their usual lifetimes as calculated by the 2014 IPCC report (see [wikipedia entry](https://en.wikipedia.org/wiki/Life-cycle_greenhouse-gas_emissions_of_energy_sources#2014_IPCC.2C_Global_warming_potential_of_selected_electricity_sources) and [co2eq.js](https://github.com/corradio/electricitymap/blob/master/shared/co2eq.js)).

Each country has a GHG mass flow that depends on neighboring countries. In order to determine the GHG footprint of each country, the set of coupled GHG mass flow balance equations of each countries must be solved simultaneously. This is done by solving the linear system of equations defining the network of GHG exchanges (see [co2eq.js#L52](https://github.com/corradio/electricitymap/blob/master/web/app/co2eq.js#L52)).
Each country has a GHG mass flow that depends on neighboring countries. In order to determine the GHG footprint of each country, the set of coupled GHG mass flow balance equations of each countries must be solved simultaneously. This is done by solving the linear system of equations defining the network of GHG exchanges (see [co2eq.js#L52](https://github.com/corradio/electricitymap/blob/master/shared/co2eq.js)).


### Real-time electricity data sources
Expand Down
25 changes: 15 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '2'
services:
web:
build: web
build:
context: .
dockerfile: web/Dockerfile
command: npm run server-dev
depends_on: [mongo, memcached]
environment:
Expand All @@ -10,23 +12,26 @@ services:
- 'MONGO_URL=mongodb://mongo:27017/electricity'
ports: ['8000:8000']
volumes:
- './web/app:/home/app'
- './web/package.json:/home/package.json'
- './web/public:/home/public'
- './web/server.js:/home/server.js'
- './web/views:/home/views'
- './web/webpack.config.js:/home/webpack.config.js'
- './shared:/home/shared'
- './web/app:/home/web/app'
- './web/package.json:/home/web/package.json'
- './web/public:/home/web/public'
- './web/server.js:/home/web/server.js'
- './web/views:/home/web/views'
- './web/webpack.config.js:/home/web/webpack.config.js'
feeder:
build: feeder
build:
context: .
dockerfile: feeder/Dockerfile
depends_on: [mongo]
env_file: ./secrets.env
environment:
- ENV=development
- MEMCACHED_HOST=memcached
- 'MONGO_URL=mongodb://mongo:27017/electricity'
volumes:
- './feeder/feeder.py:/home/feeder.py'
- './feeder/parsers:/home/parsers'
- './feeder:/home/feeder'
- './shared:/home/shared'
memcached:
image: memcached
mongo:
Expand Down
8 changes: 4 additions & 4 deletions feeder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM python:2.7
WORKDIR /home/
RUN apt-get update
# Install python
# Install pygrib dependencies manually
RUN apt-get install -y libgrib-api-dev libsnappy-dev && \
pip install numpy==1.10.1 pyproj==1.9.4
WORKDIR /home/feeder
# Only add requirements to enable cached builds when it is unchanged
ADD requirements.txt /home/requirements.txt
ADD feeder/requirements.txt /home/feeder/requirements.txt
RUN pip install -r requirements.txt
# Add the rest
ADD . /home/
ADD feeder /home/feeder
ADD shared /home/shared
CMD python -u feeder.py
File renamed without changes.
4 changes: 0 additions & 4 deletions web/.dockerignore

This file was deleted.

7 changes: 4 additions & 3 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM node:6.9.2
WORKDIR /home
WORKDIR /home/web
EXPOSE 8000
ADD package.json /home/package.json
ADD web/package.json /home/web/package.json
RUN npm install
ADD . /home
ADD web /home/web
ADD shared /home/shared
RUN npm run build-release
CMD node server.js
# Healthcheck removed for now because Docker > 1.10 not supported by circle ci
Expand Down
4 changes: 2 additions & 2 deletions web/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if (isProduction) {
}

var async = require('async');
var co2eq_parameters = require('./app/co2eq_parameters');
var co2lib = require('./app/co2eq');
var co2eq_parameters = require('../shared/co2eq_parameters');
var co2lib = require('../shared/co2eq');
var compression = require('compression');
var d3 = require('d3');
var express = require('express');
Expand Down

0 comments on commit eda959a

Please sign in to comment.