isp-trace-parser 0.1.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.
@@ -0,0 +1,662 @@
1
+ import itertools
2
+ from pathlib import Path
3
+
4
+
5
+ import polars as pl
6
+ import pandas as pd
7
+
8
+
9
+ def solar_project_single_reference_year(
10
+ start_year, end_year, reference_year, project, directory, year_type="fy"
11
+ ):
12
+ """Reads solar project trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
13
+
14
+ Examples:
15
+
16
+ >>> solar_project_single_reference_year(
17
+ ... start_year=2022,
18
+ ... end_year=2024,
19
+ ... reference_year=2011,
20
+ ... project='Adelaide Desalination Plant Solar Farm',
21
+ ... directory='example_parsed_data/solar')
22
+ Datetime Value
23
+ 0 2021-07-01 00:30:00 0.0
24
+ 1 2021-07-01 01:00:00 0.0
25
+ 2 2021-07-01 01:30:00 0.0
26
+ 3 2021-07-01 02:00:00 0.0
27
+ 4 2021-07-01 02:30:00 0.0
28
+ ... ... ...
29
+ 52603 2024-06-30 22:00:00 0.0
30
+ 52604 2024-06-30 22:30:00 0.0
31
+ 52605 2024-06-30 23:00:00 0.0
32
+ 52606 2024-06-30 23:30:00 0.0
33
+ 52607 2024-07-01 00:00:00 0.0
34
+ <BLANKLINE>
35
+ [52608 rows x 2 columns]
36
+
37
+ Args:
38
+ start_year: int, start of time window to return trace data for.
39
+ end_year: int, end of time window (inclusive) to return trace data for.
40
+ reference_year: int, the reference year of the trace data to retrieve.
41
+ project: str, the name of solar project (generator) to return data for. Names should as given in the IASR
42
+ workbook.
43
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
44
+ format as produced by isp_trace_parser.restructure_solar_directory.
45
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
46
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
47
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
48
+
49
+ Returns: pd.DataFrame with columns Datetime andValue
50
+ """
51
+ kwargs = {"project": project}
52
+ return generic_single_reference_year(
53
+ "solar_project",
54
+ start_year,
55
+ end_year,
56
+ reference_year,
57
+ year_type,
58
+ directory,
59
+ **kwargs,
60
+ )
61
+
62
+
63
+ def solar_project_multiple_reference_years(
64
+ reference_years, project, directory, year_type="fy"
65
+ ):
66
+ """Reads solar project trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
67
+
68
+ Examples:
69
+
70
+ >>> solar_project_multiple_reference_years(
71
+ ... reference_years={2022: 2011, 2024: 2012},
72
+ ... project='Adelaide Desalination Plant Solar Farm',
73
+ ... directory='example_parsed_data/solar')
74
+ Datetime Value
75
+ 0 2021-07-01 00:30:00 0.0
76
+ 1 2021-07-01 01:00:00 0.0
77
+ 2 2021-07-01 01:30:00 0.0
78
+ 3 2021-07-01 02:00:00 0.0
79
+ 4 2021-07-01 02:30:00 0.0
80
+ ... ... ...
81
+ 17563 2024-06-30 22:00:00 0.0
82
+ 17564 2024-06-30 22:30:00 0.0
83
+ 17565 2024-06-30 23:00:00 0.0
84
+ 17566 2024-06-30 23:30:00 0.0
85
+ 17567 2024-07-01 00:00:00 0.0
86
+ <BLANKLINE>
87
+ [35088 rows x 2 columns]
88
+
89
+
90
+ Args:
91
+ reference_years: dict{int: int}, a mapping of the which reference year (value) to retrieve data from for
92
+ each financial or calendar year (value).
93
+ project: str, the name of solar project (generator) to return data for. Names should as given in the IASR
94
+ workbook.
95
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
96
+ format as produced by isp_trace_parser.restructure_solar_directory.
97
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
98
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
99
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
100
+
101
+ Returns: pd.DataFrame with columns Datetime andValue
102
+ """
103
+ kwargs = {"project": project}
104
+ return generic_multi_reference_year_mapping(
105
+ "solar_project", reference_years, year_type, directory, **kwargs
106
+ )
107
+
108
+
109
+ def solar_area_single_reference_year(
110
+ start_year, end_year, reference_year, area, technology, directory, year_type="fy"
111
+ ):
112
+ """Reads solar area trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
113
+
114
+ Examples:
115
+
116
+ >>> solar_area_single_reference_year(
117
+ ... start_year=2022,
118
+ ... end_year=2024,
119
+ ... reference_year=2011,
120
+ ... area='Q1',
121
+ ... technology='SAT',
122
+ ... directory='example_parsed_data/solar')
123
+ Datetime Value
124
+ 0 2021-07-01 00:30:00 0.0
125
+ 1 2021-07-01 01:00:00 0.0
126
+ 2 2021-07-01 01:30:00 0.0
127
+ 3 2021-07-01 02:00:00 0.0
128
+ 4 2021-07-01 02:30:00 0.0
129
+ ... ... ...
130
+ 52603 2024-06-30 22:00:00 0.0
131
+ 52604 2024-06-30 22:30:00 0.0
132
+ 52605 2024-06-30 23:00:00 0.0
133
+ 52606 2024-06-30 23:30:00 0.0
134
+ 52607 2024-07-01 00:00:00 0.0
135
+ <BLANKLINE>
136
+ [52608 rows x 2 columns]
137
+
138
+
139
+ Args:
140
+ start_year: int, start of time window to return trace data for.
141
+ end_year: int, end of time window (inclusive) to return trace data for.
142
+ reference_year: int, the reference year of the trace data to retrieve.
143
+ area: str, the ISP code for the area (typically a REZ) to return data for. Codes need to be as given in the IASR
144
+ workbook.
145
+ technology: str, the technology to return trace data for.
146
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
147
+ format as produced by isp_trace_parser.restructure_solar_directory.
148
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
149
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
150
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
151
+
152
+ Returns: pd.DataFrame with columns Datetime andValue
153
+ """
154
+ kwargs = {"area": area, "technology": technology}
155
+ return generic_single_reference_year(
156
+ "solar_area",
157
+ start_year,
158
+ end_year,
159
+ reference_year,
160
+ year_type,
161
+ directory,
162
+ **kwargs,
163
+ )
164
+
165
+
166
+ def solar_area_multiple_reference_years(
167
+ reference_years, area, technology, directory, year_type="fy"
168
+ ):
169
+ """Reads solar area trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
170
+
171
+ Examples:
172
+
173
+ >>> solar_area_multiple_reference_years(
174
+ ... reference_years={2022: 2011, 2024: 2012},
175
+ ... area='Q1',
176
+ ... technology='SAT',
177
+ ... directory='example_parsed_data/solar')
178
+ Datetime Value
179
+ 0 2021-07-01 00:30:00 0.0
180
+ 1 2021-07-01 01:00:00 0.0
181
+ 2 2021-07-01 01:30:00 0.0
182
+ 3 2021-07-01 02:00:00 0.0
183
+ 4 2021-07-01 02:30:00 0.0
184
+ ... ... ...
185
+ 17563 2024-06-30 22:00:00 0.0
186
+ 17564 2024-06-30 22:30:00 0.0
187
+ 17565 2024-06-30 23:00:00 0.0
188
+ 17566 2024-06-30 23:30:00 0.0
189
+ 17567 2024-07-01 00:00:00 0.0
190
+ <BLANKLINE>
191
+ [35088 rows x 2 columns]
192
+
193
+
194
+ Args:
195
+ reference_years: dict{int: int}, a mapping of the which reference year (value) to retrieve data from for
196
+ each financial or calendar year (value).
197
+ area: str, the ISP code for the area (typically a REZ) to return data for. Codes need to be as given in the IASR
198
+ workbook.
199
+ technology: str, the technology to return trace data for.
200
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
201
+ format as produced by isp_trace_parser.restructure_solar_directory.
202
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
203
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
204
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
205
+
206
+ Returns: pd.DataFrame with columns Datetime andValue
207
+ """
208
+ kwargs = {"area": area, "technology": technology}
209
+ return generic_multi_reference_year_mapping(
210
+ "solar_area", reference_years, year_type, directory, **kwargs
211
+ )
212
+
213
+
214
+ def wind_project_single_reference_year(
215
+ start_year, end_year, reference_year, project, directory, year_type="fy"
216
+ ):
217
+ """Reads wind project trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
218
+
219
+ Examples:
220
+
221
+ >>> wind_project_single_reference_year(
222
+ ... start_year=2022,
223
+ ... end_year=2024,
224
+ ... reference_year=2011,
225
+ ... project='Bango 973 Wind Farm',
226
+ ... directory='example_parsed_data/wind')
227
+ Datetime Value
228
+ 0 2021-07-01 00:30:00 0.162167
229
+ 1 2021-07-01 01:00:00 0.153542
230
+ 2 2021-07-01 01:30:00 0.131597
231
+ 3 2021-07-01 02:00:00 0.106550
232
+ 4 2021-07-01 02:30:00 0.086972
233
+ ... ... ...
234
+ 52603 2024-06-30 22:00:00 0.044304
235
+ 52604 2024-06-30 22:30:00 0.046103
236
+ 52605 2024-06-30 23:00:00 0.046103
237
+ 52606 2024-06-30 23:30:00 0.057853
238
+ 52607 2024-07-01 00:00:00 0.076900
239
+ <BLANKLINE>
240
+ [52608 rows x 2 columns]
241
+
242
+
243
+ Args:
244
+ start_year: int, start of time window to return trace data for.
245
+ end_year: int, end of time window (inclusive) to return trace data for.
246
+ reference_year: int, the reference year of the trace data to retrieve.
247
+ project: str, the name of solar project (generator) to return data for. Names should as given in the IASR
248
+ workbook.
249
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
250
+ format as produced by isp_trace_parser.restructure_solar_directory.
251
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
252
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
253
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
254
+
255
+ Returns: pd.DataFrame with columns Datetime andValue
256
+ """
257
+ kwargs = {"project": project}
258
+ return generic_single_reference_year(
259
+ "wind_project",
260
+ start_year,
261
+ end_year,
262
+ reference_year,
263
+ year_type,
264
+ directory,
265
+ **kwargs,
266
+ )
267
+
268
+
269
+ def wind_project_multiple_reference_years(
270
+ reference_years, project, directory, year_type="fy"
271
+ ):
272
+ """Reads wind project trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
273
+
274
+ Examples:
275
+
276
+ >>> wind_project_multiple_reference_years(
277
+ ... reference_years={2022: 2011, 2024: 2012},
278
+ ... project='Bango 973 Wind Farm',
279
+ ... directory='example_parsed_data/wind')
280
+ Datetime Value
281
+ 0 2021-07-01 00:30:00 0.162167
282
+ 1 2021-07-01 01:00:00 0.153542
283
+ 2 2021-07-01 01:30:00 0.131597
284
+ 3 2021-07-01 02:00:00 0.106550
285
+ 4 2021-07-01 02:30:00 0.086972
286
+ ... ... ...
287
+ 17563 2024-06-30 22:00:00 0.932596
288
+ 17564 2024-06-30 22:30:00 0.956507
289
+ 17565 2024-06-30 23:00:00 0.950307
290
+ 17566 2024-06-30 23:30:00 0.958626
291
+ 17567 2024-07-01 00:00:00 0.943996
292
+ <BLANKLINE>
293
+ [35088 rows x 2 columns]
294
+
295
+
296
+ Args:
297
+ reference_years: dict{int: int}, a mapping of the which reference year (value) to retrieve data from for
298
+ each financial or calendar year (value).
299
+ project: str, the name of solar project (generator) to return data for. Names should as given in the IASR
300
+ workbook.
301
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
302
+ format as produced by isp_trace_parser.restructure_solar_directory.
303
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
304
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
305
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
306
+
307
+ Returns: pd.DataFrame with columns Datetime andValue
308
+ """
309
+ kwargs = {"project": project}
310
+ return generic_multi_reference_year_mapping(
311
+ "wind_project", reference_years, year_type, directory, **kwargs
312
+ )
313
+
314
+
315
+ def wind_area_single_reference_year(
316
+ start_year,
317
+ end_year,
318
+ reference_year,
319
+ area,
320
+ resource_quality,
321
+ directory,
322
+ year_type="fy",
323
+ ):
324
+ """Reads wind area trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
325
+
326
+ Examples:
327
+
328
+ >>> wind_area_single_reference_year(
329
+ ... start_year=2022,
330
+ ... end_year=2024,
331
+ ... reference_year=2011,
332
+ ... area='Q1',
333
+ ... resource_quality='WH',
334
+ ... directory='example_parsed_data/wind')
335
+ Datetime Value
336
+ 0 2021-07-01 00:30:00 0.790868
337
+ 1 2021-07-01 01:00:00 0.816555
338
+ 2 2021-07-01 01:30:00 0.762126
339
+ 3 2021-07-01 02:00:00 0.787833
340
+ 4 2021-07-01 02:30:00 0.821139
341
+ ... ... ...
342
+ 52603 2024-06-30 22:00:00 0.842419
343
+ 52604 2024-06-30 22:30:00 0.850748
344
+ 52605 2024-06-30 23:00:00 0.850466
345
+ 52606 2024-06-30 23:30:00 0.853165
346
+ 52607 2024-07-01 00:00:00 0.816184
347
+ <BLANKLINE>
348
+ [52608 rows x 2 columns]
349
+
350
+
351
+ Args:
352
+ start_year: int, start of time window to return trace data for.
353
+ end_year: int, end of time window (inclusive) to return trace data for.
354
+ reference_year: int, the reference year of the trace data to retrieve.
355
+ area: str, the ISP code for the area (typically a REZ) to return data for. Codes need to be as given in the IASR
356
+ workbook.
357
+ resource_quality: str, the resource quality of the trace to retrieve usaual 'WH' or 'WM'.
358
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
359
+ format as produced by isp_trace_parser.restructure_solar_directory.
360
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
361
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
362
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
363
+
364
+ Returns: pd.DataFrame with columns Datetime andValue
365
+ """
366
+ kwargs = {"area": area, "resource_type": resource_quality}
367
+ return generic_single_reference_year(
368
+ "wind_area",
369
+ start_year,
370
+ end_year,
371
+ reference_year,
372
+ year_type,
373
+ directory,
374
+ **kwargs,
375
+ )
376
+
377
+
378
+ def wind_area_multiple_reference_years(
379
+ reference_years, area, resource_quality, directory, year_type="fy"
380
+ ):
381
+ """Reads wind area trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
382
+
383
+ Examples:
384
+
385
+ >>> wind_area_multiple_reference_years(
386
+ ... reference_years={2022: 2011, 2024: 2012},
387
+ ... area='Q1',
388
+ ... resource_quality='WH',
389
+ ... directory='example_parsed_data/wind')
390
+ Datetime Value
391
+ 0 2021-07-01 00:30:00 0.790868
392
+ 1 2021-07-01 01:00:00 0.816555
393
+ 2 2021-07-01 01:30:00 0.762126
394
+ 3 2021-07-01 02:00:00 0.787833
395
+ 4 2021-07-01 02:30:00 0.821139
396
+ ... ... ...
397
+ 17563 2024-06-30 22:00:00 0.500298
398
+ 17564 2024-06-30 22:30:00 0.468695
399
+ 17565 2024-06-30 23:00:00 0.531441
400
+ 17566 2024-06-30 23:30:00 0.548219
401
+ 17567 2024-07-01 00:00:00 0.534083
402
+ <BLANKLINE>
403
+ [35088 rows x 2 columns]
404
+
405
+
406
+ Args:
407
+ reference_years: dict{int: int}, a mapping of the which reference year (value) to retrieve data from for
408
+ each financial or calendar year (value).
409
+ area: str, the ISP code for the area (typically a REZ) to return data for. Codes need to be as given in the IASR
410
+ workbook.
411
+ resource_quality: str, the resource quality of the trace to retrieve usaual 'WH' or 'WM'.
412
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
413
+ format as produced by isp_trace_parser.restructure_solar_directory.
414
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
415
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
416
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
417
+
418
+ Returns: pd.DataFrame with columns Datetime andValue
419
+ """
420
+ kwargs = {"area": area, "resource_type": resource_quality}
421
+ return generic_multi_reference_year_mapping(
422
+ "wind_area", reference_years, year_type, directory, **kwargs
423
+ )
424
+
425
+
426
+ def demand_single_reference_year(
427
+ start_year,
428
+ end_year,
429
+ reference_year,
430
+ subregion,
431
+ scenario,
432
+ poe,
433
+ descriptor,
434
+ directory,
435
+ year_type="fy",
436
+ ):
437
+ """Reads demand trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
438
+
439
+ Examples:
440
+
441
+ >>> demand_single_reference_year(
442
+ ... start_year=2024,
443
+ ... end_year=2024,
444
+ ... reference_year=2011,
445
+ ... subregion='CNSW',
446
+ ... scenario='Green Energy Exports',
447
+ ... poe='POE10',
448
+ ... descriptor='OPSO_MODELLING',
449
+ ... directory='example_parsed_data/demand')
450
+ Datetime Value
451
+ 0 2023-07-01 00:30:00 1021.534634
452
+ 1 2023-07-01 01:00:00 997.293145
453
+ 2 2023-07-01 01:30:00 971.978426
454
+ 3 2023-07-01 02:00:00 942.272701
455
+ 4 2023-07-01 02:30:00 899.031012
456
+ ... ... ...
457
+ 17563 2024-06-30 22:00:00 1042.242398
458
+ 17564 2024-06-30 22:30:00 1028.134356
459
+ 17565 2024-06-30 23:00:00 996.066288
460
+ 17566 2024-06-30 23:30:00 968.414059
461
+ 17567 2024-07-01 00:00:00 945.461810
462
+ <BLANKLINE>
463
+ [17568 rows x 2 columns]
464
+
465
+
466
+ Args:
467
+ start_year: int, start of time window to return trace data for.
468
+ end_year: int, end of time window (inclusive) to return trace data for.
469
+ reference_year: int, the reference year of the trace data to retrieve.
470
+ subregion: str, the ISP ID for the subregion to return data for. ID need to be as given in the IASR
471
+ workbook.
472
+ scenario: str, the scenario to return data for.
473
+ poe: str, the poe level to return data for.
474
+ descriptor: str, the type of demand data to return.
475
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
476
+ format as produced by isp_trace_parser.restructure_solar_directory.
477
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
478
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
479
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
480
+
481
+ Returns: pd.DataFrame with columns Datetime andValue
482
+ """
483
+ kwargs = {
484
+ "area": subregion,
485
+ "scenario": scenario,
486
+ "poe": poe,
487
+ "descriptor": descriptor,
488
+ }
489
+ return generic_single_reference_year(
490
+ "demand", start_year, end_year, reference_year, year_type, directory, **kwargs
491
+ )
492
+
493
+
494
+ def demand_multiple_reference_years(
495
+ reference_years, subregion, scenario, poe, descriptor, directory, year_type="fy"
496
+ ):
497
+ """Reads wind area trace data from an output directory created by isp_trace_parser.restructure_solar_directory.
498
+
499
+ Examples:
500
+
501
+ >>> demand_multiple_reference_years(
502
+ ... reference_years={2024: 2011},
503
+ ... subregion='CNSW',
504
+ ... scenario='Green Energy Exports',
505
+ ... poe='POE10',
506
+ ... descriptor='OPSO_MODELLING',
507
+ ... directory='example_parsed_data/demand')
508
+ Datetime Value
509
+ 0 2023-07-01 00:30:00 1021.534634
510
+ 1 2023-07-01 01:00:00 997.293145
511
+ 2 2023-07-01 01:30:00 971.978426
512
+ 3 2023-07-01 02:00:00 942.272701
513
+ 4 2023-07-01 02:30:00 899.031012
514
+ ... ... ...
515
+ 17563 2024-06-30 22:00:00 1042.242398
516
+ 17564 2024-06-30 22:30:00 1028.134356
517
+ 17565 2024-06-30 23:00:00 996.066288
518
+ 17566 2024-06-30 23:30:00 968.414059
519
+ 17567 2024-07-01 00:00:00 945.461810
520
+ <BLANKLINE>
521
+ [17568 rows x 2 columns]
522
+
523
+
524
+ Args:
525
+ reference_years: dict{int: int}, a mapping of the which reference year (value) to retrieve data from for
526
+ each financial or calendar year (value).
527
+ subregion: str, the ISP ID for the subregion to return data for. ID need to be as given in the IASR
528
+ workbook.
529
+ scenario: str, the scenario to return data for.
530
+ poe: str, the poe level to return data for.
531
+ descriptor: str, the type of demand data to return.
532
+ directory: str or pathlib.Path, the directory were the trace data is stored. Trace data needs to be in the
533
+ format as produced by isp_trace_parser.restructure_solar_directory.
534
+ year_type: str, 'fy' or 'calendar', if 'fy' then time filtering is by financial year with start_year and
535
+ end_year specifiying the financial year to return data for, using year ending nomenclature (2016 ->
536
+ FY2015/2016). If 'calendar', then filtering is by calendar year.
537
+
538
+ Returns: pd.DataFrame with columns Datetime andValue
539
+ """
540
+ kwargs = {
541
+ "area": subregion,
542
+ "scenario": scenario,
543
+ "poe": poe,
544
+ "descriptor": descriptor,
545
+ }
546
+ return generic_multi_reference_year_mapping(
547
+ "demand", reference_years, year_type, directory, **kwargs
548
+ )
549
+
550
+
551
+ def get_years_and_half_years(start_year, end_year, year_type):
552
+ if year_type == "calendar":
553
+ years = range(start_year, end_year + 1)
554
+ half_years = [1, 2]
555
+ years_and_half_years = itertools.product(years, half_years)
556
+ elif year_type == "fy":
557
+ years = range(start_year - 1, end_year + 1)
558
+ half_years = [1, 2]
559
+ years_and_half_years = list(itertools.product(years, half_years))[1:-1]
560
+ else:
561
+ raise ValueError(f"The year_type {year_type} is not recognised.")
562
+ return years_and_half_years
563
+
564
+
565
+ def generic_multi_reference_year_mapping(
566
+ data_type, reference_year_mapping, year_type, directory, **kwargs
567
+ ):
568
+ data = []
569
+ for year, reference_year in reference_year_mapping.items():
570
+ data.append(
571
+ generic_single_reference_year(
572
+ data_type, year, year, reference_year, year_type, directory, **kwargs
573
+ )
574
+ )
575
+ data = pd.concat(data)
576
+ return data
577
+
578
+
579
+ def generic_single_reference_year(
580
+ data_type, start_year, end_year, reference_year, year_type, directory, **kwargs
581
+ ):
582
+ years_and_half_years = get_years_and_half_years(start_year, end_year, year_type)
583
+ data = []
584
+ for i, (year, half_year) in enumerate(years_and_half_years):
585
+ filepath_args = {
586
+ "year": year,
587
+ "half_year": half_year,
588
+ "reference_year": reference_year,
589
+ "directory": directory,
590
+ }
591
+ filepath_args.update(kwargs)
592
+ filepath = filepath_writers[data_type](**filepath_args)
593
+ data.append(pl.read_parquet(filepath))
594
+ data = pl.concat(data)
595
+ return data.to_pandas()
596
+
597
+
598
+ def get_solar_project_filepath(year, half_year, reference_year, directory, project):
599
+ filepath_template = "RefYear{ry}/Project/{project}/RefYear{ry}_{project}_FFP_HalfYear{y}-{hy}.parquet"
600
+ project = project.replace(" ", "_").replace("*", "")
601
+ return Path(directory) / filepath_template.format(
602
+ ry=reference_year, project=project, y=year, hy=half_year
603
+ )
604
+
605
+
606
+ def get_solar_area_filepath(
607
+ year, half_year, reference_year, directory, area, technology
608
+ ):
609
+ filepath_template = "RefYear{ry}/Area/{area}/{tech}/RefYear{ry}_{area}_{tech}_HalfYear{y}-{hy}.parquet"
610
+ return Path(directory) / filepath_template.format(
611
+ ry=reference_year, area=area, y=year, hy=half_year, tech=technology
612
+ )
613
+
614
+
615
+ def get_wind_project_filepath(year, half_year, reference_year, directory, project):
616
+ filepath_template = (
617
+ "RefYear{ry}/Project/{project}/RefYear{ry}_{project}_HalfYear{y}-{hy}.parquet"
618
+ )
619
+ project = project.replace(" ", "_").replace("*", "")
620
+ return Path(directory) / filepath_template.format(
621
+ ry=reference_year, project=project, y=year, hy=half_year
622
+ )
623
+
624
+
625
+ def get_wind_area_filepath(
626
+ year, half_year, reference_year, directory, area, resource_type
627
+ ):
628
+ filepath_template = (
629
+ "RefYear{ry}/Area/{area}/{resource_type}/"
630
+ "RefYear{ry}_{area}_{resource_type}_HalfYear{y}-{hy}.parquet"
631
+ )
632
+ return Path(directory) / filepath_template.format(
633
+ ry=reference_year, area=area, y=year, hy=half_year, resource_type=resource_type
634
+ )
635
+
636
+
637
+ def get_demand_file_path(
638
+ year, half_year, reference_year, directory, area, scenario, poe, descriptor
639
+ ):
640
+ scenario = scenario.replace(" ", "_")
641
+ filepath_template = (
642
+ "{scenario}/RefYear{ry}/{area}/{poe}/{descriptor}/"
643
+ "{scenario}_RefYear{ry}_{area}_{poe}_{descriptor}_HalfYear{y}-{hy}.parquet"
644
+ )
645
+ return Path(directory) / filepath_template.format(
646
+ ry=reference_year,
647
+ area=area,
648
+ y=year,
649
+ hy=half_year,
650
+ scenario=scenario,
651
+ poe=poe,
652
+ descriptor=descriptor,
653
+ )
654
+
655
+
656
+ filepath_writers = {
657
+ "solar_project": get_solar_project_filepath,
658
+ "solar_area": get_solar_area_filepath,
659
+ "wind_project": get_wind_project_filepath,
660
+ "wind_area": get_wind_area_filepath,
661
+ "demand": get_demand_file_path,
662
+ }