Skip to content

entsoe

Entoso-E utils are used to work with data from Entsoe-E

Entsoe

Class to help working with Entose data

Source code in physical_operations_utils/entsoe.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Entsoe:
    """Class to help working with Entose data"""

    def __init__(self):
        logging.warning("Entsoe class initialized")
        pass

    def map_area_eic_code_to_area_name(self, eic_code: str) -> str:
        """
        Map EIC code to area name.

        Args:
            eic_code (str): The EIC code to map.

        Returns:
            str: The corresponding area name if found, otherwise None.

        Raises:
            ValueError: If eic_code is not a string.

        Example:
            ```python
            entsoe = Entsoe()
            entsoe.map_area_eic_code_to_area_name("10YNO-1--------2")
            # Output: 'NO1'
            entsoe.map_area_eic_code_to_area_name("10YFI-1--------U")
            # Output: 'FI'
            entsoe.map_area_eic_code_to_area_name("INVALID_CODE")
            # Output: None
            ```
        """

        logging.warning(f"Mapping EIC code {eic_code} to area name")

        if not isinstance(eic_code, str):
            raise ValueError("eic_code must be a string")

        entsoe_eic_area_dictionary = {
            "10YNO-1--------2": "NO1",
            "10YNO-2--------T": "NO2",
            "10YNO-3--------J": "NO3",
            "10YNO-4--------9": "NO4",
            "10Y1001A1001A48H": "NO5",
            "10Y1001A1001A44P": "SE1",
            "10Y1001A1001A45N": "SE2",
            "10Y1001A1001A46L": "SE3",
            "10Y1001A1001A47J": "SE4",
            "10YFI-1--------U": "FI",
            "10YDK-1--------W": "DK1",
            "10YDK-2--------M": "DK2",
            "10Y1001A1001A39I": "EE",
            "10YLV-1001A00074": "LV",
            "10YLT-1001A0008Q": "LT",
        }

        if eic_code in entsoe_eic_area_dictionary:
            logging.warning(f"Mapping found for EIC code {eic_code}")
            return entsoe_eic_area_dictionary[eic_code]
        else:
            logging.warning(f"No mapping found for EIC code {eic_code}")
            return

map_area_eic_code_to_area_name(eic_code)

Map EIC code to area name.

Parameters:

Name Type Description Default
eic_code str

The EIC code to map.

required

Returns:

Name Type Description
str str

The corresponding area name if found, otherwise None.

Raises:

Type Description
ValueError

If eic_code is not a string.

Example
entsoe = Entsoe()
entsoe.map_area_eic_code_to_area_name("10YNO-1--------2")
# Output: 'NO1'
entsoe.map_area_eic_code_to_area_name("10YFI-1--------U")
# Output: 'FI'
entsoe.map_area_eic_code_to_area_name("INVALID_CODE")
# Output: None
Source code in physical_operations_utils/entsoe.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def map_area_eic_code_to_area_name(self, eic_code: str) -> str:
    """
    Map EIC code to area name.

    Args:
        eic_code (str): The EIC code to map.

    Returns:
        str: The corresponding area name if found, otherwise None.

    Raises:
        ValueError: If eic_code is not a string.

    Example:
        ```python
        entsoe = Entsoe()
        entsoe.map_area_eic_code_to_area_name("10YNO-1--------2")
        # Output: 'NO1'
        entsoe.map_area_eic_code_to_area_name("10YFI-1--------U")
        # Output: 'FI'
        entsoe.map_area_eic_code_to_area_name("INVALID_CODE")
        # Output: None
        ```
    """

    logging.warning(f"Mapping EIC code {eic_code} to area name")

    if not isinstance(eic_code, str):
        raise ValueError("eic_code must be a string")

    entsoe_eic_area_dictionary = {
        "10YNO-1--------2": "NO1",
        "10YNO-2--------T": "NO2",
        "10YNO-3--------J": "NO3",
        "10YNO-4--------9": "NO4",
        "10Y1001A1001A48H": "NO5",
        "10Y1001A1001A44P": "SE1",
        "10Y1001A1001A45N": "SE2",
        "10Y1001A1001A46L": "SE3",
        "10Y1001A1001A47J": "SE4",
        "10YFI-1--------U": "FI",
        "10YDK-1--------W": "DK1",
        "10YDK-2--------M": "DK2",
        "10Y1001A1001A39I": "EE",
        "10YLV-1001A00074": "LV",
        "10YLT-1001A0008Q": "LT",
    }

    if eic_code in entsoe_eic_area_dictionary:
        logging.warning(f"Mapping found for EIC code {eic_code}")
        return entsoe_eic_area_dictionary[eic_code]
    else:
        logging.warning(f"No mapping found for EIC code {eic_code}")
        return