API#
All the modelling code lives in the src package. Running the study does not
require it, because python workflow/main.py calls everything. This section is for
reusing one step of the method in other work, or for seeing exactly how a step in the paper is
written in code. The cards lead to the reference; the guide below explains how it can be put to
use.
src.cluster: k-means clustering that picks the typical days.
Study
Reproduce helpers
src.reproduce: run scenarios, load results and rebuild the paper's tables.
Reference
Full reference
Every module and function in src, generated from the source code.
How to use this section#
1. Locate the step of interest. Each module does one step of the method, so the reference reads like the method section of the paper:
Step in the study |
Module |
What it provides |
|---|---|---|
Pick representative days |
|
|
Shrink the hourly data |
|
|
Build the time structure |
|
The OSeMOSYS time-slice sets and weights each storage formulation needs |
Rebuild the intra-day SoC |
|
Turns the solved Kotzur and Welsch storage levels into a SoC series for every time block of the year |
Solve and collect |
|
Runs GLPK and writes cost, capacity and runtime to |
Reproduce the paper |
|
|
2. Call it from a script. The functions take file paths and plain Python values, so any one of them can be used without the rest. For example, the clustering can be applied to other wind and demand profiles to see which representative days it picks:
from src.cluster import cluster_data
days, sequence = cluster_data("my_wind_cf.csv", "my_demand.csv", n_clusters=8, random_state=0)
print(days) # the 8 representative days
print(sequence[:7]) # which representative day stands in for each day of the first week
Similarly, one scenario of the study can be rerun with all four formulations, returning a table:
from src.reproduce import run_case
df = run_case("WND", k=8, h=1)
print(df[["Model", "Total cost", "Storage Capacity"]])
3. Use it as a reference for other models. For work in another framework, the modules
are a compact recipe: how many representative days to use, how to weight them, and how each
formulation links storage across days. Reading src.update_yearsplit and the update_conversion*
modules next to About Storage Modelling shows exactly what each formulation adds to a
model, which can then be ported to another tool.