Skip to content

Commit 082aa9f

Browse files
committed
Historic frequency data for Jan21-Jan22
1 parent a81d20a commit 082aa9f

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ r: bytes = client.query(date_col=date_col, start_date=start_date, end_date=end_d
3434
* `day-ahead-wind-forecast`
3535
* `demand-data-update`
3636
* `dc-results-summary`
37+
* `historic-frequency-data` [Jan21-Jan22]
3738

3839
### Download of files
3940
* `historic-generation-mix`

pyngeso/resources.py

+53-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,59 @@
3232
"dc-results-summary": {
3333
"id": "888e5029-f786-41d2-bc15-cbfd1d285e96",
3434
"url": "https://data.nationalgrideso.com/ancillary-services/dynamic-containment-data/r/dc_results_summary_master_data_2021-2022"
35-
}
35+
},
36+
"historic-frequency-data-jan22": {
37+
"id": "43000c20-1208-4ca7-a419-712c7a1d375c",
38+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/january_2022_-_historic_frequency_data"
39+
},
40+
"historic-frequency-data-dec21": {
41+
"id": "afe9895c-5937-4e78-8949-f0f026643666",
42+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/december_2021_-_historic_frequency_data"
43+
},
44+
"historic-frequency-data-nov21": {
45+
"id": "9bc4746e-3152-4c6f-886e-58377ab88e0e",
46+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/november_2021_-_historic_frequency_data"
47+
},
48+
"historic-frequency-data-oct21": {
49+
"id": "12291f14-95c3-4847-b2ef-3190eaa1193c",
50+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/october_2021_-_historic_frequency_data"
51+
},
52+
"historic-frequency-data-sep21": {
53+
"id": "5cea7516-cbc3-416e-8dbf-162327c16b17",
54+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/september_2021_-_historic_frequency_data"
55+
},
56+
"historic-frequency-data-aug21": {
57+
"id": "ae40912b-de8f-43b1-8eeb-c58e469f2365",
58+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/august_2021_-_historic_frequency_data"
59+
},
60+
"historic-frequency-data-jul21": {
61+
"id": "94d95251-ccbb-4187-ae54-1b90ebf12b9f",
62+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/july_2021_-_historic_frequency_data"
63+
},
64+
"historic-frequency-data-jun21": {
65+
"id": "bd754692-bce7-43b7-ba25-813921476391",
66+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/june_2021_-_historic_frequency_data"
67+
},
68+
"historic-frequency-data-may21": {
69+
"id": "625597eb-7364-4ba8-a306-a7f59dcdc2a7",
70+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/may_2021_-_historic_frequency_data"
71+
},
72+
"historic-frequency-data-apr21": {
73+
"id": "bd6e1b3f-1abb-452c-813c-397a41f7af8d",
74+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/april_2021_-_historic_frequency_data"
75+
},
76+
"historic-frequency-data-mar21": {
77+
"id": "ac4e4031-0f86-48ff-8ecd-147d51ffbb81",
78+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/march_2021_-_historic_frequency_data"
79+
},
80+
"historic-frequency-data-feb21": {
81+
"id": "53e2be31-c68c-40b3-bb83-7ae12240107c",
82+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/february_2021_-_historic_frequency_data"
83+
},
84+
"historic-frequency-data-jan21": {
85+
"id": "fe2502b8-7fef-4027-8399-550a0c84f415",
86+
"url": "https://data.nationalgrideso.com/system/system-frequency-data/r/january_2021_-_historic_frequency_data"
87+
},
3688
}
3789

3890
file_resource_ids: Dict[str, Dict[str, str]] = {

tests/test_pyngeso.py

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
import logging
23
import json
34
import csv
@@ -147,3 +148,40 @@ def test_dc_results_summary():
147148
unique_target_dates = set([record.get(date_col) for record in records])
148149
assert len(unique_target_dates) == 1
149150
assert len(records) == 6
151+
152+
153+
@pytest.mark.vcr
154+
@pytest.mark.parametrize(
155+
"month, year",
156+
[
157+
("jan", 2022),
158+
("jan", 2021),
159+
("feb", 2021),
160+
("mar", 2021),
161+
("apr", 2021),
162+
("may", 2021),
163+
("jun", 2021),
164+
("jul", 2021),
165+
("aug", 2021),
166+
("sep", 2021),
167+
("oct", 2021),
168+
("nov", 2021),
169+
("dec", 2021),
170+
],
171+
)
172+
def test_historic_frequency_data(month: str, year: int):
173+
date_col = "dtm"
174+
start_date = datetime.strptime(f"{month} {year}", "%b %Y").strftime("%Y-%m-%d")
175+
client = NgEso(f"historic-frequency-data-{month}{str(year)[-2:]}")
176+
r = client.query(date_col=date_col, start_date=start_date, end_date=start_date)
177+
178+
assert isinstance(r, bytes)
179+
r_dict = json.loads(r)
180+
records = r_dict.get("result").get("records")
181+
assert isinstance(records, list)
182+
assert len(records) > 0
183+
unique_target_dates = set([record.get(date_col) for record in records])
184+
assert len(unique_target_dates) == 1
185+
assert len(records) == 1
186+
fetched_year = int(records[0].get(date_col)[:4])
187+
assert fetched_year == year

0 commit comments

Comments
 (0)