Skip to content

Commit

Permalink
Feature/romania (electricitymaps#64)
Browse files Browse the repository at this point in the history
* Initial RO commit

* Fix imports

* Add link

* Update RO.py with exchanges

* Added arrows and fixed parser
  • Loading branch information
corradio authored Sep 20, 2016
1 parent 1e65428 commit 3bec007
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Each country has a GHG mass flow that depends on neighboring countries. In order
- Latvia: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx)
- Lithuania: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx)
- Norway: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx)
- Romania: [Transelectrica](http://www.transelectrica.ro/en/web/tel/home)
- Spain: [REE](https://demanda.ree.es/generacion_acumulada.html)
- Sweden: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx)

Expand Down
27 changes: 26 additions & 1 deletion api/static/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ if (!nobrowsercheck && !isChrome()) {
countries: ['FR', 'IT'],
lonlat: [6.5, 44.5],
rotation: 70
},
{
countries: ['RO', 'HU'],
lonlat: [21.8074107, 47.1141229],
rotation: -70
},
{
countries: ['RO', 'UA'],
lonlat: [24.821959, 47.768595],
rotation: 0
},
{
countries: ['RO', 'MD'],
lonlat: [28.009764, 47.003312],
rotation: 60
},
{
countries: ['RO', 'BG'],
lonlat: [25.609385, 43.674878],
rotation: 180
},
{
countries: ['RO', 'RS'],
lonlat: [21.469049, 44.947107],
rotation: -140
}
];

Expand Down Expand Up @@ -388,7 +413,7 @@ if (!nobrowsercheck && !isChrome()) {
-countries[o].data.exchange[d]
];
pair.netFlow = d3.mean(netFlows);
if (pair.netFlow == undefined)
if (pair.netFlow === undefined)
return;
pair.co2 = function () {
return pair.countries.map(function (k) { return countries[k].data.co2; });
Expand Down
3 changes: 2 additions & 1 deletion feeder/feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from parsers.LT import fetch_LT
from parsers.LV import fetch_LV
from parsers.NO import fetch_NO
from parsers.RO import fetch_RO
from parsers.SE import fetch_SE


Expand All @@ -30,8 +31,8 @@
fetch_LT,
fetch_LV,
fetch_NO,
fetch_RO,
fetch_SE

]

# Set up stats
Expand Down
44 changes: 44 additions & 0 deletions feeder/parsers/RO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import arrow
import dateutil
import requests

COUNTRY_CODE = 'RO'

def fetch_RO():
url = 'http://www.transelectrica.ro/sen-filter'
data = {}
for item in requests.get(url).json():
d = list(item.iteritems())[0]
data[d[0]] = d[1]

obj = {
'countryCode': COUNTRY_CODE,
'datetime': arrow.get(data['row1_HARTASEN_DATA'], "YY/M/D HH:mm:ss").replace(
tzinfo=dateutil.tz.gettz('Europe/Bucharest')).datetime
}
obj['consumption'] = {
'unknown': float(data['CONS'])
}
# According to http://www.transelectrica.ro/widget/web/tel/sen-harta/-/harta_WAR_SENOperareHartaportlet
# BALT and UCRS (for Baltic and Ukraine South) are categorized under Bulgary on transelectrica website. We did the same here.
obj['exchange'] = {
'BG': float(data.get('VARN', 0)) + float(data.get('DOBR', 0)) + float(data.get('KOZL1', 0)) + float(data.get('KOZL2', 0)) + float(data.get('BALT', 0)) + float(data.get('UCRS', 0)),
'HU': float(data.get('SAND', 0)) + float(data.get('BEKE1', 0)) + float(data.get('BEKE2', 0)),
'MD': float(data.get('COSE', 0)) + float(data.get('UNGE', 0)) + float(data.get('CIOA', 0)) + float(data.get('GOTE', 0)),
'RS': float(data.get('DJER', 0)) + float(data.get('PAN1', 0)) + float(data.get('PAN2', 0)) + float(data.get('KUSJ', 0)) + float(data.get('SIP_', 0)) + float(data.get('KIKI', 0)),
'UA': float(data.get('VULC', 0)) + float(data.get('MUKA', 0)) + float(data.get('COD1', 0))
}
obj['production'] = {
'biomass': float(data['BMASA']),
'coal': float(data['CARB']),
'gas': float(data['GAZE']),
'hydro': float(data['APE']),
'nuclear': float(data['NUCL']),
'solar': float(data['FOTO']),
'wind': float(data['EOLIAN'])
}

return obj

if __name__ == '__main__':
print fetch_RO()

0 comments on commit 3bec007

Please sign in to comment.