isp-trace-parser 0.1.0__tar.gz → 1.0.0__tar.gz

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.
Files changed (38) hide show
  1. isp_trace_parser-1.0.0/PKG-INFO +648 -0
  2. isp_trace_parser-1.0.0/README.md +635 -0
  3. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/pyproject.toml +4 -1
  4. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_name_mapping_configs/solar_project_mapping.yaml +1 -1
  5. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/__init__.py +6 -3
  6. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/construct_reference_year_mapping.py +11 -2
  7. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/demand_traces.py +134 -26
  8. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/get_data.py +335 -135
  9. isp_trace_parser-1.0.0/src/isp_trace_parser/input_validation.py +24 -0
  10. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/metadata_extractors.py +12 -6
  11. isp_trace_parser-1.0.0/src/isp_trace_parser/solar_traces.py +330 -0
  12. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser/trace_formatter.py +4 -1
  13. isp_trace_parser-1.0.0/src/isp_trace_parser/trace_restructure_helper_functions.py +175 -0
  14. isp_trace_parser-1.0.0/src/isp_trace_parser/wind_traces.py +378 -0
  15. isp_trace_parser-1.0.0/src/isp_trace_parser.egg-info/PKG-INFO +648 -0
  16. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser.egg-info/SOURCES.txt +2 -1
  17. isp_trace_parser-1.0.0/src/isp_trace_parser.egg-info/requires.txt +4 -0
  18. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/tests/test_directory_restructure.py +13 -5
  19. isp_trace_parser-1.0.0/tests/test_input_validation.py +258 -0
  20. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/tests/test_trace_file_meta_data_extraction.py +9 -9
  21. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/tests/test_writing_save_names.py +7 -7
  22. isp_trace_parser-0.1.0/PKG-INFO +0 -147
  23. isp_trace_parser-0.1.0/README.md +0 -136
  24. isp_trace_parser-0.1.0/src/isp_trace_parser/generator_to_trace_draft_mapper.py +0 -144
  25. isp_trace_parser-0.1.0/src/isp_trace_parser/solar_traces.py +0 -153
  26. isp_trace_parser-0.1.0/src/isp_trace_parser/trace_restructure_helper_functions.py +0 -145
  27. isp_trace_parser-0.1.0/src/isp_trace_parser/wind_traces.py +0 -216
  28. isp_trace_parser-0.1.0/src/isp_trace_parser.egg-info/PKG-INFO +0 -147
  29. isp_trace_parser-0.1.0/src/isp_trace_parser.egg-info/requires.txt +0 -2
  30. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/LICENSE +0 -0
  31. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/setup.cfg +0 -0
  32. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_name_mapping_configs/demand_scenario_mapping.yaml +0 -0
  33. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_name_mapping_configs/solar_area_mapping.yaml +0 -0
  34. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_name_mapping_configs/wind_area_mapping.yaml +0 -0
  35. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_name_mapping_configs/wind_project_mapping.yaml +0 -0
  36. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser.egg-info/dependency_links.txt +0 -0
  37. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/src/isp_trace_parser.egg-info/top_level.txt +0 -0
  38. {isp_trace_parser-0.1.0 → isp_trace_parser-1.0.0}/tests/test_trace_formatter.py +0 -0
@@ -0,0 +1,648 @@
1
+ Metadata-Version: 2.1
2
+ Name: isp-trace-parser
3
+ Version: 1.0.0
4
+ Summary: A Python package for reformatting and accessing demand, solar, and wind time series data used by the
5
+ Author-email: nick-gorman <n.gorman305@gmail.com>, prakaa <abiprakash007@gmail.com>, dylanjmcconnell <dylan.mcconnell@unsw.edu.au>
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: polars>=1.7.1
10
+ Requires-Dist: pandas>=2.2.2
11
+ Requires-Dist: pydantic>=2.9.2
12
+ Requires-Dist: joblib>=1.4.2
13
+
14
+ # AEMO Integrated System Plan Trace Parser
15
+
16
+ [![PyPI version](https://badge.fury.io/py/isp-trace-parser.svg)](https://badge.fury.io/py/isp-trace-parser)
17
+ [![Continuous Integration and Deployment](https://github.com/Open-ISP/isp-trace-parser/actions/workflows/cicd.yml/badge.svg)](https://github.com/Open-ISP/isp-trace-parser/actions/workflows/cicd.yml)
18
+ [![codecov](https://codecov.io/gh/Open-ISP/isp-trace-parser/graph/badge.svg?token=HLRLX78WHP)](https://codecov.io/gh/Open-ISP/isp-trace-parser)
19
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Open-ISP/isp-trace-parser/main.svg)](https://results.pre-commit.ci/latest/github/Open-ISP/isp-trace-parser/main)
20
+ [![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye.astral.sh)
21
+
22
+ A Python package for reformatting and accessing demand, solar generation and wind generation time series data used by the Australian Energy
23
+ Market Operator (AEMO) in their Integrated System Plan (ISP) modelling study.
24
+
25
+ > [!IMPORTANT]
26
+ > Currently, `isp-trace-parser` only supports trace data in the format of the 2024 ISP.
27
+
28
+ ## Table of contents
29
+
30
+ - [Install](#install)
31
+ - [How the package works](#how-the-package-works)
32
+ - [Accessing raw trace data](#accessing-raw-trace-data)
33
+ - [Key terminology](#key-terminology)
34
+ - [Examples](#examples)
35
+ - [Parsing trace data](#parsing-trace-data)
36
+ - [Querying parsed trace data](#querying-parsed-trace-data)
37
+ - [Querying trace data for a sets of generators, areas or subregions](#querying-trace-data-for-a-sets-of-generators-areas-or-subregions)
38
+ - [Constructing reference year mapping](#constructing-reference-year-mapping)
39
+ - [Dataframe trace parsing](#dataframe-trace-parsing)
40
+ - [Contributing](#contributing)
41
+ - [License](#license)
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install isp-trace-parser
47
+ ```
48
+
49
+ ## How the package works
50
+
51
+ 1. Parse raw AEMO trace data using the functions `parse_wind_traces`, `parse_solar_traces`, and
52
+ `parse_demand_traces`.
53
+ - These functions reformat and restructure the data to a specified directory.
54
+ - *Reformatting* puts the data in a standard time series format (i.e. with a `Datetime` column and `Values` column).
55
+ - The data is *restructured* into half-yearly chunks in [Parquet](https://parquet.apache.org/) files, which significantly improves the speed at which data can be read from disk.
56
+ - To access the full documentation for these functions, you can run `help` in the Python console, e.g. `help(parse_wind_traces)`.
57
+
58
+ 2. Query the parsed data using the naming conventions for generators, renewable energy zones (REZs), and subregions established in the
59
+ AEMO Inputs and Assumptions workbook (see [`isp-workbook-parser`](https://github.com/Open-ISP/isp-workbook-parser)) using the `get_data` functions
60
+ - Refer to the [Querying parsed trace data example](https://github.com/Open-ISP/isp-trace-parser#querying-parsed-trace-data).
61
+ - To access the full documentation for these functions, you can run `help` in the Python console, e.g.
62
+ `help(get_data.solar_project_trace_single_reference_year)`.
63
+
64
+ ## Accessing raw trace data
65
+
66
+ Currently, AEMO trace data needs to be downloaded from the [AEMO website](https://aemo.com.au/en/energy-systems/major-publications/integrated-system-plan-isp/2024-integrated-system-plan-isp)
67
+ and unzipped manually before the trace parser can be used.
68
+
69
+ > [!Note]
70
+ > However, it is likely future versions of the trace parser will automate this process by using a third party platform to host the trace data.
71
+
72
+ ## Key terminology
73
+
74
+ ### Solar/wind
75
+
76
+ - _**Project**_: Traces for a specific solar/wind project
77
+ - _**Area**_: Traces for an area, e.g. a renewable energy zone
78
+ - _**Reference year**_: A historical weather year that is used to produce the generation trace.
79
+ - Modelled years are mapped to reference years, e.g. generation data for one or multiple years can be mapped to a single reference year, or generation data for each year can be mapped to different reference years (refer to the [Querying parsed trace data example](https://github.com/Open-ISP/isp-trace-parser#querying-parsed-trace-data)).
80
+ - _**Technology**_ (solar): Fixed flat plate (FFP), single-axis tracking (SAT), concentrated solar thermal (CST).
81
+ - _**Resource quality**_ (wind):
82
+ - Onshore wind: Wind High (WH) and Wind Low (WL)
83
+ - Offshore wind: Wind Offshore Fixed (WFX) and Wind Offshore Floating (WFL)
84
+
85
+ ### Demand
86
+ - _**Reference year**_: A historical weather year that is used to produce the demand trace.
87
+ - Modelled years are mapped to reference years, e.g. demand data for one or multiple years can be mapped to a single reference year, or demand data for each year can be mapped to different reference years (refer to the [Querying parsed trace data example](https://github.com/Open-ISP/isp-trace-parser#querying-parsed-trace-data)).
88
+ - _**Subregion**_: ISP subregion (refer to the [ISP methodology](https://aemo.com.au/-/media/files/stakeholder_consultation/consultations/nem-consultations/2023/isp-methodology-2023/isp-methodology_june-2023.pdf?la=en))
89
+ - _**Scenario**_: ISP scenario (refer to the [ISP methodology](https://aemo.com.au/-/media/files/stakeholder_consultation/consultations/nem-consultations/2023/isp-methodology-2023/isp-methodology_june-2023.pdf?la=en))
90
+ - _**POE**_: Probability of exceedance (refer to [AEMO Demand Terms documentation](https://aemo.com.au/-/media/Files/Electricity/NEM/Security_and_Reliability/Dispatch/Policy_and_Process/Demand-terms-in-EMMS-Data-Model.pdf)). Generally either POE10 or POE50.
91
+ - _**Demand type**_: `OPSO_MODELLING`, `OPSO_MODELLING_PVLITE` or `PV_TOT`. Refer to [this ESOO document](https://aemo.com.au/-/media/files/electricity/nem/planning_and_forecasting/nem_esoo/2024/model-instructions-2024-esoo.pdf?la=en) for a description of each.
92
+
93
+ ## Examples
94
+
95
+ ### Parsing trace data
96
+
97
+ If AEMO trace data is downloaded onto a local machine, it can be reformatted using `isp_trace_parser`.
98
+
99
+ To perform the reformatting and restructuring, the solar, wind and demand data should each be stored in separate directories (though no exact directory structure within the solar, wind and demand subdirectories needs to be followed).
100
+
101
+ The following code can then be used to parse the data:
102
+
103
+ ### Parsing all files in a directory
104
+
105
+ ```python
106
+ from isp_trace_parser import parse_solar_traces, parse_wind_traces, parse_demand_traces
107
+
108
+ parse_solar_traces(
109
+ input_directory='<path/to/aemo/solar/traces>',
110
+ parsed_directory='<path/to/store/solar/output>',
111
+ )
112
+
113
+ parse_wind_traces(
114
+ input_directory='<path/to/aemo/wind/traces>',
115
+ parsed_directory='<path/to/store/wind/output>',
116
+ )
117
+
118
+ parse_demand_traces(
119
+ input_directory='<path/to/aemo/demand/traces>',
120
+ parsed_directory='<path/to/store/demand/output>',
121
+ )
122
+ ```
123
+
124
+ ### Filtering which files get parsed
125
+
126
+ ```python
127
+ from isp_trace_parser import (
128
+ parse_solar_traces,
129
+ SolarMetadataFilter,
130
+ parse_wind_traces,
131
+ WindMetadataFilter,
132
+ parse_demand_traces,
133
+ DemandMetadataFilter
134
+ )
135
+
136
+ # Note: to not filter on a component of the metadata it can be excluded from the filter definition.
137
+
138
+ solar_filters = SolarMetadataFilter(
139
+ name=['N1'],
140
+ file_type=['area'],
141
+ technology=['SAT'],
142
+ reference_year=[2011]
143
+ )
144
+
145
+ parse_solar_traces(
146
+ input_directory='<path/to/aemo/solar/traces>',
147
+ parsed_directory='<path/to/store/solar/output>',
148
+ filters=solar_filters
149
+ )
150
+
151
+ wind_filters = WindMetadataFilter(
152
+ name=['N1'],
153
+ file_type=['area'],
154
+ resouce_quality=['WH'],
155
+ reference_year=[2011]
156
+ )
157
+
158
+ parse_wind_traces(
159
+ input_directory='<path/to/aemo/wind/traces>',
160
+ parsed_directory='<path/to/store/wind/output>',
161
+ filters=wind_filters
162
+ )
163
+
164
+ demand_filters = DemandMetadataFilter(
165
+ scenario=['Green Energy Exports'],
166
+ subregion=['CNSW'],
167
+ poe=['POE50'],
168
+ demand_type=['OPSO_MODELLING'],
169
+ reference_year=[2011]
170
+ )
171
+
172
+ parse_demand_traces(
173
+ input_directory='<path/to/aemo/demand/traces>',
174
+ parsed_directory='<path/to/store/demand/output>',
175
+ filters=demand_filters
176
+ )
177
+ ```
178
+
179
+ ### Querying parsed trace data
180
+
181
+ Once trace data has been parsed it can be queried using the following API functionality.
182
+
183
+ <details>
184
+ <summary>Solar project traces from 2022 to 2024 (for a single reference year), and for 2022 and 2024 (multiple reference years)</summary>
185
+ <br>
186
+
187
+ ```python
188
+ from isp_trace_parser import get_data
189
+
190
+ solar_project_trace_single_reference_year = get_data.solar_project_single_reference_year(
191
+ start_year=2022,
192
+ end_year=2024,
193
+ reference_year=2011,
194
+ project='Adelaide Desalination Plant Solar Farm',
195
+ directory='example_parsed_data/solar'
196
+ )
197
+
198
+ solar_project_trace_many_reference_years = get_data.solar_project_multiple_reference_years(
199
+ reference_years={2022: 2011, 2024: 2012},
200
+ project='Adelaide Desalination Plant Solar Farm',
201
+ directory='example_parsed_data/solar'
202
+ )
203
+ ```
204
+
205
+ </details>
206
+
207
+ <details>
208
+ <summary>Solar area/REZ traces from 2022 to 2024 (for a single reference year), and for 2022 and 2024 (multiple reference years)</summary>
209
+ <br>
210
+
211
+ ```python
212
+ from isp_trace_parser import get_data
213
+ solar_rez_trace_single_reference_years = get_data.solar_area_single_reference_year(
214
+ start_year=2022,
215
+ end_year=2024,
216
+ reference_year=2011,
217
+ area='Q1',
218
+ technology='SAT',
219
+ directory='example_parsed_data/solar'
220
+ )
221
+
222
+ solar_rez_trace_many_reference_years = get_data.solar_area_multiple_reference_years(
223
+ reference_years={2022: 2011, 2024: 2012},
224
+ area='Q1',
225
+ technology='SAT',
226
+ directory='example_parsed_data/solar'
227
+ )
228
+ ```
229
+
230
+ </details>
231
+
232
+ <details>
233
+ <summary>Wind project traces from 2022 to 2024 (for a single reference year), and for 2022 and 2024 (multiple reference years)</summary>
234
+ <br>
235
+
236
+ ```python
237
+ from isp_trace_parser import get_data
238
+ wind_project_trace_single_reference_years = get_data.wind_project_single_reference_year(
239
+ start_year=2022,
240
+ end_year=2024,
241
+ reference_year=2011,
242
+ project='Bango 973 Wind Farm',
243
+ directory='example_parsed_data/wind'
244
+ )
245
+
246
+ wind_project_trace_many_reference_years = get_data.wind_project_multiple_reference_years(
247
+ reference_years={2022: 2011, 2024: 2012},
248
+ project='Bango 973 Wind Farm',
249
+ directory='example_parsed_data/wind'
250
+ )
251
+ ```
252
+
253
+ </details>
254
+
255
+ <details>
256
+ <summary>Wind area/REZ traces from 2022 to 2024 (for a single reference year), and for 2022 and 2024 (multiple reference years)</summary>
257
+ <br>
258
+
259
+ ```python
260
+ from isp_trace_parser import get_data
261
+ wind_rez_trace_single_reference_years = get_data.wind_area_single_reference_year(
262
+ start_year=2022,
263
+ end_year=2024,
264
+ reference_year=2011,
265
+ area='Q1',
266
+ resource_quality='WH',
267
+ directory='example_parsed_data/wind'
268
+ )
269
+
270
+ wind_rez_trace_many_reference_years = get_data.wind_area_multiple_reference_years(
271
+ reference_years={2022: 2011, 2024: 2012},
272
+ area='Q1',
273
+ resource_quality='WH',
274
+ directory='example_parsed_data/wind'
275
+ )
276
+ ```
277
+
278
+ </details>
279
+
280
+ <details>
281
+ <summary>OPSO_MODELLING POE10 traces from 2022 to 2024 (for a single reference year), and for 2024 (multiple reference years) from the "Green Energy Exports" scenario</summary>
282
+ <br>
283
+
284
+ ```python
285
+ from isp_trace_parser import get_data
286
+ demand_subregion_trace_single_reference_years = get_data.demand_single_reference_year(
287
+ start_year=2024,
288
+ end_year=2024,
289
+ reference_year=2011,
290
+ subregion='CNSW',
291
+ scenario='Green Energy Exports',
292
+ poe='POE10',
293
+ demand_type='OPSO_MODELLING',
294
+ directory='example_parsed_data/demand'
295
+ )
296
+
297
+ demand_subregion_trace_many_reference_years = get_data.demand_multiple_reference_years(
298
+ reference_years={2024: 2011},
299
+ subregion='CNSW',
300
+ scenario='Green Energy Exports',
301
+ poe='POE10',
302
+ demand_type='OPSO_MODELLING',
303
+ directory='example_parsed_data/demand'
304
+ )
305
+
306
+ ```
307
+
308
+ </details>
309
+
310
+ ### Querying trace data for a sets of generators, areas or subregions
311
+
312
+ Often modelling or analysis will require a set of traces. For example, all the existing solar generators traces, all
313
+ the wind REZ traces, or all the subregion demand traces. To query a set of traces the names of generators, REZ IDs,
314
+ or subregion IDs can be retrieved from the IASR workbook using the
315
+ [isp-workbook-parser](https://github.com/Open-ISP/isp-workbook-parser). Using isp-workbook-parser the workbook data can
316
+ be exported to CSVs, and then required names, REZ IDs, or subregion IDs extracted, as shown below:
317
+
318
+ <details>
319
+ <summary>Wind and solar project traces</summary>
320
+ <br>
321
+
322
+ ```python
323
+ from pathlib import Path
324
+
325
+ import pandas as pd
326
+ from isp_trace_parser import get_data
327
+
328
+
329
+ # Define location of parsed data.
330
+
331
+ parsed_workbook_data = Path(
332
+ "/path/to/parsed/workbook/data"
333
+ )
334
+
335
+ parsed_solar_data = Path('path/to/parsed/solar/traces')
336
+
337
+ # Wind and solar generator names are stored across four IASR workbook tables
338
+
339
+ existing_generators = pd.read_csv(
340
+ parsed_workbook_data / Path("existing_generator_summary.csv")
341
+ )
342
+
343
+ committed_generators = pd.read_csv(
344
+ parsed_workbook_data / Path("committed_generator_summary.csv")
345
+ )
346
+
347
+ anticipated_generators = pd.read_csv(
348
+ parsed_workbook_data / Path("anticipated_projects_summary.csv")
349
+ )
350
+
351
+ additional_generators = pd.read_csv(
352
+ parsed_workbook_data / Path("additional_projects_summary.csv")
353
+ )
354
+
355
+
356
+ # Before combining the data tables we need to standardise the generator name column
357
+
358
+ generator_tables = [
359
+ existing_generators,
360
+ committed_generators,
361
+ anticipated_generators,
362
+ additional_generators
363
+ ]
364
+
365
+ for table in generator_tables:
366
+ table.rename(
367
+ columns={table.columns.values[0]: "Generator"},
368
+ inplace=True
369
+ )
370
+
371
+ generator_data = pd.concat(generator_tables)
372
+
373
+
374
+ # The names of solar and wind projects/generators can be retrieved by filtering
375
+
376
+ solar_generators = generator_data[generator_data['Technology type'] == 'Large scale Solar PV']
377
+
378
+ solar_generator_names = list(solar_generators['Generator'])
379
+
380
+ print(solar_generator_names)
381
+ # ['Avonlie Solar Farm', 'Beryl Solar Farm', 'Bomen Solar Farm', 'Broken Hill Solar Farm' . . .
382
+
383
+ wind_generators = generator_data[generator_data['Technology type'] == 'Wind']
384
+
385
+ wind_generator_names = list(wind_generators['Generator'])
386
+
387
+ print(wind_generator_names)
388
+ # ['Bango 973 Wind Farm', 'Bango 999 Wind Farm', 'Boco Rock Wind Farm', 'Bodangora Wind Farm' . . .
389
+
390
+
391
+ # These names can be used to retrieve trace data
392
+
393
+ solar_generator_traces = {}
394
+
395
+ for generator_name in solar_generator_names:
396
+ trace_for_generator = get_data.solar_project_single_reference_year(
397
+ start_year=2025,
398
+ end_year=2030,
399
+ reference_year=2011,
400
+ project=generator_name,
401
+ directory=parsed_solar_data
402
+ )
403
+ solar_generator_traces[generator_name] = trace_for_generator
404
+ ```
405
+
406
+ </details>
407
+
408
+
409
+ <details>
410
+ <summary>Wind area traces</summary>
411
+ <br>
412
+
413
+ ```python
414
+ from pathlib import Path
415
+
416
+ import pandas as pd
417
+ from isp_trace_parser import get_data
418
+
419
+
420
+ # Define location of parsed data.
421
+
422
+ parsed_workbook_data = Path(
423
+ "/path/to/parsed/workbook/data"
424
+ )
425
+
426
+ parsed_wind_data = Path('path/to/parsed/wind/traces')
427
+
428
+ # ISP REZ IDs and wind resource types can be retrieved from the parsed workbook data
429
+
430
+ build_limits = pd.read_csv(
431
+ parsed_workbook_data / Path("initial_build_limits.csv")
432
+ )
433
+
434
+ # If a unit has a non-nan offshore floating build limit then it will have the wind
435
+ # resource qualities WFL and WFX (wind offshore floating and wind offshore fixed).
436
+
437
+ offshore_rezs = build_limits[~build_limits["Wind generation total limits (MW)_Offshore -floating"].isna()]
438
+
439
+ print(list(offshore_rezs['REZ ID']))
440
+ # ['N10', 'N11', 'V7', 'V8', 'S10', 'T4']
441
+
442
+ # If a unit has a nonzero high build limit then it will be an on shore REZ and have the wind
443
+ # resource qualities WH and WM (wind high and wind medium).
444
+
445
+ onshore_rezs = build_limits[build_limits["Wind generation total limits (MW)_High"] > 0.1]
446
+
447
+ print(list(onshore_rezs['REZ ID']))
448
+ # ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', . . .
449
+
450
+ # These sets of onshore and offshore REZ IDs then can be used to retrieve trace data
451
+
452
+ wind_offshore_rez_traces = {}
453
+
454
+ for rez in list(offshore_rezs['REZ ID']):
455
+ trace_for_rez = get_data.wind_area_single_reference_year(
456
+ start_year=2025,
457
+ end_year=2026,
458
+ reference_year=2011,
459
+ area=rez,
460
+ resource_quality='WFL',
461
+ directory=parsed_wind_data
462
+ )
463
+ wind_offshore_rez_traces[rez] = trace_for_rez
464
+
465
+ wind_onshore_rez_traces = {}
466
+
467
+ for rez in list(onshore_rezs['REZ ID']):
468
+ trace_for_rez = get_data.wind_area_single_reference_year(
469
+ start_year=2025,
470
+ end_year=2026,
471
+ reference_year=2011,
472
+ area=rez,
473
+ resource_quality='WH',
474
+ directory=parsed_wind_data
475
+ )
476
+ wind_onshore_rez_traces[rez] = trace_for_rez
477
+ ```
478
+
479
+ </details>
480
+
481
+
482
+ <details>
483
+ <summary>Solar area traces</summary>
484
+ <br>
485
+
486
+ ```python
487
+ from pathlib import Path
488
+
489
+ import pandas as pd
490
+ from isp_trace_parser import get_data
491
+
492
+
493
+ # Define location of parsed data.
494
+
495
+ parsed_workbook_data = Path(
496
+ "/path/to/parsed/workbook/data"
497
+ )
498
+
499
+ parsed_solar_data = Path('path/to/parsed/wind/traces')
500
+
501
+ # ISP REZ IDs and types can be retrieved from the parsed workbook data
502
+
503
+ build_limits = pd.read_csv(
504
+ parsed_workbook_data / Path("initial_build_limits.csv")
505
+ )
506
+
507
+ # If a unit has a nonzero high build limit then it will be an onshore REZ and have the
508
+ # solar traces for SAT (single axis tracking) and CST (concentrating solar thermal).
509
+
510
+ onshore_solar_rezs = build_limits[build_limits["Solar PV plus Solar thermal Limits (MW)_Solar"] > 0.1]
511
+
512
+ print(list(onshore_solar_rezs['REZ ID']))
513
+ # ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', . . .
514
+
515
+ # These sets of onshore and offshore REZ IDs then can be used to retrieve trace data
516
+
517
+ single_axis_tracking_traces = {}
518
+
519
+ for rez in list(onshore_solar_rezs['REZ ID']):
520
+ trace_for_rez = get_data.solar_area_single_reference_year(
521
+ start_year=2025,
522
+ end_year=2026,
523
+ reference_year=2011,
524
+ area=rez,
525
+ technology='SAT',
526
+ directory=parsed_solar_data
527
+ )
528
+ single_axis_tracking_traces[rez] = trace_for_rez
529
+ ```
530
+
531
+ </details>
532
+
533
+
534
+ <details>
535
+ <summary>Demand subregion traces</summary>
536
+ <br>
537
+
538
+ ```python
539
+ from pathlib import Path
540
+
541
+ import pandas as pd
542
+ from isp_trace_parser import get_data
543
+
544
+
545
+ # Define location of parsed data.
546
+
547
+ parsed_workbook_data = Path(
548
+ "/path/to/parsed/workbook/data"
549
+ )
550
+
551
+ parsed_demand_data = Path('path/to/parsed/demand/traces')
552
+
553
+ # ISP Subregion ID can be retrieved from renewable energy zones table
554
+
555
+ rez_definitions = pd.read_csv(
556
+ parsed_workbook_data / Path("renewable_energy_zones.csv")
557
+ )
558
+
559
+ subregions = list(set(rez_definitions["ISP Sub-region"]))
560
+ print(subregions)
561
+ # ['CSA', 'SESA', 'CQ', 'NQ', 'NNSW', 'CNSW', 'SNSW', 'SNW', 'TAS', 'VIC', 'SQ']
562
+
563
+ # This set of subregions can then can be used to retrieve demand trace data
564
+
565
+ demand_traces = {}
566
+
567
+ for subregion in subregions:
568
+ trace = get_data.demand_single_reference_year(
569
+ start_year=2025,
570
+ end_year=2026,
571
+ reference_year=2011,
572
+ subregion=subregion,
573
+ demand_type='OPSO_MODELLING',
574
+ poe='POE50',
575
+ scenario='Step Change',
576
+ directory=parsed_demand_data
577
+ )
578
+ demand_traces[subregion] = trace
579
+
580
+ ```
581
+
582
+ </details>
583
+
584
+ ### Constructing a reference year mapping
585
+
586
+ A helper function is provided to allow you to construct reference year mappings for use with the `get_data` multiple reference year functions.
587
+
588
+ The sequence of reference years specified is cycled from first to last and mapped to data years starting
589
+ from `start_year` and ending in `end_year`.
590
+
591
+ ```python
592
+ from isp_trace_parser import construct_reference_year_mapping
593
+
594
+ mapping = construct_reference_year_mapping(
595
+ start_year=2030,
596
+ end_year=2035,
597
+ reference_years=[2011, 2013, 2018],
598
+ )
599
+ print(mapping)
600
+ # {2030: 2011, 2031: 2013, 2032: 2018, 2033: 2011, 2034: 2013, 2035: 2018}
601
+ ```
602
+
603
+ ### polars Dataframe trace parsing
604
+
605
+ `isp-trace-parser` also exposes functionality for transforming input trace data (in a [`polars`](https://pola.rs/)
606
+ `DataFrame`) in the AEMO format to a standard time series format (i.e. "Datetime" and "Values" columns). As shown
607
+ below, the data can be converted to polars from pandas before performing Dataframe trace parsing, and back to pandas
608
+ after the parsing is complete, the polars package provides [functionality for converting to and from `pandas`](https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.to_pandas.html).
609
+
610
+
611
+ ```python
612
+ import polars as pl
613
+ import pandas as pd
614
+ from isp_trace_parser import trace_formatter
615
+
616
+ aemo_format_data = pd.DataFrame({
617
+ 'Year': [2024, 2024],
618
+ 'Month': [6, 6],
619
+ 'Day': [1, 2],
620
+ '01': [11.2, 15.3],
621
+ '02': [30.7, 20.4],
622
+ '48': [17.1, 18.9]
623
+ })
624
+
625
+ aemo_format_data_as_polars = pl.from_pandas(aemo_format_data)
626
+
627
+ trace_parser_format_data = trace_formatter(aemo_format_data_as_polars)
628
+
629
+ print(trace_parser_format_data.to_pandas())
630
+ # Datetime Value
631
+ # 0 2024-06-01 00:30:00 11.2
632
+ # 1 2024-06-01 01:00:00 30.7
633
+ # 2 2024-06-02 00:00:00 17.1
634
+ # 3 2024-06-02 00:30:00 15.3
635
+ # 4 2024-06-02 01:00:00 20.4
636
+ # 5 2024-06-03 00:00:00 18.9
637
+ ```
638
+
639
+ ## Contributing
640
+
641
+ Interested in contributing to the source code? Check out the [contributing instructions](https://github.com/Open-ISP/isp-trace-parser/blob/main/CONTRIBUTING.md), which also includes steps to install `isp-trace-parser` for development.
642
+
643
+
644
+ Please note that this project is released with a [Code of Conduct](https://github.com/Open-ISP/isp-trace-parser/blob/main/CONDUCT.md). By contributing to this project, you agree to abide by its terms.
645
+
646
+ ## License
647
+
648
+ `isp-trace-parser` was created as a part of the [OpenISP project](https://github.com/Open-ISP). It is licensed under the terms of [GNU GPL-3.0-or-later](https://github.com/Open-ISP/isp-trace-parser/blob/main/LICENSE) licences.