Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser ES updates #7764 #7767

Conversation

t-couery
Copy link
Contributor

@t-couery t-couery commented Jan 25, 2025

Issue

This RP is linked to Canary Islands no data since 23.01.2025, closes: #7764
Fixes: GMM-389

Description

https://demanda.ree.es/ data has changed, this PR brings severals changes linked to this change on :

  • Mappings
  • Exchanges => I've implemented the new exchanges to: PT, FR, AD, MA but they're not configured at the moment

For the mapping of energy sources, I use this mapping. @silimotion says that thermal renewable can also includes biomass =>

  • Battery => battery (storage positive)
  • Batteries consume => battery (storage negative)
  • Renewable wastes => biomass
  • Coal => coal
  • Gas turbine => gas
  • Fuel/gas => gas (or oil or unknown ?)
  • Combined cycle => gas
  • Cogeneration => gas
  • Thermal renewable => geothermal
  • Pumping Turbine => hydro (storage positive)
  • Pumping consumption => hydro (storage negative)
  • Nuclear => nuclear
  • Diesel engines => oil
  • TAuxiliary generation => oil
  • Vapor turbine => oil
  • Solar PV => solar (PV = Photo voltaic so OK)
  • Solar => solar
  • Solar thermal => solar (hot water for turbine I guess)
  • Wastes => unknown
  • Cogeneration and waste => unknown
  • Other special regime => unknown
  • Other renewable => unknown
  • Non-renewable waste => unknown
  • Other special regime => unknown
  • Wind => wind

I need help to fix tests ES parser.

Preview

Below, I will detail the 12 zones :

  • ES-CN-HI => ElHierro
  • ES-CN-LP => LaPalma
  • ES-CN-IG => Gomera
  • ES-CN-TE => Tenerife
  • ES-CN-GC => GranCanaria
  • ES-CN-FVLZ => LanzaroteFuerteventura
  • ES-IB-MA => Mallorca
  • ES-IB-ME => Menorca
  • ES-IB-IZ => Ibiza
  • ES-IB-FO => Formentera
  • ES-CE => Ceuta
  • ES-ML => Melilla

Double check

  • I have tested my parser changes locally with poetry run test_parser "zone_key"
  • I have run poetry run format in the top level directory to format my changes.

@t-couery t-couery requested a review from VIKTORVAV99 as a code owner January 25, 2025 21:07
@github-actions github-actions bot added parser python Pull requests that update Python code zone config Pull request or issue for zone configurations labels Jan 25, 2025
@t-couery
Copy link
Contributor Author

t-couery commented Jan 25, 2025

ES : Spanish Peninsula

I've replaced ENSTO with the ES parser, which has more detail now, so you'll have to check if it's relevant.

poetry run test_parser ES consumption

[{'consumption': 30120.0,
  'datetime': datetime.datetime(2025, 1, 25, 21, 35, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES'}]

image

poetry run test_parser ES production

[ {'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 21, 35, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'coal': 251,
                 'gas': 2060,
                 'geothermal': 503,
                 'hydro': 4962,
                 'nuclear': 7119,
                 'solar': 41,
                 'unknown': 1366,
                 'wind': 11251},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'battery': -6, 'hydro': -1122},
  'zoneKey': 'ES'}]

please note that battery and hydro have production and consumption => I merge both value.

image

@t-couery
Copy link
Contributor Author

ES-CN-HI => ElHierro

poetry run test_parser ES-CN-HI consumption

[ {'consumption': 6.9,
  'datetime': datetime.datetime(2025, 1, 25, 21, 5, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-HI'}]

image

poetry run test_parser ES-CN-HI production

{'correctedModes': [],
'datetime': datetime.datetime(2025, 1, 25, 3, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
'production': {'gas': 0.0, 'hydro': 0.1, 'oil': 3.0, 'solar': 0.0, 'wind': 1.9},
'source': 'demanda.ree.es',
'sourceType': <EventSourceType.measured: 'measured'>,
'storage': {'hydro': -0.2},
'zoneKey': 'ES-CN-HI'}

storage -0.2 is 05 - 0.7
image

@t-couery
Copy link
Contributor Author

ES-CN-LP => LaPalma

poetry run test_parser ES-CN-LP consumption

 [{'consumption': 30.2,
  'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-LP'}]

[{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'production': {'gas': 0.0, 'hydro': 0.0, 'oil': 28.8, 'solar': 1.4, 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'hydro': -0.0},
  'zoneKey': 'ES-CN-LP'}]

image

@t-couery
Copy link
Contributor Author

ES-CN-IG => Gomera

poetry run test_parser ES-CN-IG consumption

[{'consumption': 10.1,
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-IG'}]

poetry run test_parser ES-CN-IG production

[{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'production': {'gas': 0.0, 'hydro': 0.0, 'oil': 8.8, 'solar': 0.0, 'wind': 1.3},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'hydro': -0.0},
  'zoneKey': 'ES-CN-IG'}]

image

@t-couery
Copy link
Contributor Author

ES-CN-TE => Tenerife

poetry run test_parser ES-CN-TE consumption

[{'consumption': 452.2,
  'datetime': datetime.datetime(2025, 1, 25, 14, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-TE'}]

poetry run test_parser ES-CN-TE production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 14, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'production': {'gas': 252.0, 'hydro': 0.0, 'oil': 95.1, 'solar': 76.8, 'wind': 27.3},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'hydro': -0.0},
  'zoneKey': 'ES-CN-TE'}

image

@t-couery
Copy link
Contributor Author

ES-CN-GC => GranCanaria

The hidden link on web site : https://demanda.ree.es/visiona/canarias/gcanariaau/acumulada/2025-1-25

poetry run test_parser ES-CN-GC consumption

{'consumption': 455.7,
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-GC'}

poetry run test_parser ES-CN-GC production

 {'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'production': {'gas': 262.4, 'hydro': 0.0, 'oil': 142.6, 'solar': 0.0, 'wind': 48.7},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'hydro': -0.0},
  'zoneKey': 'ES-CN-GC'}

Vapor turbine is oil in the mapping, need to check this point

image

@t-couery
Copy link
Contributor Author

ES-CN-FVLZ => LanzaroteFuerteventura

poetry run test_parser ES-CN-FVLZ consumption

{'consumption': 192.2,
  'datetime': datetime.datetime(2025, 1, 25, 17, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CN-FVLZ'}

poetry run test_parser ES-CN-FVLZ production

 {'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 17, 0, tzinfo=zoneinfo.ZoneInfo(key='Atlantic/Canary')),
  'production': {'gas': 5.8, 'hydro': 0.0, 'oil': 164.3, 'solar': 5.0, 'wind': 17.6},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'hydro': -0.0},
  'zoneKey': 'ES-CN-FVLZ'}

image

@t-couery
Copy link
Contributor Author

ES-IB-MA => Mallorca

poetry run test_parser ES-IB-MA consumption

 {'consumption': 556.1,
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-IB-MA'}

poetry run test_parser ES-IB-MA production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'biomass': 14.6,
                 'coal': 0.0,
                 'gas': 360.3,
                 'geothermal': 0.0,
                 'oil': 0.0,
                 'solar': 1.5,
                 'unknown': 15.5,
                 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {},
  'zoneKey': 'ES-IB-MA'}

image

@t-couery
Copy link
Contributor Author

ES-IB-ME => Menorca

poetry run test_parser ES-IB-ME consumption

{'consumption': 38.8,
  'datetime': datetime.datetime(2025, 1, 25, 16, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-IB-ME'}

poetry run test_parser ES-IB-ME production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 16, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'biomass': 0.0,
                 'coal': 0.0,
                 'gas': 19.6,
                 'geothermal': 0.0,
                 'oil': 0.0,
                 'solar': 19.9,
                 'unknown': 0.0,
                 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {},
  'zoneKey': 'ES-IB-ME'}

image

@t-couery
Copy link
Contributor Author

ES-IB-IZ => Ibiza

poetry run test_parser ES-IB-IZ consumption

 {'consumption': 108.7,
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-IB-IZ'}

poetry run test_parser ES-IB-IZ production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 20, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'biomass': 0.0,
                 'coal': 0.0,
                 'gas': 0.0,
                 'geothermal': 0.0,
                 'oil': 25.4,
                 'solar': 0.0,
                 'unknown': 0.6,
                 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {},
  'zoneKey': 'ES-IB-IZ'}

image

@t-couery
Copy link
Contributor Author

ES-IB-FO => Formentera

poetry run test_parser ES-IB-FO consumption

{'consumption': 5.4,
  'datetime': datetime.datetime(2025, 1, 25, 16, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-IB-FO'}

poetry run test_parser ES-IB-FO production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 16, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'biomass': 0.0,
                 'coal': 0.0,
                 'gas': 0.0,
                 'geothermal': 0.0,
                 'oil': 0.0,
                 'solar': 0.2,
                 'unknown': 0.0,
                 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {},
  'zoneKey': 'ES-IB-FO'}

image

@t-couery
Copy link
Contributor Author

ES-CE => Ceuta

poetry run test_parser ES-CE consumption

{'consumption': 26.83,
  'datetime': datetime.datetime(2025, 1, 25, 22, 0, tzinfo=zoneinfo.ZoneInfo(key='Africa/Ceuta')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-CE'}

poetry run test_parser ES-CE production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 22, 0, tzinfo=zoneinfo.ZoneInfo(key='Africa/Ceuta')),
  'production': {'gas': 0.07, 'oil': 27.38, 'unknown': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'battery': -0.0},
  'zoneKey': 'ES-CE'}

image

@t-couery
Copy link
Contributor Author

ES-ML => Melilla

poetry run test_parser ES-ML consumption

 {'consumption': 24.6,
  'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Africa/Ceuta')),
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'zoneKey': 'ES-ML'}

poetry run test_parser ES-ML production

{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Africa/Ceuta')),
  'production': {'gas': 0.0, 'oil': 24.31, 'unknown': 2.27},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {'battery': -0.0},
  'zoneKey': 'ES-ML'}

image

@t-couery
Copy link
Contributor Author

ES->ES-IB-MA

poetry run test_parser ES->ES-IB-MA exchange

'sourceType': <EventSourceType.measured: 'measured'>},
 {'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'netFlow': 165.3,
  'sortedZoneKeys': 'ES->ES-IB-MA',
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>}

ES-IB-IZ->ES-IB-MA

poetry run test_parser ES-IB-IZ->ES-IB-MA exchange

{'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'netFlow': -86.2,
  'sortedZoneKeys': 'ES-IB-IZ->ES-IB-MA',
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>}

ES-IB-MA->ES-IB-ME

poetry run test_parser ES-IB-MA->ES-IB-ME exchange

{'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'netFlow': 9.1,
  'sortedZoneKeys': 'ES-IB-MA->ES-IB-ME',
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>}

image

@t-couery
Copy link
Contributor Author

ES-IB-FO->ES-IB-IZ

poetry run test_parser ES-IB-FO->ES-IB-IZ exchange

{'datetime': datetime.datetime(2025, 1, 25, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'netFlow': 9.1,
  'sortedZoneKeys': 'ES-IB-MA->ES-IB-ME',
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>}

image

@t-couery
Copy link
Contributor Author

These exchange are not yet configured but implented

AD->ES

{'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')), 'sortedZoneKeys': 'AD->ES', 'netFlow': -55.0, 'source': 'demanda.ree.es', 'sourceType': <EventSourceType.measured: 'measured'>}

ES->MA

{'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')), 'sortedZoneKeys': 'ES->MA', 'netFlow': 516.0, 'source': 'demanda.ree.es', 'sourceType': <EventSourceType.measured: 'measured'>}

ES->FR

{'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')), 'sortedZoneKeys': 'ES->FR', 'netFlow': 2421.0, 'source': 'demanda.ree.es', 'sourceType': <EventSourceType.measured: 'measured'>},

ES->PT => This one is not yet in Electricity Map

{'datetime': datetime.datetime(2025, 1, 25, 15, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')), 'sortedZoneKeys': 'ES->PT', 'netFlow': 1219.0, 'source': 'demanda.ree.es', 'sourceType': <EventSourceType.measured: 'measured'>}

image

@github-actions github-actions bot added the tests label Jan 25, 2025
@VIKTORVAV99
Copy link
Member

@t-couery this looks great so far!

I'll start reviewing it tomorrow but to fix the tests you can run poetry run test --snapshot-update to re-generate the snapshots. This should fix the CI issue.

@t-couery
Copy link
Contributor Author

I'll start reviewing it tomorrow but to fix the tests you can run poetry run test --snapshot-update to re-generate the snapshots. This should fix the CI issue.

Thx, I had already tried using --snapshot-update without success, but after investigation I solved the problem bu uninstall snapshottest :
pip uninstall snapshottest

@VIKTORVAV99
Copy link
Member

Ah yeah!

We recently switched snapshot library because snapshottest didn't work reliably and had serilization issues.

Nice to see it got resolved though!

config/zones/ES.yaml Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Outdated
ses,
logger,
target_datetime,
)

exchangeList = ExchangeList(logger)
for event in data:
exchanges = {}
net_flow = 0.0
Copy link
Member

@VIKTORVAV99 VIKTORVAV99 Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good, this will mean the value will always be 0 even if it's missing.

I would recommend saving the exports in one exchange mapping and imports in another and then merging them.

something like in this psudo code:

exchanges = []
for exchange_key in EXCHANGE_MAPPING[sorted_zone_keys]["codes"]:
  for event in data:
    exchange_list = ExchangeList(logger)
    for key in event:
      exchange_list.append()
  exchanges.append(exchange_list)

return ExchangeList.merge_exchanges(exchanges, logger).toList()

(this can probably be made a bit more efficient)

This will ensure it's not defaulting to zero, that we only record the event if both the imports and exports are known, and re-use existing tested logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, it's been modified

parsers/test/test_ES.py Outdated Show resolved Hide resolved
Comment on lines 51 to 53
'correctedModes': list([
'hydro',
]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should not have occured here. Do you know why hydro was negative?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, after analysis it's a specic case of El Hierro wich have hydro storage but also a "gnhd" sum. I can"t remove this key because it's a standard hydro for Spain.
I do a specific patch for this case.
image

Copy link
Contributor

@silimotion silimotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the parser for a full year for ibiza and tenerife and compared the values that were generated when i calculated the emission factors half a year ago. The values are the same except for the differences due to the fuel mappings. E.g. Reporting gas and oil instead of all oil but gas + oil = old gas.

As far as I understand the mappings haven't changed. And even if they had changed some code would be needed to still report old data with the correct mapping.

@@ -291,31 +368,21 @@ def fetch_production(
check_valid_parameters(zone_key, session, target_datetime)
ses = session or Session()
data_mapping = PRODUCTION_PARSE_MAPPING.copy()

## Production mapping override for Canary Islands
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

This was used to adjust the mappings as different zones use different fuels but use the same name in demanda.ree.es.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I only used the wording on the electricity producer's website. I thought the data was credible and the old code obsolete. Do you think we should replace gas with oil?

Exemple of Tenerife :
#7767 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do could you 0 fill the data for gas? Normally we want to avoid it but otherwise it will keep both the oil and gas values in the database and this is simpler than me manually cleaning up the data for all of these zones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell me, I don't have an opinion on whether to put back the old code or leave mine or set it to 0 here.
I based my opinion on the https://demanda.ree.es/visiona/canarias/tenerifeau/acumulada/2025-01-29 website.

For Tenerife, with my code it's a majority of gas, with the old code it's mainly oil.

image

The old code gas + cycle combined => old for Canaries + Ibiza
For Menorca Diesel engines => gaz

    ## Production mapping override for Canary Islands
    # NOTE the LNG terminals are not built yet, so power generated by "gas" or "cc" in ES-CN domain is actually using oil.
    # Recheck this every 6 months and move to gas key if there has been a change.
    # Last checked: 2022-06-27
    if zone_key.split("-")[1] == "CN":
        data_mapping["gas"] = "oil"
        data_mapping["cc"] = "oil"

    if zone_key == "ES-IB-ME" or zone_key == "ES-IB-FO":
        data_mapping["gas"] = "oil"
    if zone_key == "ES-IB-IZ":
        data_mapping["die"] = "gas"

Copy link
Member

@VIKTORVAV99 VIKTORVAV99 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we concluded last time that there where no LNG terminals in the Canary Islands so unless that has changed they simply don't have any gas to burn.

Which is why they had a special mapping that attributed it to oil instead.

Not totally sure about the other islands from the top of my head but I think the reasoning was the same there.

Personally as long as we can back it up I'm fine with either option. As long as it's well founded. Best thing would probably be to reach out to REE and ask them to adjust their data mappings but that could take a while even if they decide to do it.

Copy link
Contributor

@silimotion silimotion Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this links we can see that all plants in tenerife only consume oil fuels:

1

2

3

(Click on "Consumos")

Edit:

To add a bit more of information and in case the links break in the far future or something:

Here is a screenshot of the page, in this case for the only fossil power plant in Menorca:

Screenshot_20250129_235714

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put the old code back in to keep this mapping and modify the test results accordingly

ES.get_url(ZoneKey("ES-IB-MA"), "2025-01-27"),
content=data.read(),
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be a good idea to also add a test for DST for the Canary Islands as the strings are a bit different (1A, 1B instead of 2A, 2B). Also because there are no Canary Islands tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, it's added

@silimotion
Copy link
Contributor

One detail I wanted to note regarding the fuel mappings:

Upon closer inspection I've noticed that the case of Ibiza is a bit more complicated than I initially thought...

Screenshot_20250130_004229

We can see that there is a bit of oil use... It is about 3% of all energy use so can't be mapped directly to diesel or gas turbines from ree. As according to the aggregated data that I just scraped from ree page neither gas turbines nor diesel has accounted for 3% of production since data is available.

Year Gas turbine Diesel engine
2017 353196 574011
2018 512796 400448
2019 191107 236817
2020 89489 53935
2021 84052 171038
2022 119301 269603
2023 124515 215734

Also:

When I looked in the archive, I found a 3 old backup with the following data:

Screenshot_20250130_012205

Which is also around 3%.

So I would guess oil is used as backup or during startup of the diesel or turbine generators. I think therefore that it would make sense to still map it to gas. Another option would be to map all production to unknown and add some comment in the app. The emission factors from gas could be reused even. The drawback would be that we don't know for sure the percentage, as there are only two data points.

At least this is what I understand from all this information. I'm sorry if this is very long, I wanted to be as clear as possible.

What do you think of this @VIKTORVAV99 ?

Copy link
Member

I'd rather not map it to unknown if it can be avoided. If it's just used as an emergency backup I think it's fine to map it as gas as well. Pretty sure that is happening in our other mappings for say ENTSO-E as well.

@t-couery
Copy link
Contributor Author

Just fyi, but given your level of understanding I know you've already understood. The parser already returns gas (wich include also arround 3% of oil) for the Ibiza zone with the latest updates. So we're in line with what needs to be done in this case.

{A1DE3855-C8DD-4081-BCE1-97C8AA3C1B38}

The row data. 'die' is converted to gaz here

        {
            "ts": "2025-01-30 11:00",
            "dem": 95.1,
            "car": 0.0,
            "die": 11.7,
            "gas": 0.0,
            "cc": 0.0,
            "cb": 0.0,
            "fot": 4.5,
            "tnr": 0.0,
            "trn": 0.0,
            "eol": 0.0,
            "emm": -0.0,
            "emi": 81.1,
            "otrRen": 0.6,
            "resid": 0.0,
            "genAux": 0.0,
            "cogen": 0.0,
            "eif": -2.7,
            "residNr": 0.0,
            "residRen": 0.0
        },
{'correctedModes': [],
  'datetime': datetime.datetime(2025, 1, 30, 11, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Madrid')),
  'production': {'biomass': 0.0,
                 'coal': 0.0,
                 'gas': 11.7,
                 'geothermal': 0.0,
                 'oil': 0.0,
                 'solar': 4.5,
                 'unknown': 0.6,
                 'wind': 0.0},
  'source': 'demanda.ree.es',
  'sourceType': <EventSourceType.measured: 'measured'>,
  'storage': {},
  'zoneKey': 'ES-IB-IZ'}

image

parsers/ES.py Outdated Show resolved Hide resolved
@t-couery
Copy link
Contributor Author

t-couery commented Feb 2, 2025

Hi, is there anything I can do to help close this RP?

Copy link
Contributor

@silimotion silimotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few last things regarding some details.

parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
Copy link
Member

@VIKTORVAV99 VIKTORVAV99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some final notes but looks good to me!

I'll merge it tomorrow (Monday) and see if I can add the new zones before creating a new release as well. Otherwise I'll split it later this week.

Thanks a lot for fixing this!

config/zones/ES.yaml Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
parsers/ES.py Outdated Show resolved Hide resolved
@silimotion
Copy link
Contributor

@VIKTORVAV99 I have just updated my .ipynb (Also on Colab) and added the emission factors for Lanzarote and Fuerteventura zones, so check those out when adding the new zones.

@VIKTORVAV99
Copy link
Member

@VIKTORVAV99 I have just updated my .ipynb (Also on Colab) and added the emission factors for Lanzarote and Fuerteventura zones, so check those out when adding the new zones.

Will do!

@VIKTORVAV99 VIKTORVAV99 enabled auto-merge (squash) February 3, 2025 08:39
@VIKTORVAV99 VIKTORVAV99 merged commit 24ed26d into electricitymaps:master Feb 3, 2025
21 checks passed
@t-couery
Copy link
Contributor Author

t-couery commented Feb 3, 2025

@VIKTORVAV99 and @silimotion

I just wanted to take a moment to sincerely thank you for your help with the Spanish electricity parser. Your knowledge and expertise were invaluable, and I truly appreciate the time and effort you took to guide me.

I had no idea that such a dedicated and competent community existed around this topic, and I’m really grateful to have had the opportunity to learn from you. Your insights made a huge difference, and I wouldn’t have made as much progress without your support.

Thanks again for you help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser python Pull requests that update Python code tests zone config Pull request or issue for zone configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data Issue]: Canary Islands no data since 23.01.2025
3 participants