Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* PL added

* current

* fixed bugs

* final

* final changes

* final changes

* final changes

* final changes

* final changes
  • Loading branch information
Apant authored and corradio committed Oct 17, 2016
1 parent fb06f3b commit a412421
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# electricitymap
# electricitymap
A real-time visualisation of the GHG and CO2 footprint of electricity generation built with [d3.js](https://d3js.org/), optimized for Google Chrome. Try it out at [http://electricitymap.tmrow.co](http://electricitymap.tmrow.co).

![image](https://cloud.githubusercontent.com/assets/1655848/16257011/15711692-3856-11e6-98ca-95cce4d02b02.png)
Expand Down Expand Up @@ -29,6 +29,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)
- Poland: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html)
- Portugal: [REN](http://www.centrodeinformacao.ren.pt/EN/InformacaoExploracao/Pages/EstatisticaDiaria.aspx)
- Romania: [Transelectrica](http://www.transelectrica.ro/en/web/tel/home)
- Spain: [REE](https://demanda.ree.es/generacion_acumulada.html)
Expand Down
49 changes: 49 additions & 0 deletions feeder/parsers/PL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from bs4 import BeautifulSoup
import arrow, requests

COUNTRY_CODE = 'PL'
session = requests.session()

def fetchValue(params):

now = arrow.utcnow()
end = now.replace(hours=+2)
start = now.replace(hours=-22)
periodEnd = end.format('YYYYMMDDHH00')
periodStart = start.format('YYYYMMDDHH00')

parameters = '&psrType=' + params + '&documentType=A75&processType=A16&in_Domain=10YPL-AREA-----S&periodStart=' + periodStart + '&periodEnd=' + periodEnd
url = 'https://transparency.entsoe.eu/api?securityToken=7466690c-c66a-4a00-8e21-2cb7d538f380' + parameters

content = session.get(url)
soup = BeautifulSoup(content.text, "html.parser")

last = soup.find_all('point')[-1].find_all('quantity')[-1]
value = last.contents[0]

return float(value)

def fetch_PL():

parameters = ["B01", "B02", "B03", "B04", "B05", "B06", "B10", "B11", "B12", "B19"]
output_array = map(fetchValue, parameters)

data = {
'countryCode': COUNTRY_CODE,
'production': {
'wind': output_array[9],
'solar': 0,
'hydro': output_array[6] + output_array[7] + output_array[8],
'biomass': output_array[0],
'nuclear': 0,
'gas': output_array[2] + output_array[3],
'coal': output_array[1] + output_array[4],
'oil': output_array[5],
'unknown': 0
}
}

return data

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

0 comments on commit a412421

Please sign in to comment.