Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/isp_trace_parser/construct_reference_year_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
def construct_reference_year_mapping(
start_year: int, end_year: int, reference_years: list[int]
) -> dict:
"""Constructs a dictionary mapping a sequence of modeling years to a cycle of reference years.
"""Construct a dictionary mapping a sequence of modeling years to a cycle of reference years.

Examples:

>>> construct_reference_year_mapping(
... start_year=2030,
... end_year=2035,
Expand All @@ -29,6 +28,7 @@ def construct_reference_year_mapping(
start_year: int, first year in sequence of modelling years
end_year: int, last year in sequence of modelling years
reference_years: list[int], list of reference years to cycle through when constructing the mapping.

"""
input_validation.start_year_before_end_year(start_year, end_year)
years = range(start_year, end_year + 1)
Expand Down
13 changes: 7 additions & 6 deletions src/isp_trace_parser/demand_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class DemandMetadataFilter(BaseModel):
included then only traces with metadata matching the values in the corresponding list will be parsed.

Examples:

Filter for only subregions that are in a list of names.

>>> metadata_filters = DemandMetadataFilter(
Expand All @@ -50,6 +49,7 @@ class DemandMetadataFilter(BaseModel):
poe: list of POE levels, only including "POE10" and "POE50"
demand_type, list of demand types, only including "OPSO_MODELLING", "OPSO_MODELLING_PVLITE", and "PV_TOT"
reference_year: list of ints specifying reference_years

"""

subregion: list[str] | None = None
Expand All @@ -71,7 +71,7 @@ def parse_demand_traces(
use_concurrency: bool = True,
filters: DemandMetadataFilter | None = None,
) -> None:
"""Takes a directory with AEMO demand trace data and reformats the data, saving it to a new directory.
"""Take a directory with AEMO demand trace data and reformats the data, saving it to a new directory.

AEMO demand trace data comes in CSVs with columns specifying the year, day, and month, and data columns
(labeled 01, 02, ... 48) storing the demand values for each half hour of the day. The file name of the CSV
Expand All @@ -94,7 +94,6 @@ def parse_demand_traces(
metadata value present in the corresponding filter list will be passed, see examples below.

Examples:

Parse whole directory of trace data.

>>> parse_demand_traces(
Expand Down Expand Up @@ -134,6 +133,7 @@ def parse_demand_traces(
attribute is not set, no filtering on that attribute occurs. See example.

Returns: None

"""
input_directory = input_validation.input_directory(input_directory)
parsed_directory = input_validation.parsed_directory(parsed_directory)
Expand Down Expand Up @@ -171,8 +171,7 @@ def restructure_demand_file(
output_directory: Path,
filters: DemandMetadataFilter | None = None,
) -> None:
"""
Restructures a single demand trace file and saves it as parquet.
"""Restructures a single demand trace file and saves it as parquet.

The output filename is the AEMO input filename with the .csv suffix replaced by
.parquet (e.g. CNSW_RefYear_2011_HYDROGEN_EXPORT_POE10_OPSO_MODELLING.csv
Expand Down Expand Up @@ -212,6 +211,7 @@ def restructure_demand_file(
... ) # doctest: +SKIP

# This will process the input file and save it in parquet format in the specified output directory

"""
file_metadata["scenario"] = demand_scenario_mapping[file_metadata["scenario"]]

Expand All @@ -226,11 +226,12 @@ def restructure_demand_file(


def _frame_with_metadata(trace: pl.DataFrame, file_metadata: dict) -> pl.DataFrame:
"""Adds metadata fields as columns to a trace DataFrame.
"""Add metadata fields as columns to a trace DataFrame.

Args:
trace: The trace data Polars Dataframe to add data to.
file_metadata: Dict containing metadata (subregion, reference_year, scenario, poe, and demand_type)

"""
return trace.with_columns(
subregion=pl.lit(file_metadata["subregion"]),
Expand Down
Loading
Loading