Main Utilities package

Path utility functions for development and frozen builds.

This module provides functions to locate data directories correctly in both development and PyInstaller frozen builds.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

districtheatingsim.utilities.path_utils.get_data_path(subfolder='')[source]

Get path to data directory for both development and frozen builds.

Parameters:

subfolder (str) – Optional subfolder within data directory

Returns:

Absolute path to data directory or subfolder

Return type:

str

Note

In frozen builds, data folder is located next to the executable for user accessibility.

districtheatingsim.utilities.path_utils.get_project_data_path(project_name='')[source]

Get path to project_data directory for both development and frozen builds.

Parameters:

project_name (str) – Optional name of specific project

Returns:

Absolute path to project_data directory or specific project

Return type:

str

Note

In frozen builds, project_data folder is located next to the executable.

districtheatingsim.utilities.path_utils.get_internal_data_path(relative_path)[source]

Get path to data inside _internal folder (not user-accessible).

Parameters:

relative_path (str) – Relative path within internal data structure

Returns:

Absolute path to internal data

Return type:

str

districtheatingsim.utilities.path_utils.is_frozen()[source]

Check if running as frozen (compiled) application.

Returns:

True if running as compiled executable, False otherwise

Return type:

bool

districtheatingsim.utilities.path_utils.get_app_root()[source]

Get application root directory.

Returns:

Path to executable directory (frozen) or project root (development)

Return type:

str

Test Reference Year (TRY) import module for German weather data.

This module provides functionality to import and parse standardized meteorological data files used for building energy simulations and district heating calculations.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

districtheatingsim.utilities.test_reference_year.import_TRY(filename)[source]

Read and parse TRY (Test Reference Year) weather data file.

Parameters:

filename (str) – Path to TRY file in fixed-width format

Returns:

Tuple of (temperature, windspeed, direct_radiation, global_radiation, cloud_cover)

Return type:

tuple of numpy.ndarray

Raises:

Note

  • File contains 8760 hourly values for a complete year

  • Temperature in °C (at 2m height)

  • Wind speed in m/s (at 10m height)

  • Radiation values in W/m² (horizontal surface)

  • Cloud cover in eighths (0-8, where 9=not observable)

  • Global radiation is calculated as sum of direct and diffuse radiation

Utility functions for the DistrictHeatingSim application.

This module provides helper functions for resource path resolution, global exception handling, and theme management.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

districtheatingsim.utilities.utilities.get_resource_path(relative_path)[source]

Get absolute path to resource for both development and PyInstaller builds.

Parameters:

relative_path (str) – Relative path to resource from project root

Returns:

Absolute path to resource

Return type:

str

Note

Data folders (data, project_data, images, leaflet) are placed outside the _internal folder in PyInstaller builds for user accessibility.

districtheatingsim.utilities.utilities.handle_global_exception(exc_type, exc_value, exc_traceback)[source]

Global exception handler that displays errors in a QMessageBox dialog.

Parameters:

Note

KeyboardInterrupt exceptions are handled by the default system handler.

districtheatingsim.utilities.utilities.get_stylesheet_based_on_time()[source]

Get stylesheet identifier based on current system time.

Returns:

‘light_theme_style_path’ if between 6:00-18:00, otherwise ‘dark_theme_style_path’

Return type:

str

Note

Light theme is applied during daytime (6 AM - 6 PM), dark theme during evening/night hours.