Add hourly/quarterly frequency support for the 15-min market (#15), fix Periodo parsing (#14)#17
Open
KoscheiiB wants to merge 2 commits into
Open
Conversation
…cia#14) OMIE renamed the day-ahead period column from 'Hora' to 'Periodo' (file spec v1.37 §3.1). The energy-by-technology reader only mapped 'Hora', so current files lost the HOUR column and returned an empty/broken DataFrame. Map 'Periodo'->HOUR (accent-insensitive) and add the new ALMACENAMIENTO / HIBRIDACION technology columns.
…ia#15) From 2025-10-01 the day-ahead market publishes 96 quarter-hour periods (H1Q1..H24Q4) in place of 24 hourly ones. Add a Frequency enum and thread it through the marginal-price and energy-by-technology importers/readers: - QUARTERLY: full 96 periods; empty before 2025-10-01 (no data exists). - HOURLY (default, backward-compatible): native 24 for historical dates. - Quarter values are average power (MW); hourly is the MEAN of the four quarters, opt-in via derive_hourly_from_quarters (default off). The same URL serves both resolutions by date, so the parameter lives on the reader/importer rather than the downloader. Adds focused tests with real OMIE fixtures (pre and post cutover).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @acruzgarcia, following up on #15. This adds the quarter-hour support, in two commits so the
standalone bug can land on its own if you prefer.
The first commit fixes the
Periodorename (#14). Since 2025-10-01 OMIE renamed the period columnfrom
HoratoPeriodoin the day-ahead files. The energy-by-technology reader still mapped onlyHora, so for any current datedf[get_keys()]raised on the missingHOURcolumn, which is the empty/broken DataFrame in #14. Thefix maps
PeriodotoHOUR(accent-insensitive, so it also toleratesCARBÓNvsCARBON) and addsthe two new technology columns (
ALMACENAMIENTO,HIBRIDACIÓN). It stands on its own and fixescurrent hourly-named files regardless of the quarter-hour work.
The second commit adds the
frequencyparameter (#15): aFrequencyenum (HOURLY,QUARTERLY)threaded through the importers and readers for the two day-ahead files that come in both resolutions,
marginal price and energy-by-technology.
QUARTERLYreturns the full 96 periods (H1Q1..H24Q4), andan empty frame before 2025-10-01 since no quarter-hour data exists then.
HOURLY, the default soexisting callers are unchanged, returns the native 24 periods for historical dates exactly as before.
The quarter values are average power (MW) per 15-min slot, not additive energy, so hourly is the mean
of the four quarters, never the sum (that sum is the bug behind the roughly 4x inflation people hit).
Tests assert the mean.
One note on the design. You suggested adding
frequencyto the downloaders and downloading hourlywhen still possible. While building it I checked what OMIE serves now and it's a bit different from
what we'd expect, so I went a slightly different route; happy to change it if you'd rather. The
day-ahead files don't have separate hourly vs quarterly URLs; the same file flips content by date
(
INT_PBC_EV_H_1_..andINT_PBC_TECNOLOGIAS_H_..return 24 periods before 2025-10-01 and 96 after,at the same URL). The other published price file,
marginalpdbc, went the same way: 24 rows before,96 after (
marginalpdbc_20251015.1andmarginalpdbc_20260615.1both carry 96 periods, with valuesmatching the INT file). I couldn't find a current-date hourly day-ahead file under any of the usual
names.
OMIE's own file-format spec confirms it (Modelo de Ficheros, v1.37 PDF). From §3.1:
So for a current date there's no hourly file to download, only quarter-hour. That's why
frequencysits on the reader/importer, where it decides output shape, rather than the downloader, whose URL
doesn't depend on it. For the case where you ask for hourly but only quarter-hour exists, I left the
aggregation opt-in rather than forced:
derive_hourly_from_quartersdefaults toFalse(returnsnothing, faithful to what was published) and
Truegives hourly as the mean of the quarters. Thatkeeps the historical hourly contract intact and makes the quarter-to-hourly math a choice. If you'd
prefer the parameter on the downloaders, or a different default, I'll adjust.
Two related things are out of scope here, because they are new upstream surface rather than fixes to
existing readers. OMIEData has no commercial-capacities reader today, so that one is a new file type,
not a change to current behaviour. The day-ahead aggregated supply/demand curve is similar: under
§5.1.3.1 of the v1.37 spec it is now a quarter-hour curve (periods as
HnQn), published per day ascurva_pbc_YYYYMMDDon thefile-downloadendpoint, which is a different file and format from theper-hour
INT_CURVA_ACUM_UO_MIB_1_HH_..that the currentSupplyDemandCurveDownloaderbuilds. So itis an addition rather than a fix. Each would be its own separate PR, and worth pursuing only if it
fits the direction you want for OMIEData. If you'd want either of them upstream, let me know which way
you'd like to take it and I'm glad to put it together.
Tests are in
tests/filereaders_tests/quarterly_support_test.py(9 of them): quarterly returns 96,quarterly before cutover returns empty, hourly native unchanged, hourly-on-quarter default-empty vs
opt-in mean, and the
Periodofix. Fixtures are real OMIE files from before and after the cutover. Theexisting reader tests still pass (two pre-existing failures on pandas 3.x are unrelated).