python-esios 2.1.0__py3-none-any.whl → 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esios/.agents/skills/esios/SKILL.md +104 -129
- esios/catalog.py +478 -0
- esios/cli/app.py +2 -0
- esios/cli/catalog_cmd.py +177 -0
- esios/client.py +5 -0
- esios/data/archives.yaml +921 -0
- esios/data/geos.yaml +3 -0
- esios/data/indicators.yaml +43 -0
- esios/data/magnitudes.yaml +3 -0
- esios/data/time_periods.yaml +3 -0
- esios/managers/archives.py +2 -4
- {python_esios-2.1.0.dist-info → python_esios-2.2.0.dist-info}/METADATA +2 -1
- {python_esios-2.1.0.dist-info → python_esios-2.2.0.dist-info}/RECORD +16 -13
- esios/data/catalogs/__init__.py +0 -0
- esios/data/catalogs/archives/__init__.py +0 -5
- esios/data/catalogs/archives/catalog.py +0 -163
- esios/data/catalogs/archives/refresh.py +0 -95
- {python_esios-2.1.0.dist-info → python_esios-2.2.0.dist-info}/WHEEL +0 -0
- {python_esios-2.1.0.dist-info → python_esios-2.2.0.dist-info}/entry_points.txt +0 -0
- {python_esios-2.1.0.dist-info → python_esios-2.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,81 +1,62 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: esios
|
|
3
3
|
description: Query Spanish electricity market data (ESIOS/REE). Use when the user asks about electricity prices, generation, demand, I90 files, or any ESIOS indicator.
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# ESIOS Data Assistant
|
|
8
8
|
|
|
9
|
-
You have access to the `python-esios`
|
|
9
|
+
You have access to the `python-esios` library and CLI for querying the Spanish electricity market (ESIOS/REE).
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## When to use what
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# List all indicators
|
|
17
|
-
esios indicators list
|
|
13
|
+
- **Python scripts** (default): reproducible, composable, saveable. Use for any data work the user will want to keep or iterate on.
|
|
14
|
+
- **CLI**: quick one-shot lookups, exploration, sanity checks. Use when the user wants a fast answer they won't need again.
|
|
15
|
+
- **If unsure**: ask the user whether they want a script or a quick CLI check.
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
esios indicators search "precio"
|
|
17
|
+
## Python Library (default)
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
esios
|
|
19
|
+
```python
|
|
20
|
+
from esios import ESIOSClient
|
|
24
21
|
|
|
25
|
-
#
|
|
26
|
-
esios indicators history 600 --start 2025-01-01 --end 2025-01-31
|
|
27
|
-
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --format csv --output data.csv
|
|
28
|
-
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --format parquet --output data.parquet
|
|
22
|
+
client = ESIOSClient() # reads config file, then ESIOS_API_KEY env var
|
|
29
23
|
|
|
30
|
-
#
|
|
31
|
-
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo España
|
|
32
|
-
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo 3
|
|
24
|
+
# --- Indicators ---
|
|
33
25
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 --expr "df.resample('D').mean()"
|
|
37
|
-
```
|
|
26
|
+
# Get indicator handle
|
|
27
|
+
handle = client.indicators.get(600)
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
# Historical data as DataFrame
|
|
30
|
+
df = handle.historical("2025-01-01", "2025-01-31")
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
esios archives list
|
|
32
|
+
# Filter by geography
|
|
33
|
+
df = handle.historical("2025-01-01", "2025-01-31", geo_ids=[3]) # España only
|
|
44
34
|
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
# Inspect geographies
|
|
36
|
+
handle.geos # List of {"geo_id": int, "geo_name": str}
|
|
37
|
+
handle.geos_dataframe() # DataFrame with geo_id and geo_name columns
|
|
38
|
+
handle.resolve_geo("España") # Returns 3
|
|
48
39
|
|
|
49
|
-
#
|
|
50
|
-
|
|
40
|
+
# Search indicators
|
|
41
|
+
results = client.indicators.search("precio")
|
|
51
42
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
esios archives exec 34 --sheet I90DIA03 --date 2025-06-01 -x "df.describe()"
|
|
55
|
-
esios archives exec 34 --sheet I90DIA03 -s 2025-05-05 -e 2025-06-08 \
|
|
56
|
-
-x "df[df['Sentido']=='Bajar'].groupby('Unidad de Programación')['value'].sum().sort_values()"
|
|
57
|
-
esios archives exec 34 --sheet I90DIA26 --date 2025-06-01 --format csv --output pbf.csv
|
|
58
|
-
```
|
|
43
|
+
# Compare multiple indicators
|
|
44
|
+
df = client.indicators.compare([600, 10034, 10035], "2025-01-01", "2025-01-07")
|
|
59
45
|
|
|
60
|
-
|
|
46
|
+
# --- I90 Settlement Files ---
|
|
61
47
|
|
|
62
|
-
|
|
63
|
-
esios cache status # Path, size, geos registry, catalog info
|
|
64
|
-
esios cache geos # Global geo_id → geo_name registry
|
|
65
|
-
esios cache path # Print cache directory
|
|
66
|
-
esios cache clear # Clear indicator cache
|
|
67
|
-
esios cache clear --all # Clear everything (indicators, archives, geos, catalog)
|
|
68
|
-
esios cache clear --indicator 600 # Clear one indicator
|
|
69
|
-
```
|
|
48
|
+
from esios.processing.i90 import I90Book
|
|
70
49
|
|
|
71
|
-
|
|
50
|
+
archive = client.archives.get(34)
|
|
51
|
+
books = I90Book.from_archive(archive, start="2025-05-05", end="2025-06-08")
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
book = books[0]
|
|
54
|
+
sheet = book["I90DIA03"]
|
|
55
|
+
df = sheet.df # Preprocessed DataFrame with datetime index
|
|
56
|
+
print(sheet.frequency) # "hourly" or "hourly-quarterly"
|
|
76
57
|
```
|
|
77
58
|
|
|
78
|
-
|
|
59
|
+
### Common Indicator IDs
|
|
79
60
|
|
|
80
61
|
| ID | Name | Description | Geos |
|
|
81
62
|
|----|------|-------------|------|
|
|
@@ -86,24 +67,18 @@ esios config show
|
|
|
86
67
|
| 10035 | Generación solar FV | Real-time solar PV generation | ES |
|
|
87
68
|
| 1293 | Demanda prevista | Forecasted demand | ES |
|
|
88
69
|
|
|
89
|
-
Use `
|
|
70
|
+
Use `client.indicators.search("query")` to find more.
|
|
90
71
|
|
|
91
|
-
|
|
72
|
+
### Multi-Geo Indicators
|
|
92
73
|
|
|
93
|
-
Some indicators (e.g. 600) return data for multiple countries.
|
|
74
|
+
Some indicators (e.g. 600) return data for multiple countries. Output is pivoted so each geography becomes a column:
|
|
94
75
|
|
|
95
76
|
```
|
|
96
77
|
datetime España Portugal Francia Alemania Bélgica Países Bajos
|
|
97
78
|
2025-01-01 00:00:00 63.50 63.50 72.10 58.20 58.20 58.20
|
|
98
|
-
2025-01-01 01:00:00 55.80 55.80 60.30 48.90 48.90 48.90
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Filter to specific geos with `--geo`:
|
|
102
|
-
```bash
|
|
103
|
-
esios indicators history 600 -s 2025-01-01 -e 2025-01-07 --geo España --geo Portugal
|
|
104
79
|
```
|
|
105
80
|
|
|
106
|
-
|
|
81
|
+
### Geography Reference
|
|
107
82
|
|
|
108
83
|
| geo_id | geo_name |
|
|
109
84
|
|--------|----------|
|
|
@@ -114,94 +89,94 @@ esios indicators history 600 -s 2025-01-01 -e 2025-01-07 --geo España --geo Por
|
|
|
114
89
|
| 8827 | Bélgica |
|
|
115
90
|
| 8828 | Países Bajos |
|
|
116
91
|
|
|
117
|
-
|
|
118
|
-
- `--geo 3` or `--geo España` or `--geo españa`
|
|
119
|
-
- `--geo "Países Bajos"` or `--geo 8828`
|
|
92
|
+
### I90 Key Sheets
|
|
120
93
|
|
|
121
|
-
|
|
94
|
+
| Sheet | Description |
|
|
95
|
+
|-------|-------------|
|
|
96
|
+
| I90DIA03 | Restricciones en el Mercado Diario (curtailment) |
|
|
97
|
+
| I90DIA08 | Restricciones en Tiempo Real |
|
|
98
|
+
| I90DIA26 | Programa Base de Funcionamiento (PBF, generation program) |
|
|
99
|
+
| I90DIA01 | Programa PVP |
|
|
100
|
+
| I90DIA07 | Regulación Terciaria (mFRR) |
|
|
122
101
|
|
|
123
|
-
|
|
124
|
-
from esios import ESIOSClient
|
|
102
|
+
### Key conventions
|
|
125
103
|
|
|
126
|
-
|
|
104
|
+
- All timestamps are in Europe/Madrid timezone
|
|
105
|
+
- Date ranges > 3 weeks are auto-chunked into smaller API requests
|
|
106
|
+
- Data older than 48h is considered final (won't be re-fetched)
|
|
107
|
+
- Recent data (last 48h) is re-fetched on each request (electricity market corrections)
|
|
108
|
+
- Cache is per-column sparse: fetching `geo_ids=[3]` only caches that column
|
|
109
|
+
- Custom exceptions: `ESIOSError`, `AuthenticationError`, `APIResponseError`, `NetworkError`
|
|
127
110
|
|
|
128
|
-
|
|
129
|
-
handle = client.indicators.get(600)
|
|
111
|
+
## CLI Reference (quick lookups)
|
|
130
112
|
|
|
131
|
-
|
|
132
|
-
df = handle.historical("2025-01-01", "2025-01-31")
|
|
113
|
+
### Catalog (offline)
|
|
133
114
|
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
```bash
|
|
116
|
+
esios catalog list indicators # List cataloged indicators
|
|
117
|
+
esios catalog list indicators "precio" # Filter by name
|
|
118
|
+
esios catalog list archives # List cataloged archives
|
|
119
|
+
esios catalog show indicator 600 # Details for indicator
|
|
120
|
+
esios catalog show archive 34 # Details for archive
|
|
121
|
+
esios catalog refresh # Refresh from live API
|
|
122
|
+
esios catalog refresh --dry-run # Preview changes
|
|
123
|
+
```
|
|
136
124
|
|
|
137
|
-
|
|
138
|
-
handle.geos # List of {"geo_id": int, "geo_name": str}
|
|
139
|
-
handle.geos_dataframe() # DataFrame with geo_id and geo_name columns
|
|
140
|
-
handle.resolve_geo("España") # Returns 3
|
|
125
|
+
### Indicators
|
|
141
126
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
127
|
+
```bash
|
|
128
|
+
esios indicators list # List all indicators
|
|
129
|
+
esios indicators search "precio" # Search by name
|
|
130
|
+
esios indicators meta 600 # Show metadata
|
|
131
|
+
esios indicators history 600 -s 2025-01-01 -e 2025-01-31
|
|
132
|
+
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo España
|
|
133
|
+
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --format csv --output data.csv
|
|
145
134
|
```
|
|
146
135
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
### CLI (quickest path)
|
|
136
|
+
### Archives
|
|
150
137
|
|
|
151
138
|
```bash
|
|
152
|
-
#
|
|
153
|
-
esios archives
|
|
139
|
+
esios archives list # List available archives
|
|
140
|
+
esios archives download 34 -s 2025-05-01 -e 2025-05-31 --output ./data
|
|
141
|
+
esios archives sheets 34 --date 2025-06-01 # List sheets in I90 file
|
|
142
|
+
```
|
|
154
143
|
|
|
155
|
-
|
|
156
|
-
# I90DIA03 — Restricciones en el Mercado Diario (curtailment)
|
|
157
|
-
# I90DIA08 — Restricciones en Tiempo Real
|
|
158
|
-
# I90DIA26 — Programa Base de Funcionamiento (PBF, generation program)
|
|
159
|
-
# I90DIA01 — Programa PVP
|
|
160
|
-
# I90DIA07 — Regulación Terciaria (mFRR)
|
|
144
|
+
### Exec (ad-hoc pandas)
|
|
161
145
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
146
|
+
```bash
|
|
147
|
+
# Indicators
|
|
148
|
+
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 -x "df.describe()"
|
|
149
|
+
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 --geo España -x "df.resample('D').mean()"
|
|
150
|
+
esios indicators exec 600 10034 -s 2025-01-01 -e 2025-01-31 -x "df.corr()"
|
|
165
151
|
|
|
166
|
-
#
|
|
152
|
+
# Archives (I90)
|
|
153
|
+
esios archives exec 34 --sheet I90DIA03 --date 2025-06-01 -x "df.groupby('Sentido')['value'].sum()"
|
|
167
154
|
esios archives exec 34 --sheet I90DIA03 -s 2025-05-05 -e 2025-06-08 \
|
|
168
|
-
-x "df[df['Sentido']=='Bajar'].groupby('Unidad de Programación')['value'].sum().sort_values()
|
|
155
|
+
-x "df[df['Sentido']=='Bajar'].groupby('Unidad de Programación')['value'].sum().sort_values()"
|
|
169
156
|
```
|
|
170
157
|
|
|
171
|
-
###
|
|
158
|
+
### Cache management
|
|
172
159
|
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
```bash
|
|
161
|
+
esios cache status # Path, size, registry info
|
|
162
|
+
esios cache geos # Global geo_id → geo_name registry
|
|
163
|
+
esios cache clear # Clear indicator cache
|
|
164
|
+
esios cache clear --all # Clear everything
|
|
165
|
+
esios cache clear --indicator 600 # Clear one indicator
|
|
166
|
+
```
|
|
176
167
|
|
|
177
|
-
|
|
178
|
-
client = ESIOSClient()
|
|
179
|
-
archive = client.archives.get(34)
|
|
180
|
-
books = I90Book.from_archive(archive, start="2025-05-05", end="2025-06-08")
|
|
168
|
+
### Output options
|
|
181
169
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
df = sheet.df # Preprocessed DataFrame with datetime index
|
|
186
|
-
print(sheet.frequency) # "hourly" or "hourly-quarterly"
|
|
170
|
+
```
|
|
171
|
+
--format table|csv|json|parquet (default: table)
|
|
172
|
+
--output file.csv (write to file instead of stdout)
|
|
187
173
|
```
|
|
188
174
|
|
|
189
|
-
##
|
|
190
|
-
|
|
191
|
-
- Data is cached locally as parquet files (`~/.cache/esios/`)
|
|
192
|
-
- Each indicator gets its own directory: `indicators/{id}/data.parquet`
|
|
193
|
-
- Indicator metadata cached in `indicators/{id}/meta.json` (7-day TTL)
|
|
194
|
-
- Indicator catalog cached in `indicators/catalog.json` (24h TTL)
|
|
195
|
-
- Global geo registry at `geos.json` (persisted forever, grows incrementally)
|
|
196
|
-
- Data older than 48h is considered final (won't be re-fetched)
|
|
197
|
-
- Recent data (last 48h) is re-fetched on each request (electricity market corrections)
|
|
198
|
-
- Cache is per-column sparse: fetching `--geo España` only caches that column
|
|
175
|
+
## Configuration
|
|
199
176
|
|
|
200
|
-
|
|
177
|
+
```bash
|
|
178
|
+
esios config set token <API_KEY>
|
|
179
|
+
esios config show
|
|
180
|
+
```
|
|
201
181
|
|
|
202
|
-
|
|
203
|
-
- Date ranges > 3 weeks are auto-chunked into smaller API requests
|
|
204
|
-
- Archives support skip-existing (won't re-download cached files)
|
|
205
|
-
- I90 sheets detect hourly vs quarter-hourly frequency automatically
|
|
206
|
-
- API token resolution: config file (`~/.config/esios/config.toml`) > `ESIOS_API_KEY` env var
|
|
207
|
-
- Custom exceptions: `ESIOSError`, `AuthenticationError`, `APIResponseError`, `NetworkError`
|
|
182
|
+
Config file: `~/.config/esios/config.toml`. API key resolution: config file > `ESIOS_API_KEY` env var.
|