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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^uv.lock$|tests/trace_data/
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.0
rev: v0.16.5
hooks:
# Run the linter.
- id: ruff
Expand Down
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ helper functions.
```python
def template_network_transmission_paths(iasr_tables, scenario):
paths = _extract_flow_paths(iasr_tables["flow_path_transfer_capability"])
paths = _add_transfer_limits(paths, iasr_tables["interconnector_transfer_capability"])
paths = _add_transfer_limits(
paths, iasr_tables["interconnector_transfer_capability"]
)
paths = _filter_to_scenario(paths, scenario)
return paths
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edit the code to point at an ispypsa_config.yaml file of your choice, then run t
Python script.

```Python
--8<-- "example_workflow.py"
--8 < --"example_workflow.py"
```

## Configuration & Logging
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example_api_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ edit the code to point at an ispypsa_config.yaml file of your choice, then run t
Python script.

```Python
--8<-- "example_workflow.py"
--8 < --"example_workflow.py"
```
47 changes: 13 additions & 34 deletions docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ either the ISPyPSA CLI or API:
```Python
from ispypsa.data_fetch import fetch_workbook

fetch_workbook(
workbook_version="6.0",
save_path="path/to/save/iasr_workbook.xlsx"
)
fetch_workbook(workbook_version="6.0", save_path="path/to/save/iasr_workbook.xlsx")
```

### Trace data
Expand All @@ -53,9 +50,7 @@ or API:
from ispypsa.data_fetch import fetch_trace_data

fetch_trace_data(
dataset_type="example",
dataset_year=2024,
save_directory="path/to/save/directory"
dataset_type="example", dataset_year=2024, save_directory="path/to/save/directory"
)
```

Expand Down Expand Up @@ -84,7 +79,7 @@ parsing can be run using either the ISPyPSA CLI or API:
build_local_cache(
cache_path="path/to/cache/location",
workbook_path="path/to/iasr_workbook.xlsx",
iasr_workbook_version="6.0"
iasr_workbook_version="6.0",
)
```

Expand Down Expand Up @@ -140,9 +135,7 @@ run using either ISPyPSA CLI or API.

# Get raw IASR tables
iasr_tables = read_csvs(parsed_workbook_cache)
manually_extracted_tables = load_manually_extracted_tables(
config.iasr_workbook_version
)
manually_extracted_tables = load_manually_extracted_tables(config.iasr_workbook_version)

# Create ISPyPSA inputs from IASR tables.
ispypsa_tables = create_ispypsa_inputs_template(
Expand Down Expand Up @@ -276,7 +269,9 @@ you can also create the PyPSA friendly operational timeseries data at this stage
operational_timeseries_location,
)

write_csvs({"operational_snapshots": operational_snapshots}, pypsa_friendly_inputs_location)
write_csvs(
{"operational_snapshots": operational_snapshots}, pypsa_friendly_inputs_location
)
```

## PyPSA building and run
Expand Down Expand Up @@ -312,12 +307,8 @@ constraints are not preserved when the PyPSA network object is saved to disk.
pypsa_friendly_inputs_location = (
run_directory / config.paths.ispypsa_run_name / "pypsa_friendly"
)
timeseries_location = (
pypsa_friendly_inputs_location / "capacity_expansion_timeseries"
)
pypsa_outputs_directory = (
run_directory / config.paths.ispypsa_run_name / "outputs"
)
timeseries_location = pypsa_friendly_inputs_location / "capacity_expansion_timeseries"
pypsa_outputs_directory = run_directory / config.paths.ispypsa_run_name / "outputs"

# Load pypsa friendly inputs
pypsa_tables = read_csvs(pypsa_friendly_inputs_location)
Expand All @@ -333,11 +324,7 @@ constraints are not preserved when the PyPSA network object is saved to disk.
network.optimize.solve_model(solver_name=config.solver)

# Save results.
save_pypsa_network(
network,
pypsa_outputs_directory,
"capacity_expansion"
)
save_pypsa_network(network, pypsa_outputs_directory, "capacity_expansion")
```

### Operational model
Expand Down Expand Up @@ -381,12 +368,8 @@ computational complexity.
operational_timeseries_location = (
pypsa_friendly_inputs_location / "operational_timeseries"
)
pypsa_outputs_directory = (
run_directory / config.paths.ispypsa_run_name / "outputs"
)
capacity_expansion_pypsa_file = (
pypsa_outputs_directory / "capacity_expansion.nc"
)
pypsa_outputs_directory = run_directory / config.paths.ispypsa_run_name / "outputs"
capacity_expansion_pypsa_file = pypsa_outputs_directory / "capacity_expansion.nc"

# Load pypsa friendly inputs
pypsa_tables = read_csvs(pypsa_friendly_inputs_location)
Expand All @@ -410,9 +393,5 @@ computational complexity.
overlap=config.temporal.operational.overlap,
)

save_pypsa_network(
network,
pypsa_outputs_directory,
"operational"
)
save_pypsa_network(network, pypsa_outputs_directory, "operational")
```
Loading