data Module

This module provides methods to fetch energy production data for a specific country over a defined time period. One of the main challenges is the variability in the availability of data for different countries, which can impact the granularity and completeness of the data.

codegreen_core.data.energy(country, start_time, end_time, type='generation', interval60=True) pandas.DataFrame

Returns hourly time series of energy production mix for a specified country and time range.

This method fetches the energy data for the specified country between the specified duration. It checks if a valid energy data source is available. If not, None is returned. Otherwise, the energy data is returned as a pandas DataFrame. The structure of data depends on the energy source.

For example, if the source is ENTSOE, the data contains:

Column

type

Description

startTimeUTC

datetime

Start date in UTC (60 min interval)

Biomass

float64

Fossil Hard coal

float64

Geothermal

float64

….more energy sources

float64

renewableTotal

float64

The total based on all renewable sources

renewableTotalWS

float64

The total production using only Wind and Solar energy sources

nonRenewableTotal

float64

total

float64

Total using all energy sources

percentRenewable

int64

percentRenewableWS

int64

Percentage of energy produced using only wind and solar energy

Wind_per

int64

Percentages of individual energy sources

Solar_per

int64

Nuclear_per

int64

Hydroelectricity_per

int64

Geothermal_per

int64

Natural Gas_per

int64

Petroleum_per

int64

Coal_per

int64

Biomass_per

int64

Note : fields marked bold are calculated based on the data fetched.

Parameters:
  • country (str) – The 2 alphabet country code.

  • start_time (datetime) – The start date for data retrieval. A Datetime object. Note that this date will be rounded to the nearest hour.

  • end_time (datetime) – The end date for data retrieval. A datetime object. This date is also rounded to the nearest hour.

  • type (str) – The type of data to retrieve; either ‘historical’ or ‘forecasted’. Defaults to ‘historical’.

Returns:

A DataFrame containing the hourly energy production mix.

Return type:

pd.DataFrame

List of countries

The list of countries for which data is available :

Note

The following table is automatically generated from ‘codegreen_core.utilities.country_list.json’ on 2024-10-22

  • Austria (AT)

    • Energy source: ENTSOE

  • Bosnia and Herzegovina (BA)

    • Energy source: ENTSOE

  • Belgium (BE)

    • Energy source: ENTSOE

  • Bulgaria (BG)

    • Energy source: ENTSOE

  • Switzerland (CH)

    • Energy source: ENTSOE

  • Czech Republic (CZ)

    • Energy source: ENTSOE

  • Germany (DE)

    • Energy source: ENTSOE

  • Germany (DK)

    • Energy source: ENTSOE

  • Estonia (EE)

    • Energy source: ENTSOE

  • Spain (ES)

    • Energy source: ENTSOE

  • Finland (FI)

    • Energy source: ENTSOE

  • France (FR)

    • Energy source: ENTSOE

  • Greece (GR)

    • Energy source: ENTSOE

  • Croatia (HR)

    • Energy source: ENTSOE

  • Hungary (HU)

    • Energy source: ENTSOE

  • Ireland (IE)

    • Energy source: None

  • Italy (IT)

    • Energy source: ENTSOE

  • Lithuania (LT)

    • Energy source: ENTSOE

  • Luxembourg (LU)

    • Energy source: ENTSOE

  • Latvia (LV)

    • Energy source: ENTSOE

  • Montenegro (ME)

    • Energy source: ENTSOE

  • Netherlands (NL)

    • Energy source: ENTSOE

  • Norway (NO)

    • Energy source: ENTSOE

  • Republic of North Macedonia (MK)

    • Energy source: ENTSOE

  • Poland (PL)

    • Energy source: ENTSOE

  • Portugal (PT)

    • Energy source: ENTSOE

  • Romania (RO)

    • Energy source: ENTSOE

  • Serbia (RS)

    • Energy source: ENTSOE

  • Sweden (SE)

    • Energy source: ENTSOE

  • Slovenia (SI)

    • Energy source: ENTSOE

  • Slovak Republic (SK)

    • Energy source: ENTSOE

Fetching data from ENTSOE

ENTSO-E (https://www.entsoe.eu), the European Network of Transmission System Operators for Electricity, is an association that facilitates the cooperation of European transmission system operators (TSOs). Through its Transparency Portal, ENTSO-E provides real-time energy data for various countries across Europe, ensuring open access to this information. We utilize this data for countries within the European Union (EU).

codegreen_core.data.entsoe.get_actual_production_percentage(country, start, end, interval60=False) pandas.DataFrame

Returns time series data containing the percentage of energy generated from various sources for the specified country within the selected time period. It also includes the percentage of energy from renewable and non renewable sources. The data is fetched from the APIs is subsequently refined. To obtain data in 60-minute intervals (if not already available), set ‘interval60’ to True

Parameters:
  • country (str) – The 2 alphabet country code.

  • start (datetime) – The start date for data retrieval. A Datetime object. Note that this date will be rounded to the nearest hour.

  • end (datetime) – The end date for data retrieval. A datetime object. This date is also rounded to the nearest hour.

Returns:

A DataFrame containing the hourly energy production mix and percentage of energy generated from renewable and non renewable sources.

Return type:

pd.DataFrame

codegreen_core.data.entsoe.get_forecast_percent_renewable(country: str, start: datetime, end: datetime) pandas.DataFrame

Returns time series data comprising the forecast of the percentage of energy generated from renewable sources (specifically, wind and solar) for the specified country within the selected time period.

  • The data source is the ENTSOE APIs and involves combining data from 2 APIs : total forecast, wind and solar forecast.

  • The time interval is 60 min

  • the data frame includes : startTimeUTC, totalRenewable,total,percent_renewable,posix_timestamp

Parameters:
  • country (str) – The 2 alphabet country code.

  • start (datetime) – The start date for data retrieval. A Datetime object. Note that this date will be rounded to the nearest hour.

  • end (datetime) – The end date for data retrieval. A datetime object. This date is also rounded to the nearest hour.

Returns:

A DataFrame containing startTimeUTC, totalRenewable,total,percent_renewable,posix_timestamp.