forked from electricitymaps/electricitymaps-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/romania (electricitymaps#64)
* Initial RO commit * Fix imports * Add link * Update RO.py with exchanges * Added arrows and fixed parser
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |