def entsoe (self): client = EntsoePandasClient(api_key='5aa63adb-f9f7-47aa-8053-5cf531a3743f') start = pd.Timestamp(tomorrow, tz='Europe/Berlin') end = pd.Timestamp(aftertomorrow, tz='Europe/Berlin') country_code = 'DE' df = client.query_wind_and_solar_forecast(country_code, start=start, end=end, psr_type=None) df1 = client.query_generation_forecast(country_code, start=start, end=end ) df = self.kwh(df) df['hour']=df.index.hour df['date']=df.index.date df['weekDay']=df.index.dayofweek df['month']=df.index.month dfgroup = df.groupby(['date','hour']).agg({ 'Solar':'sum', 'Wind Offshore':'sum' ,'Wind Onshore':'sum' ,'weekDay':'max', 'month':'max'}) df2 = pd.DataFrame(data=df1) df2['hour']=df2.index.hour df2['date']=df2.index.date df1group = df2.groupby(['date','hour']).sum() df1group = df1group * 1000 df1group.rename(columns={0:'Generation'}, inplace=True) result = pd.concat([df1group,dfgroup], axis=1) idx = result.index result.index = result.index.set_levels([idx.get_level_values('date').astype(str), idx.get_level_values('hour')]) return result
ts_load = client.query_load(country_code, start=start, end=end) ts_load.to_csv('data_base/ts_load.csv') ts_load_forecast = client.query_load_forecast(country_code, start=start, end=end) ts_load_forecast.to_csv('data_base/ts_load_forecast.csv') ts_generation_forecast = client.query_generation_forecast(country_code, start=start, end=end) ts_generation_forecast.to_csv('data_base/ts_generation_forecast.csv') # Dataframes df_wind_and_solar_forecast = client.query_wind_and_solar_forecast( country_code, start=start, end=end, psr_type=None) df_wind_and_solar_forecast.to_csv('data_base/df_wind_and_solar_forecast.csv') df_generation = client.query_generation(country_code, start=start, end=end, psr_type=None) df_generation.to_csv('data_base/df_generation.csv') df_installed_generation_capacity = client.query_installed_generation_capacity( country_code, start=start, end=end, psr_type=None) df_installed_generation_capacity.to_csv( 'data_base/df_installed_generation_capacity.csv') df_crossborder_flows = client.query_crossborder_flows('DE', 'DK',
client = EntsoePandasClient(api_key='444fc771-5d0f-499f-9328-90c05c459219') #start and end date format start_date_raw = date.today() + timedelta(days=1) start_date = start_date_raw.strftime("%Y%m%d") end_date_raw = date.today() + timedelta(days=2) end_date = end_date_raw.strftime("%Y%m%d") #quering load and renewable generation forecasts start = pd.Timestamp(start_date, tz='Europe/Brussels') end = pd.Timestamp(end_date, tz='Europe/Brussels') country_code = 'DE' load_raw = client.query_load_forecast(country_code, start=start, end=end) renewable = client.query_wind_and_solar_forecast(country_code, start=start, end=end) #formating load_raw to pandas dataframe load = pd.DataFrame(load_raw) #Algorithm renewable['Total'] = renewable['Solar'] + renewable[ 'Wind Offshore'] + renewable['Wind Onshore'] renewable['Renewable/Load_ratio'] = renewable['Total'] / load[0] * 100 renewable['Quality_ratio'] = renewable['Renewable/Load_ratio'] / renewable[ 'Renewable/Load_ratio'].max() * 100 #Fomrating data: date, rounding values, etc... renewable['Date'] = renewable.index renewable.insert(0, 'id', range(0, len(renewable)))