ComparisonTab package

Variant comparison module for district heating project analysis.

Provides automatic variant discovery, KPI dashboards, and comparative visualization of economic and technical metrics.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

districtheatingsim.gui.ComparisonTab.comparison_tab.format_kpi_range(variant_data: list[dict], key: str, fmt: str, *, empty: str = '--') str[source]

Summarize one KPI across the compared variants for the dashboard.

Filters out missing / zero values, then returns a single formatted number, a "min - max" range when several variants differ, or empty when no variant provides the value. GUI-free domain/formatting logic (extracted from the view so it is unit-testable — BACKLOG B2).

Parameters:
  • variant_data – One result dict per variant.

  • key – The metric key to read from each variant dict.

  • fmt – A format() spec applied to each number (e.g. ".1f").

  • empty – Text to show when no variant provides the metric.

Returns:

The formatted value / range / empty string.

Return type:

str

class districtheatingsim.gui.ComparisonTab.comparison_tab.ProjectExplorer(folder_manager, config_manager, parent=None)[source]

Bases: QWidget

Project explorer for automatic variant discovery and selection.

Scans project folder for available variants and allows multi-selection for comparison analysis.

variants_changed

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(folder_manager, config_manager, parent=None)[source]
initUI()[source]

Initialize project explorer UI.

set_base_path(base_path)[source]

Set base path and refresh project list.

Parameters:

base_path (str) – Project data base path

discover_projects()[source]

Discover variants and their energy system configs; build two-level tree.

Top level: variant folders (Variante *). Children: each Ergebnisse*.json config inside that variant.

validate_variant(variant_path)[source]

Validate that a variant has at least one energy system result file.

Parameters:

variant_path (str) – Path to variant folder

Returns:

True if the variant is usable for comparison

Return type:

bool

on_selection_changed(item, column)[source]

Handle selection changes; propagate variant-level toggles to all child configs.

Parameters:
  • item (QTreeWidgetItem) – Changed tree item

  • column (int) – Column index (unused)

update_selected_variants()[source]

Collect all checked leaf (config) items and emit variants_changed signal.

class districtheatingsim.gui.ComparisonTab.comparison_tab.ComparisonDashboard(parent=None)[source]

Bases: QWidget

Dashboard widget showing comparison overview and KPIs.

Displays economic, environmental, and technical metrics across selected variants with interactive charts.

__init__(parent=None)[source]
initUI()[source]

Initialize dashboard UI.

create_kpi_section()[source]

Create KPI overview section.

create_kpi_widget(title, unit)[source]

Create individual KPI widget.

create_charts_section()[source]

Create charts section with tabbed organization.

update_dashboard(variant_data)[source]

Update dashboard with new variant data.

update_kpis()[source]

Update KPI widgets with current data.

update_charts()[source]

Update all comparison charts.

update_cost_chart()[source]

Update cost comparison chart.

get_clean_variant_name(full_name)[source]

Extract clean variant name from full project path name.

update_energy_chart()[source]

Update energy mix comparison chart.

update_co2_chart()[source]

Update CO2 emissions comparison chart.

update_pe_chart()[source]

Update Primärenergiefaktor comparison chart.

update_network_chart()[source]

Update network statistics chart with enhanced layout for larger space.

clear_dashboard()[source]

Clear all dashboard content.

class districtheatingsim.gui.ComparisonTab.comparison_tab.ComparisonTab(folder_manager, data_manager, config_manager, parent=None)[source]

Bases: QWidget

Comparison tab with comprehensive variant analysis.

Integrates project explorer, KPI dashboard, and comparative visualizations for multi-variant evaluation.

__init__(folder_manager, data_manager, config_manager, parent=None)[source]

Initialize comparison tab.

Parameters:
initUI()[source]

Initialize modern user interface.

create_comparison_content()[source]

Create main comparison content area.

Returns:

Content widget with dashboard tabs

Return type:

QWidget

on_variants_changed(selected_variants)[source]

Handle variant selection changes from explorer.

Parameters:

selected_variants (list) – List of selected variant info dicts

load_variant_data(selected_variants)[source]

Load data for selected (variant, config) combinations.

Network KPIs are cached per variant path since they are shared across configs.

Parameters:

selected_variants (list) – List of item data dicts from ProjectExplorer

load_network_data(variant_path)[source]

Load network KPI data from variant configuration.

Parameters:

variant_path (str) – Path to variant folder

Returns:

Network KPI data (length, losses, pump energy, building count)

Return type:

dict

process_variant_results(results)[source]

Process raw variant results for comparison.

Parameters:

results (dict) – Raw results from JSON file

Returns:

Processed results for dashboard display

Return type:

dict

Raises:

ValueError – If processing fails