Skip to content

Commit

Permalink
Add data parser for Iceland (electricitymaps#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spydarlee authored and corradio committed Feb 4, 2017
1 parent d015931 commit 03d5d41
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Each country has a GHG mass flow that depends on neighboring countries. In order
- Great Britain: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Greece: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Hungary: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Iceland [LANDSNET](http://amper.landsnet.is/MapData/api/measurements)
- Ireland: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Italy: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Latvia: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
Expand Down Expand Up @@ -71,6 +72,7 @@ Each country has a GHG mass flow that depends on neighboring countries. In order
- Great Britain: [ENTSO-E](https://transparency.entsoe.eu/generation/r2/installedGenerationCapacityAggregation/show)
- Greece: [ENTSO-E](https://transparency.entsoe.eu/generation/r2/installedGenerationCapacityAggregation/show)
- Hungary: [ENTSO-E](https://transparency.entsoe.eu/generation/r2/installedGenerationCapacityAggregation/show)
- Iceland: [Statistics Iceland](http://px.hagstofa.is/pxen/pxweb/en/Atvinnuvegir/Atvinnuvegir__orkumal/IDN02101.px)
- Ireland
- All production types: [ENTSO-E](https://transparency.entsoe.eu/generation/r2/installedGenerationCapacityAggregation/show)
- Wind: [IWEA](http://www.iwea.com/index.cfm/page/windenergyfaqs?#q21)
Expand Down
2 changes: 2 additions & 0 deletions feeder/feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from bson.binary import Binary
from pymemcache.client.base import Client

from parsers import IS
from parsers import FR
from parsers import ENTSOE
from parsers import weather
Expand Down Expand Up @@ -105,6 +106,7 @@
'GR': ENTSOE.fetch_production,
'HU': ENTSOE.fetch_production,
'IE': ENTSOE.fetch_production,
'IS': IS.fetch_production,
'IT': ENTSOE.fetch_production,
'LT': ENTSOE.fetch_production,
'LU': ENTSOE.fetch_production,
Expand Down
11 changes: 7 additions & 4 deletions feeder/parsers/ENTSOE.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,15 @@ def get_wind(values):
if 'Wind Onshore' in values or 'Wind Offshore' in values:
return values.get('Wind Onshore', 0) + values.get('Wind Offshore', 0)

def get_geothermal(values):
if 'Geothermal' in values:
return values.get('Geothermal', 0);

def get_unknown(values):
if 'Geothermal' in values \
or 'Marine' in values \
if 'Marine' in values \
or 'Other renewable' in values \
or 'Other' in values:
return values.get('Geothermal', 0) + \
values.get('Marine', 0) + \
return values.get('Marine', 0) + \
values.get('Other renewable', 0) + \
values.get('Other', 0)

Expand Down Expand Up @@ -335,6 +337,7 @@ def fetch_production(country_code, session=None):
'oil': get_oil(production_values),
'solar': production_values.get('Solar', None),
'wind': get_wind(production_values),
'geothermal': get_geothermal(production_values),
'unknown': get_unknown(production_values)
},
'storage': {
Expand Down
75 changes: 75 additions & 0 deletions feeder/parsers/IS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import requests
from datetime import datetime
from collections import defaultdict
import xml.etree.ElementTree as ET
import json

STATIONS = {

# http://www.landsvirkjun.com/company/powerstations/
'Bjarnaflag': 'geothermal', # No data?
'BLANDA_F': 'hydro',
'BUDAR_O': 'hydro',
'BURF_F': 'hydro',
'FLJOTSDA': 'hydro',
'Hafio': 'wind', # No data?
'HRAUN_F': 'hydro',
'IRAFOS_F': 'hydro',
'KRAFLA_F': 'geothermal',
'LAXA_F': 'hydro',
'LAXARVAT': 'hydro',
'laxa': 'hydro', # No data?
'LJOSIF_F': 'hydro',
'SIG_F': 'hydro',
'Steingrimsstod': 'hydro', # No data?
'SULTAR_F': 'hydro',
'VATNSHAM': 'hydro',

# https://en.wikipedia.org/wiki/List_of_power_stations_in_Iceland
'KOLVID': 'geothermal',
'LAGARF': 'hydro',
'MJOLKA': 'hydro',
'REY': 'geothermal',
'X_NESJAV': 'geothermal',
'SVA': 'geothermal',
}

def fetch_production(country_code='IS', session=None):

# Query Landsnet for latest power production data for Iceland
r = session or requests.session()
url = 'http://amper.landsnet.is/MapData/api/measurements'
response = r.get(url)
json_obj = json.loads(response.text)

# Set zero values for energy sources Iceland doesn't use at all
# Iceland does use some wind and gas but we don't have data for those
production = defaultdict(float)
production["solar"] = 0;
production["biomass"] = 0;
production["nuclear"] = 0;
production["coal"] = 0;

# Calculate production values for each power station
# The Landsnet API includes measurements for non-generating
# stations (e.g. capacitor banks) so ignore any not in our list
for key, value in STATIONS.items():
items = [item for item in json_obj if item["substation"] == key and item["MW"] >= 0]
mw = sum(item['MW'] for item in items)
production[value] = production[value] + mw;

# Get datetime for last update (e.g. 2017-02-02T14:35:00)
totalpowerflow = next(item for item in json_obj if item["key"] == "TOTAL_POWER_FLOW")
datetime_last = datetime.strptime(totalpowerflow["time"], '%Y-%m-%dT%H:%M:%S')

data = {
'countryCode': country_code,
'production': dict(production),
'datetime': datetime_last,
'storage': {},
'source': 'landsnet.is',
}
return data

if __name__ == '__main__':
print fetch_production()
1 change: 1 addition & 0 deletions shared/co2eq_parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defaultCo2eqFootprint = {
'oil': 650,
'solar': 45,
'wind': 12,
'geothermal': 24,
'unknown': 700, // assume conventional
'other': 700 // same as 'unknown'. Here for backward compatibility
}; // in gCo2eq/kWh
Expand Down
14 changes: 14 additions & 0 deletions web/app/configs/capacities.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@
"wind": 3025
}
},
"IS": {
"capacity": {
"biomass": 0,
"oil": 117,
"coal": 0,
"hydro": 1986,
"geothermal": 665,
"nuclear": 0,
"gas": 0,
"unknown": 0,
"solar": 0,
"wind": 3
}
},
"IT": {
"capacity": {
"hydro": 22382,
Expand Down
2 changes: 2 additions & 0 deletions web/app/countrytable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function CountryTable(selector, co2Color) {
'solar': '#f27406',
'hydro': '#2772b2',
'biomass': '#166a57',
'geothermal': 'yellow',
'nuclear': '#AEB800',
'gas': '#bb2f51',
'coal': '#ac8c35',
Expand All @@ -42,6 +43,7 @@ function CountryTable(selector, co2Color) {
'solar',
'hydro',
'hydro storage',
'geothermal',
'biomass',
'nuclear',
'gas',
Expand Down

0 comments on commit 03d5d41

Please sign in to comment.