EnergyTransition / ESDL-PyEcore-Tutorial

Jupiter Notebook based tutorial on how to program with ESDL in python (using PyEcore)
0 stars 3 forks source link

Cannot connect to EDR API #2

Open theogiraudet opened 1 year ago

theogiraudet commented 1 year ago

Hello,

I am following this tutorial to understand a bit how work with ESDL. When I execute the cell:

import influxdbreader as idb
import pandas as pd 
import numpy as np

# Reads the yearly solar production
yearly_solar_production = idb.read_yearly_solar_production_profile_data(2015)

# As this tutorial models a PV park as a producer, the data for an average PV park is taken from Energy Data Repository specification
# https://edr.hesi.energy/
yearly_solar_production['Production [kW]'] = yearly_solar_production['value'] * 17340000

I have an error thrown:

Error accessing EDR API: Opening and ending tag mismatch: link line 1 and head, line 1, column 614 (<string>, line 1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 6
      3 import numpy as np
      5 # Reads the yearly solar production
----> 6 yearly_solar_production = idb.read_yearly_solar_production_profile_data(2015)
      8 # As this tutorial models a PV park as a producer, the data for an average PV park is taken from Energy Data Repository specification
      9 # https://edr.hesi.energy/
     10 yearly_solar_production['Production [kW]'] = yearly_solar_production['value'] * 17340000

File c:\Users\...\ESDL-PyEcore-Tutorial\influxdbreader.py:76, in read_yearly_solar_production_profile_data(year)
     75 def read_yearly_solar_production_profile_data(year):
---> 76     yearly_production_profile = read_yearly_profile_data(get_influx_db_solar_profile(), year)
     77     return yearly_production_profile

File c:\Users\...\ESDL-PyEcore-Tutorial\influxdbreader.py:55, in read_yearly_profile_data(influx_db_profile, year)
     53 def read_yearly_profile_data(influx_db_profile, year):
---> 55     db_client = DataFrameClient(ssl=True, host=get_host(influx_db_profile), port=443, path=get_path(influx_db_profile), database=influx_db_profile.database)
     57     query = 'SELECT * FROM "' + influx_db_profile.measurement + '" WHERE time >= \''+str(year)+'-01-01T00:00:00Z\' AND time < \''+str(year+1)+'-01-01T00:00:00Z\''
     59     query_result_dict = db_client.query(query)

File c:\Users\...\ESDL-PyEcore-Tutorial\influxdbreader.py:40, in get_host(influx_db_profile)
     39 def get_host(influx_db_profile):
---> 40     url_dict = influx_db_profile.host.split('//', 1)
     41     host_tmp = influx_db_profile.host.split('//', 1)[1].split('/', 1)[0]
     43     return host_tmp

AttributeError: 'NoneType' object has no attribute 'host'

I have search a bit why I have this error and when I try manually to access to the called URL (https://edr.hesi.energy/store/esdl/55ef73b3-fa4f-49e8-8ad6-2b1801c25dfe?format=xml), I reach a login webpage. Thus the Python code gets from this URL a HTML text that cannot be parsed as an XML text. Moreover, the text just over the cell indicates the URL "https://edr.hesi.energy/api/" for the API but the page at this URL is blank. It seems to be a Swagger webpage that is not loading. I guess the API access or URL has changed and this tutorial has not been updated.

ewoudwerkman commented 1 year ago

Hi,

Thanks for filing this issue. The EDR (Energy data repository) that stores the profiles has had an upgrade and its API has changed, but we did not update the code in this repository, mainly because the dataset is not available anymore.

A short term solution would be to use another data source for getting this type of solar data.