logoBCNexus

The bcnexus package & workflow

How the Python package is organised, and how one RunModel.run() call turns raw CSVs into a solved CLEWs model and results. Click any module or step for details.

Package structure

Modules at a glance

A simplified map of bcnexus/. The clews/ sub-package is the engine โ€” a Runner (orchestrator) that drives a Builder plus helper modules; vis/ renders results.

bcnexus /  (package root)
cli.py
utils.py
attributes_parser.py
constants.py
plots.py
bcnexus / clews /  โ€” the CLEWs engine
runner.pyRunner
builder.pyBuilder
model_structure.pyhelper
schema.pyhelper
sets_n_ratios.pyhelper
update_global_params.pyhelper
update_yearly_params.pyhelper
preprocess_data_Kotzur.pystorage
preprocess_data_Niet.pystorage
solver.pyhelper
datapackage.pyhelper
livestock.pyoptional
bcnexus / vis /  โ€” visualization
dashboard/Dash
plot_Energy ยท plot_Land ยท plot_Climate ยท โ€ฆplots
vis_utils.py

Pick a module

Click any file on the left to see what it does and where it sits in the workflow.

How it connects to the workflow

One run() call, end to end

Creating a RunModel auto-creates a BuildModel (ClewsBuilder). Calling .run(build=True, threads=N) executes the whole pipeline. Click any step for detail.

โ‘  Configure
๐ŸŽ›๏ธ Scenario config UI
utils.build_scenario_ui()
๐Ÿ“ฆ model_builder_args
scenario ยท storage_algorithm ยท clustering
โ†“
โ‘ก Instantiate clews/runner.py clews/builder.py
๐Ÿงฉ RunModel(**args)
creates ClewsBuilder inside
๐Ÿš€ bcnexusRun.run(build=True, threads=N)
drives everything below
โ†“
โ‘ข Builder phase writes data/clews_data
๐Ÿ—๏ธ Build SETs & params + temporal clustering + storage case
model_structure ยท schema ยท sets_n_ratios ยท update_global/yearly_params ยท preprocess_data_Kotzur/Niet
โ†“
โ‘ฃ Runner phase โ€” solve
๐Ÿ“„ Prepare datafile
otoole ยท datapackage report
๐Ÿ“ Write LP
GLPK
๐Ÿงฎ Solve
solver.py ยท Gurobi / CBC
๐Ÿ’พ Write solution
.sol ยท duals / shadow price
โ†“
โ‘ค Results & visuals
๐Ÿ“Š Get result CSVs
get_result_csvs() ยท otoole
๐Ÿ“ˆ Plots & dashboard
plots.main() ยท vis/dashboard

Data flow on disk

Where files live

Everything happens inside data/clews_data. The build creates clews_build_data/ with three sub-folders; results and plots land in their own trees. Set build=False to reuse a built structure and only re-cluster.

data/clews_data/clews_build_data/ โ”œโ”€ input_csvs/ templates, updated per clews_builder.yaml โ”œโ”€ inputs_csv_8760/ hourly (8760 h) profiles used for clustering โ””โ”€ Model_<storage_algorithm>/<scenario>/ final datafiles results/clews/Model_<storage_algorithm>_<scenario>/ result CSVs (via otoole) vis/<scenario>/<timeslices>ts_<RUNTAG>/ saved figures