API Reference¶
Complete API documentation for GOLIAT, organized by module category.
Core Modules¶
Core functionality for configuration, logging, and utilities.
Antenna¶
goliat.antenna.Antenna ¶
Manages antenna-specific properties and configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | The configuration object containing antenna settings. | required |
frequency_mhz | int | The operating frequency in MHz. | required |
Source code in goliat/antenna.py
Methods:¶
get_config_for_frequency ¶
Gets the antenna configuration for the current frequency.
Raises:
| Type | Description |
|---|---|
ValueError | If no configuration is defined for the frequency. |
Returns:
| Type | Description |
|---|---|
dict | The antenna configuration dictionary. |
Source code in goliat/antenna.py
get_model_type ¶
get_source_entity_name ¶
get_centered_antenna_path ¶
Constructs the path to the centered .sab antenna file.
If the exact frequency file doesn't exist, finds the nearest available frequency and shows a warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
centered_antennas_dir | str | The directory for centered antenna files. | required |
Returns:
| Type | Description |
|---|---|
str | The absolute path to the centered antenna model file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If no antenna files are found in the directory. |
Source code in goliat/antenna.py
Colors¶
goliat.colors ¶
Functions:¶
init_colorama ¶
Initialize colorama for current environment.
Preserves ANSI codes when stdout is piped (e.g., in Jupyter notebooks) by checking for JUPYTER_NOTEBOOK or COLORAMA_STRIP environment variables.
Source code in goliat/colors.py
get_color ¶
Returns the colorama color code for a log type, or white if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_type | str | Log type key (e.g., 'info', 'warning', 'error'). | required |
Returns:
| Type | Description |
|---|---|
str | Colorama color code string. |
Source code in goliat/colors.py
Constants¶
goliat.constants ¶
Constants used throughout the GOLIAT codebase.
This module centralizes magic numbers, thresholds, and hardcoded values to improve maintainability and reduce technical debt.
Attributes¶
MIN_H5_FILE_SIZE_BYTES module-attribute ¶
Minimum size in bytes for a valid H5 output file.
iSolve sometimes creates incomplete files that are smaller than this threshold. Files smaller than this are considered invalid.
H5_SIZE_INCREASE_THRESHOLD module-attribute ¶
Minimum size increase ratio for Output.h5 compared to Input.h5.
Output.h5 must be at least 10% bigger than Input.h5 to ensure the simulation completed successfully. This helps detect incomplete or corrupted output files.
PLOT_Y_AXIS_BUFFER_MULTIPLIER module-attribute ¶
Multiplier for y-axis maximum in plots.
Adds 10% buffer above the maximum value for better visualization.
Data Extractor¶
goliat.data_extractor ¶
Functions:¶
get_parameter_from_json ¶
Extracts a nested value from a JSON file using dot notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path | str | Path to the JSON file. | required |
json_path | str | Dot-separated path like 'section.subsection.key'. | required |
Returns:
| Type | Description |
|---|---|
Any | The value at the path, or None if not found. |
Source code in goliat/data_extractor.py
get_parameter ¶
Retrieves a parameter from a data source using a config-driven approach.
Supports JSON sources currently. The source_config defines where to look, and context provides values for formatting paths (e.g., project_root).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_config | Dict[str, Any] | Dict with 'source_type', 'file_path_template', 'json_path'. | required |
context | Dict[str, Any] | Values for formatting file paths. | required |
Returns:
| Type | Description |
|---|---|
Any | The retrieved value, or None on error. |
Source code in goliat/data_extractor.py
Gui Manager¶
goliat.gui_manager ¶
Main GUI manager module.
Classes¶
QueueGUI ¶
QueueGUI(queue: Queue, stop_event: Event, profiler: Profiler, progress_logger: Logger, verbose_logger: Logger)
Bases: LoggingMixin
Proxy for ProgressGUI that operates in a separate process.
Mimics the ProgressGUI interface but routes all calls through a multiprocessing queue, enabling thread-safe communication between worker and GUI processes. All methods serialize their arguments and send them via queue for the GUI process to handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue | Queue | Multiprocessing queue for IPC. | required |
stop_event | Event | Event flagging user cancellation. | required |
profiler | Profiler | Profiler for ETA calculations. | required |
progress_logger | Logger | Logger for progress-level messages. | required |
verbose_logger | Logger | Logger for detailed messages. | required |
Source code in goliat/gui/queue_gui.py
Methods:¶
log ¶
Sends a log message to the GUI via queue.
All messages are forwarded through the queue for terminal output (S4L 9.2 fix). Progress messages update the GUI status box; verbose messages only print to terminal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | Log message text. | required |
level | str | Log level ('progress' or 'verbose'). | 'verbose' |
log_type | str | Type for color coding in GUI. | 'default' |
Source code in goliat/gui/queue_gui.py
update_simulation_details ¶
Sends current simulation case details to GUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim_count | int | Current simulation number (1-indexed). | required |
total_sims | int | Total simulations in study. | required |
details | str | Human-readable description of current case. | required |
Source code in goliat/gui/queue_gui.py
update_overall_progress ¶
Updates overall study progress bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_step | float | Current step number or percentage (0-100). | required |
total_steps | int | Total steps in study. | required |
Source code in goliat/gui/queue_gui.py
update_stage_progress ¶
update_stage_progress(stage_name: str, current_step: int, total_steps: int, sub_stage: str = '') -> None
Updates progress for a specific stage (setup/run/extract).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage_name | str | Stage name like 'Setup' or 'Running Simulation'. | required |
current_step | int | Current step within stage. | required |
total_steps | int | Total steps for stage. | required |
sub_stage | str | Optional sub-stage description. | '' |
Source code in goliat/gui/queue_gui.py
start_stage_animation ¶
Starts animated progress bar for a stage.
Looks up time estimate from profiler and starts animation that progresses toward end_value over that duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name | str | Task name ('setup', 'run', 'extract', or subtask name). | required |
end_value | int | Target progress value (typically 100). | required |
Source code in goliat/gui/queue_gui.py
end_stage_animation ¶
update_profiler ¶
process_events ¶
ProgressGUI ¶
ProgressGUI(queue: Queue, stop_event: Event, process: Process, init_window_title: str = '', use_web: bool = True, auto_close: bool = False)
Bases: QWidget
Main GUI window for monitoring simulation progress.
Provides real-time progress tracking via progress bars, ETA estimation, and status logs. Runs in the main process and communicates with worker process through a multiprocessing queue.
The GUI architecture: - Main window runs in main process, worker runs in separate process - Communication via multiprocessing.Queue for thread-safe message passing - QueueHandler polls queue every 100ms and updates UI - Multiple timers handle different update frequencies (queue, clock, graphs)
Features: - Overall progress bar (weighted across all simulations) - Stage progress bar (current phase: setup/run/extract) - Real-time ETA calculation based on profiler estimates - Status log with color-coded messages - Timings table showing execution statistics - Pie charts showing phase/subtask breakdowns - Time series plots for progress and ETA trends - System tray integration for background operation
Initializes data manager, status manager, UI builder, timers, and queue handler. Sets up Qt timers for periodic updates (queue polling, clock updates, graph refreshes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue | Queue | Queue for receiving messages from worker process. | required |
stop_event | Event | Event to signal termination to worker process. | required |
process | Process | Worker process running the study. | required |
init_window_title | str | Initial window title. | '' |
use_web | bool | Whether to enable web bridge for remote monitoring. | True |
auto_close | bool | Whether to automatically close GUI on successful completion. | False |
Source code in goliat/gui/progress_gui.py
Methods:¶
update_overall_progress ¶
Updates overall progress bar across all simulations.
update_stage_progress ¶
update_stage_progress(stage_name: str, current_step: int, total_steps: int, sub_stage: str = '') -> None
Updates stage-specific progress bar and label.
Source code in goliat/gui/progress_gui.py
start_stage_animation ¶
Starts smooth animated progress bar for a stage.
Instead of jumping to discrete progress values, animates smoothly over the estimated duration. This provides visual feedback during long-running tasks where progress updates are infrequent.
The animation uses linear interpolation between current value and target (always 100% = 1000). Updates every 50ms via Qt timer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimated_duration | float | Estimated task duration in seconds (from profiler). | required |
end_step | int | Target step value (unused, always animates to 100%). | required |
Source code in goliat/gui/progress_gui.py
end_stage_animation ¶
update_animation ¶
Updates progress bar animation frame and syncs overall progress.
Called every 50ms by Qt timer when animation is active. Calculates current progress based on elapsed time and estimated duration, then updates stage progress bar. Also syncs overall progress bar using weighted progress calculation from profiler.
Source code in goliat/gui/progress_gui.py
update_simulation_details ¶
Updates simulation counter and details labels.
update_status ¶
Appends message to status log with color formatting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | Message text. | required |
log_type | str | Log type for color coding. | 'default' |
Source code in goliat/gui/progress_gui.py
update_utilization ¶
update_utilization_plot ¶
update_clock ¶
update_graphs ¶
hide_to_tray ¶
show_from_tray ¶
stop_study ¶
Sends stop signal to worker process.
Source code in goliat/gui/progress_gui.py
study_finished ¶
Handles study completion, stopping timers and updating UI.
Called when worker process signals completion. Stops all timers, updates final progress to 100%, sets stage label, and schedules window auto-close after 3 seconds (if no errors).
For memory errors (exit code 42), the GUI auto-closes even with errors so the batch worker can retry the assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error | bool | Whether study finished with errors (affects UI styling). | False |
memory_error | bool | Whether this was a memory error (exit code 42). Memory errors auto-close to allow batch retry. | False |
Source code in goliat/gui/progress_gui.py
closeEvent ¶
Handles window close event, ensuring worker process termination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event | Any | Close event. | required |
Source code in goliat/gui/progress_gui.py
Logging Manager¶
goliat.logging_manager.ColorFormatter ¶
Bases: Formatter
Custom formatter that colorizes log messages based on log_type.
Applies colorama color codes to messages and caller info based on the log_type attribute (info, warning, error, success, etc.).
Methods:¶
format ¶
Adds color codes to log messages based on log_type.
Source code in goliat/logging_manager.py
Metadata Exporter¶
goliat.metadata_exporter.TimingBreakdown dataclass ¶
TimingBreakdown(phase_name: str, avg_time_s: float, total_time_s: float, num_executions: int, subtasks: dict[str, float] = dict())
Breakdown of timing data for a single phase.
Profiler¶
goliat.profiler.Profiler ¶
Manages execution time tracking, ETA estimation, and study phase management.
This class divides a study into phases (setup, run, extract), calculates weighted progress, and estimates the time remaining. It also saves updated time estimates to a configuration file after each run, making it self-improving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_control | dict | Dict indicating which phases are enabled. | required |
profiling_config | dict | Historical timing data for estimates. | required |
study_type | str | Study type ('near_field' or 'far_field'). | required |
config_path | str | Path where profiling config is saved. | required |
Source code in goliat/profiler.py
Methods:¶
set_total_simulations ¶
set_project_scope ¶
set_current_project ¶
simulation_completed ¶
start_stage ¶
Starts tracking a new phase (setup/run/extract).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase_name | str | Phase name like 'setup', 'run', or 'extract'. | required |
total_stages | int | Number of stages within this phase. | 1 |
Source code in goliat/profiler.py
end_stage ¶
Ends current phase and records its duration for future estimates.
Source code in goliat/profiler.py
complete_run_phase ¶
get_weighted_progress ¶
Calculates overall study progress using phase weights and simulation count.
This method handles the complexity that different phases (setup, run, extract) take different amounts of time. For example, if setup takes 10 minutes, run takes 2 hours, and extract takes 5 minutes, then the run phase should account for roughly 85% of the progress bar, not 33%.
The calculation works in two parts: 1. Progress within current simulation: Sums weights of completed phases, plus partial weight for the current phase based on its progress ratio. 2. Overall progress: Divides (completed_simulations + current_sim_progress) by total_simulations to get the overall percentage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase_name | str | The name of the current phase ('setup', 'run', or 'extract'). | required |
phase_progress_ratio | float | Progress within current phase (0.0 = not started, 1.0 = fully complete). | required |
Returns:
| Type | Description |
|---|---|
float | Overall progress percentage (0.0 to 100.0). |
Source code in goliat/profiler.py
get_subtask_estimate ¶
Retrieves the estimated time for a specific subtask. Args: task_name: The name of the subtask. Returns: The estimated duration in seconds.
Source code in goliat/profiler.py
get_phase_subtasks ¶
Gets a list of subtasks for a given phase. Args: phase_name: The name of the phase. Returns: A list of subtask names.
Source code in goliat/profiler.py
get_time_remaining ¶
Estimates total time remaining for the entire study.
Uses historical timing data to predict how long each phase will take, then calculates remaining time by subtracting elapsed time from total estimated time. This gives a realistic ETA that accounts for the fact that different phases take different amounts of time.
The calculation considers: - Time already spent on fully completed simulations - Time spent on phases within the current simulation that are done - Estimated time remaining in the current phase (based on progress ratio) - Estimated time for all future simulations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_stage_progress | float | Progress within current stage (0.0 to 1.0). | 0.0 |
Returns:
| Type | Description |
|---|---|
float | Estimated time remaining in seconds. |
Source code in goliat/profiler.py
subtask ¶
A context manager to time a subtask.
Source code in goliat/profiler.py
update_and_save_estimates ¶
Updates the profiling configuration with the latest average times and saves it.
This makes the profiler's estimates self-improving over time.
Source code in goliat/profiler.py
Project Manager¶
goliat.project_manager.ProjectCorruptionError ¶
Bases: Exception
Raised when a project file is corrupted, locked, or inaccessible.
Results Extractor¶
goliat.results_extractor.ExtractionContext dataclass ¶
ExtractionContext(config: Config, simulation: Simulation, phantom_name: str, frequency_mhz: int | list[int], scenario_name: str, position_name: str, orientation_name: str, study_type: str, verbose_logger: Logger, progress_logger: Logger, free_space: bool = False, gui: Optional[QueueGUI] = None, study: Optional[BaseStudy] = None)
Context object containing all parameters needed for result extraction.
Groups related parameters together to reduce the parameter count of ResultsExtractor.init.
Simulation Runner¶
goliat.simulation_runner.SimulationRunner ¶
SimulationRunner(config: Config, project_path: str, simulation: Simulation, profiler: Profiler, verbose_logger: Logger, progress_logger: Logger, project_manager: ProjectManager, gui: Optional[QueueGUI] = None)
Bases: LoggingMixin
Manages simulation execution via the Sim4Life API or iSolve.exe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
project_path | str | Path to the Sim4Life project file. | required |
simulation | Simulation | The simulation object to run. | required |
profiler | Profiler | Profiler for timing subtasks. | required |
verbose_logger | Logger | Logger for detailed output. | required |
progress_logger | Logger | Logger for high-level updates. | required |
gui | Optional[QueueGUI] | Optional GUI proxy for updates. | None |
project_manager | ProjectManager | ProjectManager instance. Uses its save() method. | required |
Source code in goliat/simulation_runner.py
Methods:¶
run ¶
Runs the simulation using the configured execution method.
Writes input file first, then runs via Sim4Life API, manual iSolve, or oSPARC depending on config. Handles errors and provides helpful messages for common issues.
Source code in goliat/simulation_runner.py
Configuration¶
Configuration management and settings.
Core¶
goliat.config.core.Config ¶
Manages loading and access of hierarchical JSON configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_dir | str | The base directory of the project. | required |
config_filename | str | The name of the main configuration file to load. | 'near_field_config.json' |
no_cache | bool | This parameter is accepted but not used directly by the Config class. It's used by other managers to control caching behavior. | False |
Source code in goliat/config/core.py
Methods:¶
get_material_mapping ¶
Gets the material name mapping for a specific phantom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phantom_name | str | The name of the phantom. | required |
Returns:
| Type | Description |
|---|---|
dict | The material mapping dictionary. |
Source code in goliat/config/core.py
get_profiling_config ¶
Gets the profiling configuration for a given study type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
study_type | str | The type of the study (e.g., 'near_field'). | required |
Returns:
| Type | Description |
|---|---|
dict | The profiling configuration for the study type. |
Source code in goliat/config/core.py
get_download_email ¶
Returns the download email from environment variables.
Raises:
| Type | Description |
|---|---|
ValueError | If DOWNLOAD_EMAIL is not set in the environment. |
get_osparc_credentials ¶
Gets oSPARC credentials from environment variables.
Raises:
| Type | Description |
|---|---|
ValueError | If required oSPARC credentials are not set. |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing oSPARC API credentials. |
Source code in goliat/config/core.py
get_only_write_input_file ¶
Returns whether to only write input files without running simulations.
Source code in goliat/config/core.py
get_auto_cleanup_previous_results ¶
Gets the 'auto_cleanup_previous_results' setting from 'execution_control'.
This setting determines which previous simulation files to automatically delete to preserve disk space. It should only be used in serial workflows.
Also checks GOLIAT_AUTO_CLEANUP environment variable for worker scenarios where config is downloaded from cloud. Format: comma-separated values like "output,input".
Returns:
| Type | Description |
|---|---|
list | A list of file types to clean up (e.g., ["output", "input"]). |
Source code in goliat/config/core.py
build_simulation_config ¶
build_simulation_config(phantom_name: str, frequency_mhz: int | list[int], scenario_name: Optional[str] = None, position_name: Optional[str] = None, orientation_name: Optional[str] = None, direction_name: Optional[str] = None, polarization_name: Optional[str] = None) -> dict
Constructs a minimal, simulation-specific configuration dictionary.
This method is the core of the "Verify and Resume" feature. It creates a "surgical" snapshot of the configuration that is unique to a single simulation run. This snapshot is then hashed to determine if a valid, reusable simulation already exists.
The key principle is to only include parameters that directly affect the outcome of the specific simulation. For example, instead of including the entire 'gridding_parameters' block, it surgically extracts only the gridding value for the specific 'frequency_mhz' being used. This ensures that a change to one frequency's gridding in the main config does not invalidate the hashes for other, unaffected frequencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phantom_name | str | The name of the phantom model. | required |
frequency_mhz | int | list[int] | The simulation frequency in MHz. | required |
scenario_name | Optional[str] | (Near-Field) The base name of the placement scenario. | None |
position_name | Optional[str] | (Near-Field) The name of the position within the scenario. | None |
orientation_name | Optional[str] | (Near-Field) The name of the orientation. | None |
direction_name | Optional[str] | (Far-Field) The incident direction of the plane wave. | None |
polarization_name | Optional[str] | (Far-Field) The polarization of the plane wave. | None |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing the minimal, surgical configuration snapshot. |
Source code in goliat/config/core.py
get_detuning_mhz ¶
Gets detuning value in MHz for a specific simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phantom_name | str | Name of the phantom (will be normalized to lowercase). | required |
frequency_mhz | int | Frequency in MHz. | required |
placement_name | str | Placement name (format: {scenario}{position}). | required |
Returns:
| Type | Description |
|---|---|
float | Detuning value in MHz. Returns 0.0 if not found or detuning disabled. |
Source code in goliat/config/core.py
update_detuning_file ¶
update_detuning_file(phantom_name: str, frequency_mhz: int | list[int], placement_name: str, detuning_mhz: float) -> None
Updates detuning file with a new detuning value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phantom_name | str | Name of the phantom (will be normalized to lowercase). | required |
frequency_mhz | int | list[int] | Frequency in MHz. | required |
placement_name | str | Placement name (format: {scenario}{position}). | required |
detuning_mhz | float | Detuning value in MHz to write. | required |
Source code in goliat/config/core.py
initialize_missing_detuning_entries ¶
Initializes missing detuning entries for all simulations in the study.
Called at the end of a calibration run to ensure all simulation entries exist in the detuning file (with value 0) before manual calibration values are added.
Source code in goliat/config/core.py
Credentials¶
goliat.config.credentials ¶
Environment variable and credentials management.
Functions:¶
get_download_email ¶
Returns the download email from environment variables.
Raises:
| Type | Description |
|---|---|
ValueError | If DOWNLOAD_EMAIL is not set in the environment. |
Source code in goliat/config/credentials.py
get_osparc_credentials ¶
Gets oSPARC credentials from environment variables.
Raises:
| Type | Description |
|---|---|
ValueError | If required oSPARC credentials are not set. |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing oSPARC API credentials. |
Source code in goliat/config/credentials.py
File Management¶
goliat.config.file_management ¶
File management utilities for configuration.
Functions:¶
cleanup_old_data_files ¶
Removes old CSV/JSON files from data/ when there are more than 50.
Only cleans files matching specific patterns (time_remaining_, overall_progress_, profiling_config_). Files are sorted by creation time and oldest are deleted first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir | str | The data directory to clean up. | required |
Source code in goliat/config/file_management.py
Merge¶
goliat.config.merge ¶
Dictionary merging utilities.
Functions:¶
deep_merge ¶
Recursively merges two dictionaries, overwriting destination with source values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source | dict | The dictionary with values to merge. | required |
destination | dict | The dictionary to be merged into. | required |
Returns:
| Type | Description |
|---|---|
dict | The merged dictionary. |
Source code in goliat/config/merge.py
Profiling¶
goliat.config.profiling ¶
Profiling configuration management.
Functions:¶
load_or_create_profiling_config ¶
Loads profiling config from disk, or creates a new one if missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiling_config_path | str | Path to the profiling config file. | required |
Returns:
| Type | Description |
|---|---|
dict | The profiling config dict, initialized with empty structure if new. |
Source code in goliat/config/profiling.py
get_profiling_config ¶
Gets the profiling configuration for a given study type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiling_config | dict | The profiling configuration dictionary. | required |
study_type | str | The type of the study (e.g., 'near_field'). | required |
Returns:
| Type | Description |
|---|---|
dict | The profiling configuration for the study type. |
Source code in goliat/config/profiling.py
Simulation Config¶
goliat.config.simulation_config ¶
Simulation-specific configuration building utilities.
Functions:¶
build_surgical_gridding ¶
Extracts frequency-specific gridding parameters.
This surgically extracts only the gridding value for the specific frequency, ensuring that changes to other frequencies don't invalidate hashes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gridding_params | dict | The full gridding parameters dictionary. | required |
frequency_mhz | int | list[int] | The simulation frequency in MHz. | required |
Returns:
| Type | Description |
|---|---|
dict | A dictionary containing surgical gridding parameters. |
Source code in goliat/config/simulation_config.py
build_near_field_simulation_config ¶
build_near_field_simulation_config(config_accessor, surgical_config: dict, phantom_name: str, frequency_mhz: int | list[int], scenario_name: Optional[str], position_name: Optional[str], orientation_name: Optional[str]) -> None
Builds near-field specific configuration components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_accessor | Object with getitem method to access config values. | required | |
surgical_config | dict | The configuration dictionary to populate. | required |
phantom_name | str | The name of the phantom model. | required |
frequency_mhz | int | list[int] | The simulation frequency in MHz. | required |
scenario_name | Optional[str] | The base name of the placement scenario. | required |
position_name | Optional[str] | The name of the position within the scenario. | required |
orientation_name | Optional[str] | The name of the orientation. | required |
Source code in goliat/config/simulation_config.py
build_far_field_simulation_config ¶
build_far_field_simulation_config(config_accessor, surgical_config: dict, phantom_name: str, direction_name: Optional[str], polarization_name: Optional[str]) -> None
Builds far-field specific configuration components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_accessor | Object with getitem method to access config values. | required | |
surgical_config | dict | The configuration dictionary to populate. | required |
phantom_name | str | The name of the phantom model. | required |
direction_name | Optional[str] | The incident direction of the plane wave. | required |
polarization_name | Optional[str] | The polarization of the plane wave. | required |
Source code in goliat/config/simulation_config.py
Study Orchestration¶
Study classes that orchestrate simulation workflows.
Base Study¶
goliat.studies.base_study.BaseStudy ¶
BaseStudy(study_type: str, config_filename: Optional[str] = None, gui: Optional[QueueGUI] = None, profiler=None, no_cache: bool = False)
Bases: LoggingMixin
Base class for simulation studies.
Handles common setup like config loading, profiling, project management, and GUI coordination. Subclasses implement _run_study() for specific logic.
Source code in goliat/studies/base_study.py
Methods:¶
subtask ¶
A context manager for a 'subtask' within a phase.
Source code in goliat/studies/base_study.py
start_stage_animation ¶
Starts progress bar animation for the current stage.
end_stage_animation ¶
run ¶
Main entry point to run the study.
Ensures Sim4Life is running, calls _run_study(), and handles cleanup and error reporting. Catches StudyCancelledError for graceful shutdown.
Source code in goliat/studies/base_study.py
Far Field Study¶
goliat.studies.far_field_study.FarFieldStudy ¶
FarFieldStudy(study_type: str, config_filename: Optional[str] = None, gui: Optional[QueueGUI] = None, profiler=None, no_cache: bool = False)
Bases: BaseStudy
Manages far-field simulation campaigns.
Runs plane wave simulations across phantoms, frequencies, directions, and polarizations. Handles setup, run, and extraction phases with progress tracking.
Source code in goliat/studies/base_study.py
Near Field Study¶
goliat.studies.near_field_study.NearFieldStudy ¶
NearFieldStudy(study_type: str, config_filename: Optional[str] = None, gui: Optional[QueueGUI] = None, profiler=None, no_cache: bool = False)
Bases: BaseStudy
Manages near-field simulation campaigns.
Runs simulations across phantoms, frequencies, placements, positions, and orientations. Handles setup, run, and extraction phases with progress tracking and metadata verification.
Source code in goliat/studies/base_study.py
Setup Modules¶
Classes responsible for building the Sim4Life simulation scene.
Base Setup¶
goliat.setups.base_setup.BaseSetup ¶
BaseSetup(config: Config, verbose_logger: Logger, progress_logger: Logger, gui: Optional[QueueGUI] = None)
Bases: LoggingMixin
Base class for simulation setup modules.
Provides common functionality like solver configuration, time/termination setup, point sensor creation, and final voxelization. Subclasses implement run_full_setup() for specific setup logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
verbose_logger | Logger | Logger for detailed output. | required |
progress_logger | Logger | Logger for progress updates. | required |
gui | Optional[QueueGUI] | Optional GUI instance for forwarding progress messages. | None |
Source code in goliat/setups/base_setup.py
Methods:¶
run_full_setup ¶
Prepares the simulation scene. Must be implemented by subclasses.
Returns:
| Type | Description |
|---|---|
| The configured simulation object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError | If not overridden by subclass. |
Source code in goliat/setups/base_setup.py
Boundary Setup¶
goliat.setups.boundary_setup.BoundarySetup ¶
BoundarySetup(config: Config, simulation: Simulation, verbose_logger: Logger, progress_logger: Logger)
Bases: BaseSetup
Configures the boundary conditions for the simulation.
Source code in goliat/setups/boundary_setup.py
Methods:¶
setup_boundary_conditions ¶
Configures PML boundary conditions from the solver settings.
Sets the global boundary type (e.g., UPML/CPML) and PML strength (Low/Medium/High) based on the config.
Source code in goliat/setups/boundary_setup.py
Far Field Setup¶
goliat.setups.far_field_setup.FarFieldSetup ¶
FarFieldSetup(config: Config, phantom_name: str, frequency_mhz: int | list[int], direction_name: str, polarization_name: str, project_manager: ProjectManager, verbose_logger: Logger, progress_logger: Logger, profiler: Profiler, gui=None)
Bases: BaseSetup
Configures a far-field simulation for a specific direction and polarization.
Source code in goliat/setups/far_field_setup.py
Methods:¶
run_full_setup ¶
Executes the full setup sequence for a single far-field simulation with granular timing.
Source code in goliat/setups/far_field_setup.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
Gridding Setup¶
goliat.setups.gridding_setup.GriddingSetup ¶
GriddingSetup(config: Config, simulation: Simulation, placement_name: str, antenna: Antenna, verbose_logger: Logger, progress_logger: Logger, frequency_mhz: int | None = None)
Bases: BaseSetup
Configures simulation grid resolution and subgridding.
Sets up main grid (automatic or manual) with padding, and optional antenna-specific subgrids for fine details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
simulation | Simulation | The simulation object to configure gridding for. | required |
placement_name | str | Name of the placement scenario. | required |
antenna | Antenna | Antenna object. | required |
verbose_logger | Logger | Logger for detailed output. | required |
progress_logger | Logger | Logger for progress updates. | required |
frequency_mhz | int | None | Simulation frequency in MHz (optional). | None |
Source code in goliat/setups/gridding_setup.py
Methods:¶
setup_gridding ¶
Sets up main grid and optional antenna subgrids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
antenna_components | dict | None | Dict mapping component names to entities. | None |
Source code in goliat/setups/gridding_setup.py
Material Setup¶
goliat.setups.material_setup.MaterialSetup ¶
MaterialSetup(config: Config, simulation: Simulation, antenna: Antenna, phantom_name: str, verbose_logger: Logger, progress_logger: Logger, free_space: bool = False, frequencies_mhz: list[int] | None = None)
Bases: BaseSetup
Assigns materials to phantom tissues and antenna components.
Maps tissue names to IT'IS database materials and assigns antenna materials from config. Uses file locking for thread-safe database access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
simulation | Simulation | The simulation object to assign materials to. | required |
antenna | Antenna | Antenna object. | required |
phantom_name | str | Name of the phantom model. | required |
verbose_logger | Logger | Logger for detailed output. | required |
progress_logger | Logger | Logger for progress updates. | required |
free_space | bool | Whether this is a free-space simulation. | False |
frequencies_mhz | list[int] | None | List of frequencies for multisine dispersion fitting. | None |
Source code in goliat/setups/material_setup.py
Methods:¶
assign_materials ¶
Assigns materials to simulation entities.
Sets background to Air, then assigns phantom materials if not free-space, and antenna materials if not phantom_only mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
antenna_components | dict | None | Dict mapping component names to entities. | None |
phantom_only | bool | If True, skips antenna material assignment. | False |
Source code in goliat/setups/material_setup.py
Near Field Setup¶
goliat.setups.near_field_setup.NearFieldSetup ¶
NearFieldSetup(config: Config, phantom_name: str, frequency_mhz: int, scenario_name: str, position_name: str, orientation_name: str, antenna: Antenna, verbose_logger: Logger, progress_logger: Logger, profiler: Profiler, gui=None, free_space: bool = False)
Bases: BaseSetup
Configures the simulation environment by coordinating setup modules.
Source code in goliat/setups/near_field_setup.py
Methods:¶
run_full_setup ¶
Executes complete setup sequence with detailed timing.
Orchestrates the entire simulation setup process in 6 major subtasks:
-
Load phantom: Imports phantom model from disk or downloads if missing. Creates head/trunk bounding boxes if needed.
-
Configure scene: Imports antenna, places it relative to phantom, creates simulation bounding box, sets up simulation entity, adds point sensors. Handles special cases like phantom rotation and phone alignment.
-
Assign materials: Maps tissue names to IT'IS database materials, assigns antenna component materials from config. Uses file locking for thread safety.
-
Configure solver: Sets up gridding (automatic or manual with subgrids), configures boundary conditions (PML), and sets up excitation sources.
-
Voxelize: Runs automatic voxelization on all simulation entities, updates materials and grid, optionally exports material properties.
-
Save project: Saves the .smash file to disk.
Each subtask is profiled individually for accurate timing estimates. The method returns a fully configured simulation object ready to run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_manager | ProjectManager | Project manager for saving operations. | required |
lock | Optional lock (currently unused, reserved for future use). | None |
Returns:
| Type | Description |
|---|---|
Simulation | Fully configured simulation object ready for execution. |
Source code in goliat/setups/near_field_setup.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
Phantom Setup¶
goliat.setups.phantom_setup.PhantomSetup ¶
Bases: BaseSetup
Handles loading and importing phantom models into Sim4Life.
Source code in goliat/setups/phantom_setup.py
Methods:¶
ensure_phantom_is_loaded ¶
Checks if phantom is loaded, imports from disk if available, or downloads if missing.
Returns:
| Type | Description |
|---|---|
bool | True if phantom is now loaded, False if download was initiated (requires re-run). |
Source code in goliat/setups/phantom_setup.py
Placement Setup¶
goliat.setups.placement_setup.PlacementSetup ¶
PlacementSetup(config: Config, phantom_name: str, frequency_mhz: int, base_placement_name: str, position_name: str, orientation_name: str, antenna: Antenna, verbose_logger: Logger, progress_logger: Logger, free_space: bool = False)
Bases: BaseSetup
Handles antenna placement and orientation relative to phantom.
Imports antenna model, calculates target position based on placement scenario, and applies composed transformation (stand-up rotation, translation, orientation twists) to position antenna correctly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
phantom_name | str | Name of the phantom model. | required |
frequency_mhz | int | Simulation frequency in MHz. | required |
base_placement_name | str | Base name of the placement scenario. | required |
position_name | str | Name of the position within the scenario. | required |
orientation_name | str | Name of the orientation within the scenario. | required |
antenna | Antenna | Antenna object to place. | required |
verbose_logger | Logger | Logger for detailed output. | required |
progress_logger | Logger | Logger for progress updates. | required |
free_space | bool | Whether this is a free-space simulation. | False |
Source code in goliat/setups/placement_setup.py
Methods:¶
place_antenna ¶
Places and orients antenna using a single composed transformation.
This method implements a key optimization: instead of applying multiple transforms sequentially (which causes precision loss and can accumulate errors), it composes all transformations into a single matrix and applies it once.
The transformation sequence is: 1. Stand-up rotation: Rotates antenna 90° around X-axis to make it upright 2. Base translation: Moves antenna to a reference point (speaker location) 3. Special rotation: For 'by_cheek', applies -90° Z-rotation to align with YZ plane 4. Orientation twists: Applies any rotations specified in orientation config 5. Final translation: Moves antenna to its target position relative to phantom
The order matters because matrix multiplication is not commutative. Each step builds on the previous transform, so the antenna ends up correctly positioned and oriented relative to the phantom regardless of how many rotations are needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
None (uses instance attributes | antenna, placement_name, etc.) | required |
Raises:
| Type | Description |
|---|---|
RuntimeError | If antenna import fails or required entities aren't found. |
Source code in goliat/setups/placement_setup.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
Source Setup¶
goliat.setups.source_setup.SourceSetup ¶
SourceSetup(config: Config, simulation: Simulation, frequency_mhz: int, antenna: Antenna, verbose_logger: Logger, progress_logger: Logger, free_space: bool = False, phantom_name: Optional[str] = None, placement_name: Optional[str] = None)
Bases: BaseSetup
Configures excitation sources and sensors for the simulation.
Source code in goliat/setups/source_setup.py
Methods:¶
setup_source_and_sensors ¶
Sets up the edge source and sensors based on excitation type.
Uses excitation_type from config to determine Harmonic or Gaussian excitation. For free-space simulations, also adds far-field sensors for Gaussian sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
antenna_components | dict | Dict mapping component names to entities. | required |
Source code in goliat/setups/source_setup.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
Execution Strategies¶
Strategy pattern implementations for different simulation execution methods.
Execution Strategy¶
goliat.runners.execution_strategy.ExecutionStrategy ¶
ExecutionStrategy(config: Config, project_path: str, simulation: Simulation, profiler: Profiler, verbose_logger: LoggingMixin, progress_logger: LoggingMixin, project_manager: ProjectManager, gui: QueueGUI | None = None)
Bases: ABC
Abstract base class for simulation execution strategies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
project_path | str | Path to the Sim4Life project file. | required |
simulation | Simulation | The simulation object to run. | required |
profiler | Profiler | Profiler for timing subtasks. | required |
verbose_logger | LoggingMixin | Logger for detailed output. | required |
progress_logger | LoggingMixin | Logger for high-level updates. | required |
project_manager | ProjectManager | ProjectManager instance. | required |
gui | QueueGUI | None | Optional GUI proxy for updates. | None |
Source code in goliat/runners/execution_strategy.py
Isolve Manual Strategy¶
goliat.runners.isolve_manual_strategy.ISolveManualStrategy ¶
Bases: ExecutionStrategy, LoggingMixin
Execution strategy for running iSolve.exe directly via subprocess.
Source code in goliat/runners/isolve_manual_strategy.py
Methods:¶
reset_memory_error_count classmethod ¶
run ¶
Runs iSolve.exe directly with real-time output logging.
This method bypasses Sim4Life's API and runs the solver executable directly. This is useful when you need more control over the execution environment or when the API has issues. The key challenge is capturing output in real-time without blocking the main thread.
The solution uses a background thread with a queue: - A daemon thread reads stdout line-by-line and puts lines into a queue - The main thread polls the queue non-blockingly and logs output - After process completion, remaining output is drained from the queue
This approach allows the GUI to remain responsive and users to see progress updates as they happen. Without threading, reading stdout would block until the process finishes, making it impossible to show real-time progress.
Steps: 1. Locate iSolve.exe relative to Python executable 2. Spawn subprocess with stdout/stderr pipes 3. Start background thread to read stdout into queue 4. Poll process and queue, logging output without blocking 5. After completion, reload project to load results into Sim4Life
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If iSolve.exe or input file not found. |
RuntimeError | If iSolve exits with non-zero code or simulation can't be found after reload. |
Source code in goliat/runners/isolve_manual_strategy.py
Isolve Output Parser¶
goliat.runners.isolve_output_parser.ProgressInfo dataclass ¶
Extracted progress information from iSolve output.
Isolve Process Manager¶
goliat.runners.isolve_process_manager.ISolveProcessManager ¶
ISolveProcessManager(command: List[str], gui: Optional[QueueGUI], verbose_logger: Logger, progress_logger: Logger)
Bases: LoggingMixin
Manages iSolve subprocess lifecycle and non-blocking I/O.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | List[str] | Command to execute (e.g., [isolve_path, "-i", input_file]). | required |
gui | Optional[QueueGUI] | GUI proxy for stop signal checks. | required |
verbose_logger | Logger | Logger for verbose output. | required |
progress_logger | Logger | Logger for progress output. | required |
Source code in goliat/runners/isolve_process_manager.py
Methods:¶
start ¶
Start the subprocess and begin reading output.
Source code in goliat/runners/isolve_process_manager.py
is_running ¶
read_available_lines ¶
Read all available lines from output queue (non-blocking).
Returns:
| Type | Description |
|---|---|
List[str] | List of lines read (may be empty if no output available). |
Source code in goliat/runners/isolve_process_manager.py
read_all_remaining_lines ¶
Read all remaining lines after process completes.
Should be called after is_running() returns False. Ensures reader thread has finished and queue is drained.
Returns:
| Type | Description |
|---|---|
List[str] | List of all remaining lines. |
Source code in goliat/runners/isolve_process_manager.py
get_return_code ¶
read_stderr ¶
Read stderr output (fallback - most errors are in stdout).
Returns:
| Type | Description |
|---|---|
str | Stripped stderr string or empty string. |
Source code in goliat/runners/isolve_process_manager.py
terminate ¶
Terminate process, force kill if it doesn't stop in time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout | float | Seconds to wait before force killing. | 2.0 |
Source code in goliat/runners/isolve_process_manager.py
cleanup ¶
Clean up process and threads.
Source code in goliat/runners/isolve_process_manager.py
check_stop_signal ¶
Check for stop signal and terminate if requested.
Raises:
| Type | Description |
|---|---|
StudyCancelledError | If stop signal detected. |
Source code in goliat/runners/isolve_process_manager.py
Keep Awake Handler¶
goliat.runners.keep_awake_handler.KeepAwakeHandler ¶
Handles keep_awake script triggering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
Source code in goliat/runners/keep_awake_handler.py
Methods:¶
trigger_before_retry ¶
Trigger keep_awake before retry attempt.
Source code in goliat/runners/keep_awake_handler.py
trigger_on_progress ¶
Trigger keep_awake script on first progress update.
Source code in goliat/runners/keep_awake_handler.py
Osparc Direct Strategy¶
goliat.runners.osparc_direct_strategy.OSPARCDirectStrategy ¶
Bases: ExecutionStrategy, LoggingMixin
Execution strategy for submitting simulations to oSPARC cloud platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_name | str | oSPARC resource name to use (e.g., 'local', 'osparc-1'). | required |
*args | Passed to parent class. | () | |
**kwargs | Passed to parent class. | {} |
Source code in goliat/runners/osparc_direct_strategy.py
Methods:¶
run ¶
Submits simulation directly to oSPARC cloud platform.
This method handles cloud-based simulation execution through the oSPARC platform. Instead of running locally, it uploads the solver input file to oSPARC, submits a job, and polls for completion.
The process: 1. Initializes oSPARC API client using credentials from config 2. Creates a job submission with input file path and resource name 3. Submits job and waits for completion (polls status periodically) 4. Downloads results when job completes successfully 5. Reloads project to load results into Sim4Life
This requires Sim4Life 9.2+ for the XOsparcApiClient module. The method handles authentication, job lifecycle, and error reporting.
Raises:
| Type | Description |
|---|---|
RuntimeError | If API client unavailable, job creation fails, job completes with non-success status, or simulation can't be found after reload. |
FileNotFoundError | If solver input file not found. |
ValueError | If oSPARC credentials are missing from config. |
Source code in goliat/runners/osparc_direct_strategy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
Post Simulation Handler¶
goliat.runners.post_simulation_handler.PostSimulationHandler ¶
PostSimulationHandler(project_path: str, profiler: Profiler, verbose_logger: Logger, progress_logger: Logger)
Bases: LoggingMixin
Handles post-simulation tasks: waiting for results and reloading project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path | str | Path to project file to reload. | required |
profiler | Profiler | Profiler for timing subtasks. | required |
verbose_logger | Logger | Logger for verbose output. | required |
progress_logger | Logger | Logger for progress output. | required |
Source code in goliat/runners/post_simulation_handler.py
Methods:¶
wait_and_reload ¶
Wait for results and reload project.
Waits 5 seconds for results to be written, then closes and reopens the project to load results into Sim4Life. Only reloads if memory usage is above 60% to free memory.
Source code in goliat/runners/post_simulation_handler.py
Retry Handler¶
goliat.runners.retry_handler.RetryHandler ¶
Bases: LoggingMixin
Manages retry logic and attempt tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_logger | Logger | Logger for progress-level messages. | required |
gui | Optional[QueueGUI] | Optional GUI proxy for sending progress messages. | None |
Source code in goliat/runners/retry_handler.py
Methods:¶
should_retry ¶
Determine if retry should occur.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_code | Optional[int] | Process return code (None if exception). | required |
detected_errors | list | List of errors detected in output. | required |
Returns:
| Type | Description |
|---|---|
bool | True if should retry (always True for non-zero return code). |
Source code in goliat/runners/retry_handler.py
record_attempt ¶
Record a retry attempt and log it.
Source code in goliat/runners/retry_handler.py
get_attempt_number ¶
Sim4Life Api Strategy¶
goliat.runners.sim4life_api_strategy.Sim4LifeAPIStrategy ¶
Bases: ExecutionStrategy, LoggingMixin
Execution strategy for running simulations via Sim4Life API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id | str | None | Server ID to use (None for localhost). | required |
*args | Passed to parent class. | () | |
**kwargs | Passed to parent class. | {} |
Source code in goliat/runners/sim4life_api_strategy.py
Methods:¶
run ¶
Run simulation using Sim4Life API.
Raises:
| Type | Description |
|---|---|
RuntimeError | If simulation execution fails. |
Source code in goliat/runners/sim4life_api_strategy.py
Results Extraction¶
Classes for extracting and processing simulation results.
Auto Induced Processor¶
goliat.extraction.auto_induced_processor.AutoInducedProcessor ¶
Bases: LoggingMixin, _AutoInducedExtractionMixin
Processes auto-induced exposure using existing SAPD extraction infrastructure.
Orchestrates focus search, field combination, and SAPD extraction for a completed set of environmental simulations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_study | FarFieldStudy | Parent FarFieldStudy instance (provides loggers, profiler, config). | required |
phantom_name | str | Name of the phantom (e.g., "thelonious"). | required |
freq | int | Frequency in MHz. | required |
Source code in goliat/extraction/auto_induced_processor.py
Methods:¶
process ¶
Run the auto-induced analysis pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_paths | list[Path] | List of _Output.h5 file paths (one per direction/polarization). | required |
input_h5 | Path | Path to any _Input.h5 file (for skin mask extraction). | required |
output_dir | Path | Directory to write combined H5 files and results. | required |
Returns:
| Type | Description |
|---|---|
dict | Dict with analysis results including candidates, SAPD values, and worst-case. |
Source code in goliat/extraction/auto_induced_processor.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
Cleaner¶
goliat.extraction.cleaner.Cleaner ¶
Manages deletion of simulation files to free disk space.
Deletes output files, input files, and/or project files based on config. Useful for long-running studies where disk space is limited.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
Source code in goliat/extraction/cleaner.py
Methods:¶
cleanup_simulation_files ¶
Deletes simulation files based on auto_cleanup config.
Removes files matching specified patterns (output/input H5 files, project files). Only runs if cleanup is enabled in config.
Source code in goliat/extraction/cleaner.py
Field Combiner¶
goliat.extraction.field_combiner.FieldCombineConfig dataclass ¶
FieldCombineConfig(h5_paths: Sequence[Path], weights: ndarray, template_h5_path: Path, output_h5_path: Path, field_types: Sequence[str] = ('E', 'H'))
Configuration for field combination operations.
Field Reader¶
goliat.extraction.field_reader ¶
Utilities for reading E/H fields from Sim4Life _Output.h5 files.
Supports memory-efficient reading for auto-induced exposure calculations: - Read fields at specific voxel indices (skin-only extraction) - Read fields in z-slab chunks (for full-field combination) - Handle Yee grid staggering (Nx-1, Ny-1, Nz-1 per component)
Functions:¶
find_overall_field_group ¶
Find the FieldGroup containing 'Overall Field'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f | File | Open h5py File object. | required |
Returns:
| Type | Description |
|---|---|
Optional[str] | Path to the FieldGroup (e.g., 'FieldGroups/0') or None if not found. |
Source code in goliat/extraction/field_reader.py
get_field_path ¶
Get the HDF5 path for E or H field data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fg_path | str | Path to the FieldGroup. | required |
field_type | str | 'E' for electric field, 'H' for magnetic field. | 'E' |
Returns:
| Type | Description |
|---|---|
str | Path to the field's Snapshots/0 group containing comp0/comp1/comp2. |
Source code in goliat/extraction/field_reader.py
read_field_component ¶
read_field_component(f: File, field_path: str, component: int, z_slice: Optional[slice] = None) -> np.ndarray
Read a single field component as complex array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f | File | Open h5py File object. | required |
field_path | str | Path to the Snapshots/0 group. | required |
component | int | 0, 1, or 2 for x, y, z component. | required |
z_slice | Optional[slice] | Optional slice for z-axis (for chunked reading). | None |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray | Complex64 array of shape (Nx, Ny, Nz) or (Nx, Ny, Nz_chunk). | |
Note | ndarray | Dimensions vary due to Yee staggering. |
Source code in goliat/extraction/field_reader.py
read_field_at_indices ¶
read_field_at_indices(h5_path: Union[str, Path], indices: ndarray, field_type: str = 'E') -> np.ndarray
Read field values at specific voxel indices.
Optimized for reading fields only at skin voxel locations. Uses single-point h5py reads for small N, vectorized reads for large N.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_path | Union[str, Path] | Path to _Output.h5 file. | required |
indices | ndarray | Array of shape (N, 3) with [ix, iy, iz] indices. | required |
field_type | str | 'E' or 'H'. | 'E' |
Returns:
| Type | Description |
|---|---|
ndarray | Complex64 array of shape (N, 3) with [Ex, Ey, Ez] or [Hx, Hy, Hz]. |
Note
Due to Yee staggering, we use the voxel center approximation. For component i, data shape is (N-1) in dimension i. We clamp indices to valid range.
Source code in goliat/extraction/field_reader.py
read_field_chunk ¶
read_field_chunk(h5_path: Union[str, Path], z_start: int, z_end: int, field_type: str = 'E') -> Tuple[np.ndarray, np.ndarray, np.ndarray]
Read a z-slab chunk of the field.
For memory-efficient full-field combination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_path | Union[str, Path] | Path to _Output.h5 file. | required |
z_start | int | Start z-index (inclusive). | required |
z_end | int | End z-index (exclusive). | required |
field_type | str | 'E' or 'H'. | 'E' |
Returns:
| Type | Description |
|---|---|
ndarray | Tuple of (comp0, comp1, comp2) complex64 arrays. |
ndarray | Shapes vary due to Yee staggering: |
ndarray |
|
Tuple[ndarray, ndarray, ndarray] |
|
Tuple[ndarray, ndarray, ndarray] |
|
Source code in goliat/extraction/field_reader.py
read_full_field ¶
read_full_field(h5_path: Union[str, Path], field_type: str = 'E') -> Tuple[np.ndarray, np.ndarray, np.ndarray]
Read the entire E or H field.
Warning: Can be very memory intensive (~2GB for typical phantom).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_path | Union[str, Path] | Path to _Output.h5 file. | required |
field_type | str | 'E' or 'H'. | 'E' |
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray, ndarray] | Tuple of (comp0, comp1, comp2) complex64 arrays. |
Source code in goliat/extraction/field_reader.py
get_field_shape ¶
Get the grid shape from an _Output.h5 file.
Returns the node count (Nx, Ny, Nz), not voxel count. Field components have shapes (Nx-1, Ny, Nz), etc. due to Yee grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_path | Union[str, Path] | Path to _Output.h5 file. | required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int] | Tuple (Nx, Ny, Nz) - node counts. |
Source code in goliat/extraction/field_reader.py
Field Cache¶
goliat.extraction.field_cache.FieldCache ¶
FieldCache(h5_paths: Sequence[Union[str, Path]], field_type: str = 'E', low_memory: Optional[bool] = None, slab_cache_gb: float = DEFAULT_SLAB_CACHE_GB)
Cache for pre-loaded E-field data from multiple H5 files.
Supports three modes: - Memory mode (default): Load all fields into RAM for fast access. Best when you have enough RAM to hold all field data (~3 min). - Streaming mode (optimized): Uses slab-based LRU cache for efficient disk access. Much faster than naive streaming (~10-30 min vs 42 hours). - Legacy streaming mode: Single-point reads (extremely slow, deprecated).
Mode is automatically selected based on available RAM, or can be forced via the low_memory parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_paths | Sequence[Union[str, Path]] | Paths to _Output.h5 files. | required |
field_type | str | 'E' or 'H'. | 'E' |
low_memory | Optional[bool] | If True, use streaming mode (no pre-loading). If False, always use memory mode (may cause paging on low-RAM). If None (default), auto-detect based on available RAM. | None |
slab_cache_gb | float | Size of slab LRU cache in GB (only for streaming mode). | DEFAULT_SLAB_CACHE_GB |
Source code in goliat/extraction/field_cache.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
Methods:¶
read_at_indices ¶
Read field values at specific indices.
In memory mode, reads from pre-loaded cached data. In streaming mode, uses slab-based caching for efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h5_path | str | Which file to read from. | required |
indices | ndarray | (N, 3) array of [ix, iy, iz] indices. | required |
Returns:
| Type | Description |
|---|---|
ndarray | (N, 3) complex array of field values. |
Source code in goliat/extraction/field_cache.py
get_cache_stats ¶
Get slab cache statistics (streaming mode only).
close ¶
Close open file handles (streaming mode cleanup).
Focus Optimizer¶
Json Encoder¶
goliat.extraction.json_encoder.NumpyArrayEncoder ¶
Power Extractor¶
goliat.extraction.power_extractor.PowerExtractor ¶
Bases: LoggingMixin
Extracts input power and power balance from simulation results.
For near-field, reads power from port sensors. For far-field, calculates theoretical power from plane wave parameters. Also extracts power balance to verify energy conservation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
results_data | dict | Dict to store extracted power data. | required |
Source code in goliat/extraction/power_extractor.py
Methods:¶
extract_input_power ¶
Extracts input power, delegating to study-type specific methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_extractor | Extractor | Results extractor from the simulation. | required |
Source code in goliat/extraction/power_extractor.py
extract_power_balance ¶
Extracts power balance to verify energy conservation.
Power balance is a sanity check: the power going into the simulation should equal the power coming out (as losses and radiation). This helps catch numerical errors or convergence issues.
The balance is calculated as: balance = (P_out / P_in) × 100%
Where P_out includes: - Dielectric losses (power absorbed by materials) - Radiated power (power escaping the simulation volume)
For far-field studies, uses the theoretical input power (from plane wave calculation) rather than extracted power, since plane waves don't have a traditional "input port" sensor.
A balance close to 100% indicates good energy conservation. Values significantly different suggest convergence issues or numerical errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_extractor | Extractor | Results extractor from the simulation. | required |
Source code in goliat/extraction/power_extractor.py
Reporter¶
goliat.extraction.reporter.Reporter ¶
Generates and saves detailed reports from extraction results.
Creates Pickle files for programmatic access and HTML files for human readability. Includes SAR statistics, tissue groups, and peak SAR details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
Source code in goliat/extraction/reporter.py
Methods:¶
save_reports ¶
Saves Pickle and HTML reports to the results directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | DataFrame with detailed SAR statistics per tissue. | required |
tissue_groups | dict | Dict mapping group names to tissue lists. | required |
group_sar_stats | dict | Dict with aggregated SAR stats per group. | required |
results_data | dict | Dict with summary results and metadata. | required |
Source code in goliat/extraction/reporter.py
Resonance Extractor¶
goliat.extraction.resonance_extractor.ResonanceExtractor ¶
Bases: LoggingMixin
Extracts antenna resonance frequency and detuning from Gaussian pulse results.
Analyzes frequency-dependent accepted power to identify resonance peak and calculates detuning relative to nominal frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
results_data | dict | Dict to store extracted resonance data. | required |
Source code in goliat/extraction/resonance_extractor.py
Methods:¶
extract_resonance_frequency ¶
Extract antenna resonant frequency from Gaussian pulse results.
Analyzes frequency-dependent accepted power to identify resonance peak. Calculates detuning relative to nominal frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_extractor | Extractor | Results extractor from the simulation. | required |
Returns:
| Name | Type | Description |
|---|---|---|
dict | Contains resonant_freq_mhz, detuning_mhz, max_power_w, freq_resolution_mhz |
Source code in goliat/extraction/resonance_extractor.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
Sapd Extractor¶
goliat.extraction.sapd_extractor.SapdExtractionContext dataclass ¶
SapdExtractionContext(center_m: Optional[List[float]] = None, sliced_h5_path: Optional[str] = None, sliced_extractor: Optional[Any] = None, active_extractor: Optional[Any] = None, em_sensor_extractor: Optional[Any] = None, model_to_grid_filter: Optional[Any] = None, sapd_evaluator: Optional[Any] = None, sapd_field_evaluator: Optional[Any] = None)
Holds state during SAPD extraction to reduce method parameters.
Sar Extractor¶
goliat.extraction.sar_extractor.SarExtractor ¶
Bases: LoggingMixin
Extracts SAR statistics from simulation results.
Uses Sim4Life's SarStatisticsEvaluator to compute mass-averaged SAR, peak spatial-average SAR (10g), and tissue-specific metrics. Groups tissues into logical groups (eyes, skin, brain) for analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
results_data | dict | Dict to store extracted SAR data. | required |
Source code in goliat/extraction/sar_extractor.py
Methods:¶
extract_sar_statistics ¶
Extracts SAR statistics for all tissues.
This is the main SAR extraction method that orchestrates the entire process. It uses Sim4Life's SarStatisticsEvaluator to compute standardized SAR metrics according to IEEE/IEC standards.
The process: 1. Extracts the 'Overall Field' E-field data from simulation results 2. Creates a SarStatisticsEvaluator configured for 10g peak spatial-average SAR 3. Processes the evaluator output into a pandas DataFrame 4. Groups tissues into logical categories (eyes, skin, brain) 5. Calculates weighted-average SAR for each group (mass-weighted) 6. Extracts peak SAR details (location, coordinates, etc.) 7. Stores both per-tissue and group-level results
The results include mass-averaged SAR, peak spatial-average SAR (10g), and tissue-specific metrics. For near-field studies, also extracts head/trunk SAR based on placement scenario. For far-field, extracts whole-body SAR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_extractor | Extractor | Results extractor from the simulation object. | required |
Source code in goliat/extraction/sar_extractor.py
extract_peak_sar_details ¶
Extracts detailed metadata about the peak spatial-average SAR location.
While the main SAR extraction gives per-tissue statistics, this method provides detailed information about where the absolute peak SAR occurs. This includes 3D coordinates, the tissue/organ containing the peak, mass of the 10g averaging volume, and other metadata.
This information is useful for: - Understanding which anatomical region has the highest exposure - Verifying that peak SAR is in an expected location - Debugging unexpected SAR hotspots - Reporting peak exposure location in compliance documentation
Uses Sim4Life's AverageSarFieldEvaluator configured for 10g spatial averaging to find the peak location according to IEEE/IEC 62704-1 standards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
em_sensor_extractor | Extractor | The 'Overall Field' results extractor containing the SAR field data. | required |
Source code in goliat/extraction/sar_extractor.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
Sensor Extractor¶
goliat.extraction.sensor_extractor.SensorExtractor ¶
Extracts time-domain E-field data from point sensors.
Reads E-field measurements from sensors placed at simulation bbox corners, creates plots showing magnitude over time, and stores raw data in results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent | ResultsExtractor | Parent ResultsExtractor instance. | required |
results_data | dict | Dict to store extracted data. | required |
Source code in goliat/extraction/sensor_extractor.py
Methods:¶
extract_point_sensor_data ¶
Extracts E-field data from all point sensors and generates plots.
Iterates through configured sensors, extracts time-domain E-field components (Ex, Ey, Ez), calculates magnitude, and saves both plot and raw data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_extractor | Extractor | Results extractor from the simulation object. | required |
Source code in goliat/extraction/sensor_extractor.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
Tissue Grouping¶
goliat.extraction.tissue_grouping.TissueGrouper ¶
Handles grouping of tissues into logical categories for SAR analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object for accessing material mappings. | required |
phantom_name | str | Name of the phantom model. | required |
logger | LoggingMixin | Logger instance for logging messages. | required |
Source code in goliat/extraction/tissue_grouping.py
Methods:¶
group_tissues ¶
Groups tissues according to material_name_mapping.json.
Simple matching: tissue_name -> material_name -> entity_name -> check group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available_tissues | list[str] | List of tissue names found in the simulation results. | required |
Returns:
| Type | Description |
|---|---|
dict[str, list[str]] | Dict mapping group names to lists of tissue names that belong to that group. |
dict[str, list[str]] | Empty groups are still included but with empty lists. |
Source code in goliat/extraction/tissue_grouping.py
Analysis¶
Classes for analyzing and visualizing simulation results.
Analyze Simulation Stats¶
goliat.analysis.analyze_simulation_stats ¶
Analyze Near-Field simulation logs and create professional, client-ready visualizations.
IMPROVEMENTS: - Strict filtering for Near Field simulations only. - Emojis removed to prevent font rendering errors. - "High-End Engineering" aesthetic (professional dark theme). - Dynamic layout scaling for lists with many items. - Robust text placement to avoid overlap.
Functions:¶
find_all_verbose_logs ¶
Find all verbose.log files in the results directory.
parse_all_logs ¶
Parse all verbose.log files and return list of metrics.
Source code in goliat/analysis/analyze_simulation_stats.py
compute_aggregate_stats ¶
Compute aggregate statistics across all simulations.
Source code in goliat/analysis/analyze_simulation_stats.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
format_large_number ¶
Format large numbers with K/M/B suffixes.
Source code in goliat/analysis/analyze_simulation_stats.py
set_custom_style ¶
Set a professional, high-contrast engineering dark style.
Source code in goliat/analysis/analyze_simulation_stats.py
create_visualizations ¶
Create all visualizations with rigorous layout checks.
Source code in goliat/analysis/analyze_simulation_stats.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | |
main ¶
CLI entry point. Parses logs and generates stats/plots.
Source code in goliat/analysis/analyze_simulation_stats.py
Analyzer¶
goliat.analysis.analyzer.Analyzer ¶
Analyzer(config: Config, phantom_name: str, strategy: BaseAnalysisStrategy, plot_format: str = 'pdf')
Analyzes simulation results using a strategy pattern.
Delegates to strategy-specific implementations for loading results and generating plots. Handles unit conversion, caching, and report export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
phantom_name | str | Phantom model name being analyzed. | required |
strategy | BaseAnalysisStrategy | Strategy implementation for analysis logic. | required |
plot_format | str | Output format for plots ('pdf' or 'png'), default 'pdf'. | 'pdf' |
Source code in goliat/analysis/analyzer.py
Methods:¶
run_analysis ¶
Runs complete analysis pipeline using the selected strategy.
Loads results, converts units, exports reports, and generates plots. Delegates strategy-specific logic to the strategy instance.
Source code in goliat/analysis/analyzer.py
Base Strategy¶
goliat.analysis.base_strategy.BaseAnalysisStrategy ¶
Bases: ABC
Base class for analysis strategies.
Defines interface for loading results, calculating normalization factors, and generating plots. Subclasses implement study-type specific logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
phantom_name | str | Phantom model name being analyzed. | required |
analysis_config | dict | None | Optional dictionary with plot names as keys and boolean values. | None |
Source code in goliat/analysis/base_strategy.py
Methods:¶
should_generate_plot ¶
Checks if a plot should be generated based on the analysis config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_name | str | Name of the plot to check. | required |
Returns:
| Type | Description |
|---|---|
bool | True if the plot should be generated (default if not in config), False otherwise. |
Source code in goliat/analysis/base_strategy.py
get_expected_item_count ¶
Returns expected number of progress items for this phantom.
This is used by the GUI to set an accurate progress bar maximum. Each item corresponds to one progress log message (Processing, Generating plot, etc.).
Returns:
| Type | Description |
|---|---|
int | Expected number of items that will trigger progress updates. |
Source code in goliat/analysis/base_strategy.py
get_results_base_dir ¶
get_plots_dir ¶
load_and_process_results abstractmethod ¶
Loads and processes all simulation results.
Iterates through configured scenarios and calls analyzer._process_single_result() for each one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analyzer | Analyzer | Analyzer instance to process results with. | required |
Source code in goliat/analysis/base_strategy.py
get_normalization_factor abstractmethod ¶
Calculates SAR normalization factor from simulated power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequency_mhz | int | Simulation frequency in MHz. | required |
simulated_power_w | float | Input power from simulation in Watts. | required |
Returns:
| Type | Description |
|---|---|
float | Normalization factor to multiply SAR values by. |
Source code in goliat/analysis/base_strategy.py
extract_data abstractmethod ¶
extract_data(pickle_data: dict, frequency_mhz: int, placement_name: str, scenario_name: str, sim_power: float, norm_factor: float, sar_results: dict | None = None, sapd_results: dict | None = None) -> tuple[dict, list]
Extracts and structures data from a single simulation's result files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pickle_data | dict | Data loaded from the .pkl result file. | required |
frequency_mhz | int | Simulation frequency. | required |
placement_name | str | Detailed placement name. | required |
scenario_name | str | General scenario name. | required |
sim_power | float | Simulated input power in Watts. | required |
norm_factor | float | Normalization factor to apply. | required |
sar_results | dict | None | Optional JSON results dict containing additional data like power balance. | None |
sapd_results | dict | None | Optional SAPD JSON results dict (present when sapd=true in config). | None |
Returns:
| Type | Description |
|---|---|
tuple[dict, list] | Tuple of (main result entry dict, list of organ-specific entries). |
Source code in goliat/analysis/base_strategy.py
apply_bug_fixes abstractmethod ¶
Applies workarounds for known data inconsistencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_entry | dict | Data entry for a single simulation result. | required |
Returns:
| Type | Description |
|---|---|
dict | Corrected result entry. |
Source code in goliat/analysis/base_strategy.py
calculate_summary_stats abstractmethod ¶
Calculates summary statistics from aggregated results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with all aggregated simulation results. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame with summary statistics. |
Source code in goliat/analysis/base_strategy.py
generate_plots abstractmethod ¶
generate_plots(analyzer: Analyzer, plotter: Plotter, results_df: DataFrame, all_organ_results_df: DataFrame)
Generates study-type specific plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analyzer | Analyzer | Analyzer instance with aggregated data. | required |
plotter | Plotter | Plotter instance for creating figures. | required |
results_df | DataFrame | DataFrame with summary results. | required |
all_organ_results_df | DataFrame | DataFrame with organ-level details. | required |
Source code in goliat/analysis/base_strategy.py
Compare¶
goliat.analysis.compare ¶
Compare UGent and CNR data from Excel files and create comparison plots.
This module provides functionality to compare SAR data between different institutions (UGent and CNR) and create publication-quality comparison plots.
Functions:¶
load_comparison_data ¶
Load all data from both Excel files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ugent_file | str | Path to UGent Excel file | required |
cnr_file | str | Path to CNR Excel file | required |
Returns:
| Type | Description |
|---|---|
DataFrame | Combined DataFrame with all data |
Source code in goliat/analysis/compare.py
create_comparison_plots ¶
Create comparison plots for all metrics and scenarios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Combined DataFrame with UGent and CNR data | required |
output_dir | Path | Directory to save plots | required |
plot_format | str | Output format ('pdf' or 'png') | 'pdf' |
Source code in goliat/analysis/compare.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
create_summary_comparison_plots ¶
Create summary comparison plots across all scenarios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Combined DataFrame with UGent and CNR data | required |
output_dir | Path | Directory to save plots | required |
plot_format | str | Output format ('pdf' or 'png') | 'pdf' |
Source code in goliat/analysis/compare.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
run_comparison ¶
Run the full comparison analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ugent_file | str | Path to UGent Excel file | required |
cnr_file | str | Path to CNR Excel file | required |
output_dir | str | Directory to save comparison plots | required |
plot_format | str | Output format ('pdf' or 'png') | 'pdf' |
Source code in goliat/analysis/compare.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
main ¶
Main entry point for CLI usage.
Source code in goliat/analysis/compare.py
Create Excel For Partners¶
goliat.analysis.create_excel_for_partners ¶
Create Excel file matching CNR's Excel format for Thelonious and Eartha phantoms.
Functions:¶
get_target_power_mapping ¶
Read target power values from config file for each frequency.
Source code in goliat/analysis/create_excel_for_partners.py
map_placement_name ¶
Map placement names to match CNR's Excel format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
placement | str | Original placement name from CSV | required |
sheet_type | str | One of 'fronteyes', 'belly', or 'cheek' | required |
Returns:
| Type | Description |
|---|---|
str | Mapped placement name matching CNR's Excel format |
Source code in goliat/analysis/create_excel_for_partners.py
create_sheet_data ¶
Create data for one sheet matching CNR's Excel format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Source DataFrame from CSV | required |
sheet_type | str | One of 'fronteyes', 'belly', or 'cheek' | required |
power_mapping | dict[int, int] | Dictionary mapping frequency (MHz) to target power (mW) | required |
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame formatted to match CNR's Excel sheet format |
Source code in goliat/analysis/create_excel_for_partners.py
create_cnr_excel ¶
Create Excel file matching CNR's Excel format for a phantom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phantom_name | str | Name of the phantom (e.g., 'thelonious', 'eartha') | required |
csv_path | str | Path to normalized_results_detailed.csv | required |
config_path | str | Path to config JSON file with antenna_config | required |
output_path | str | Path where Excel file should be saved | required |
Source code in goliat/analysis/create_excel_for_partners.py
main ¶
Main function to create a single Excel file matching CNR's Excel format for both phantoms.
Source code in goliat/analysis/create_excel_for_partners.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
Far Field Strategy¶
goliat.analysis.far_field_strategy.FarFieldAnalysisStrategy ¶
Bases: BaseAnalysisStrategy
Analysis strategy for far-field simulations.
Handles result loading, normalization, and plot generation for far-field studies with incident directions and polarizations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
phantom_name | str | Phantom model name being analyzed. | required |
analysis_config | dict | None | Optional dictionary with plot names as keys and boolean values. | None |
Source code in goliat/analysis/far_field_strategy.py
Methods:¶
get_results_base_dir ¶
get_plots_dir ¶
get_expected_item_count ¶
Returns expected number of progress items for this phantom.
Returns the EXACT count of processing items (result files to be processed). If load_data is False (cache mode), returns 0 since no processing occurs. Plot items are not counted - the GUI handles this via dynamic maximum adjustment.
Returns:
| Type | Description |
|---|---|
int | Exact number of result files that will trigger 'Processing:' log messages. |
Source code in goliat/analysis/far_field_strategy.py
load_and_process_results ¶
Iterates through far-field results and processes each one.
Source code in goliat/analysis/far_field_strategy.py
get_normalization_factor ¶
Returns normalization factor for far-field.
Far-field simulations run at E = 1 V/m (power density = 1.326 mW/m²). To normalize to 1 W/m² (our "1 W" convention for comparison with near-field), we scale by 754 (since SAR scales as E², and E for 1 W/m² is 27.46 V/m).
The factor is 1 / (1 / (2 * 376.73)) = 753.46, rounded to 754.
Source code in goliat/analysis/far_field_strategy.py
extract_data ¶
extract_data(pickle_data: dict, frequency_mhz: int, placement_name: str, scenario_name: str, sim_power: float, norm_factor: float, sar_results: dict | None = None, sapd_results: dict | None = None) -> tuple[dict, list]
Extract and normalize SAR data from pickle file for far-field results.
Source code in goliat/analysis/far_field_strategy.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
apply_bug_fixes ¶
calculate_summary_stats ¶
Calculates summary statistics for far-field results.
Source code in goliat/analysis/far_field_strategy.py
generate_plots ¶
generate_plots(analyzer: Analyzer, plotter: Plotter, results_df: DataFrame, all_organ_results_df: DataFrame)
Generates all plots for far-field analysis.
Includes bar charts, line plots, boxplots, heatmaps, ranking plots, CDF plots, correlation matrices, bubble plots, and tissue analysis.
Source code in goliat/analysis/far_field_strategy.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
Near Field Strategy¶
goliat.analysis.near_field_strategy.NearFieldAnalysisStrategy ¶
Bases: BaseAnalysisStrategy
Analysis strategy for near-field simulations.
Handles result loading, normalization, and plot generation for near-field studies with placement scenarios, positions, and orientations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Config | Configuration object. | required |
phantom_name | str | Phantom model name being analyzed. | required |
analysis_config | dict | None | Optional dictionary with plot names as keys and boolean values. | None |
Source code in goliat/analysis/near_field_strategy.py
Methods:¶
get_results_base_dir ¶
get_plots_dir ¶
get_expected_item_count ¶
Returns expected number of progress items for this phantom.
Returns the EXACT count of processing items (result files to be processed). If load_data is False (cache mode), returns 0 since no processing occurs. Plot items are not counted - the GUI handles this via dynamic maximum adjustment.
Returns:
| Type | Description |
|---|---|
int | Exact number of result files that will trigger 'Processing:' log messages. |
Source code in goliat/analysis/near_field_strategy.py
load_and_process_results ¶
Iterates through near-field results and processes each one.
Source code in goliat/analysis/near_field_strategy.py
get_normalization_factor ¶
Calculates the normalization factor based on the target power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequency_mhz | int | The simulation frequency in MHz. | required |
simulated_power_w | float | The input power from the simulation in Watts. | required |
Returns:
| Type | Description |
|---|---|
float | The calculated normalization factor, or 1.0 if not possible. |
Source code in goliat/analysis/near_field_strategy.py
extract_data ¶
extract_data(pickle_data: dict, frequency_mhz: int, placement_name: str, scenario_name: str, sim_power: float, norm_factor: float, sar_results: dict | None = None, sapd_results: dict | None = None) -> tuple[dict, list]
Extracts and normalizes SAR and SAPD data from a single near-field result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pickle_data | dict | Data loaded from the .pkl result file. | required |
frequency_mhz | int | The simulation frequency. | required |
placement_name | str | The detailed name of the placement. | required |
scenario_name | str | The general scenario name (e.g., 'by_cheek'). | required |
sim_power | float | The simulated input power in Watts. | required |
norm_factor | float | The normalization factor to apply to SAR values. | required |
sar_results | dict | None | Optional JSON results dict containing power balance data. | None |
sapd_results | dict | None | Optional SAPD JSON results dict (present when sapd=true in config). | None |
Returns:
| Type | Description |
|---|---|
tuple[dict, list] | A tuple containing the main result entry and a list of organ-specific entries. |
Source code in goliat/analysis/near_field_strategy.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
apply_bug_fixes ¶
Applies a workaround for Head SAR being miscategorized as Trunk SAR.
NOTE: This method is deprecated for whole_body bounding box scenarios. For whole_body scenarios, SAR_head and SAR_trunk should remain NA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_entry | dict | The data entry for a single simulation result. | required |
Returns:
| Type | Description |
|---|---|
dict | The corrected result entry. |
Source code in goliat/analysis/near_field_strategy.py
calculate_summary_stats ¶
Calculates summary statistics, including completion progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with all aggregated simulation results. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | A DataFrame with mean SAR values and a 'progress' column. |
Source code in goliat/analysis/near_field_strategy.py
generate_plots ¶
generate_plots(analyzer: Analyzer, plotter: Plotter, results_df: DataFrame, all_organ_results_df: DataFrame)
Generates all plots for the near-field analysis.
Includes bar charts for average SAR, line plots for psSAR, and boxplots for SAR distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analyzer | Analyzer | The main analyzer instance. | required |
plotter | Plotter | The plotter instance for generating plots. | required |
results_df | DataFrame | DataFrame with main aggregated results. | required |
all_organ_results_df | DataFrame | DataFrame with detailed organ-level results. | required |
Source code in goliat/analysis/near_field_strategy.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 | |
Parallel Plot Executor¶
goliat.analysis.parallel_plot_executor.ParallelPlotExecutor ¶
Executes plot generation tasks in parallel using process pool.
Uses ProcessPoolExecutor for plot generation tasks to ensure full isolation of matplotlib state, avoiding thread-safety issues with rcParams and backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_workers | int | None | Maximum number of worker processes. If None, uses default (typically os.cpu_count()). | None |
Source code in goliat/analysis/parallel_plot_executor.py
Methods:¶
execute_plots ¶
execute_plots(plot_tasks: list[tuple[Callable, tuple, dict]], task_descriptions: list[str] | None = None)
Execute multiple plot generation tasks in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_tasks | list[tuple[Callable, tuple, dict]] | List of (function, args_tuple, kwargs_dict) tuples. | required |
task_descriptions | list[str] | None | Optional list of task descriptions for logging. If None, uses function names. | None |
Returns:
| Type | Description |
|---|---|
| List of results (or exceptions) in completion order. |
Source code in goliat/analysis/parallel_plot_executor.py
Parse Verbose Log¶
goliat.analysis.parse_verbose_log ¶
Parse verbose.log files to extract simulation metrics into JSON format.
This script extracts all key metrics from GOLIAT/Sim4Life verbose logs for reporting and analysis purposes.
Functions:¶
parse_verbose_log ¶
Parse a verbose.log file and extract all simulation metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_path | str | Path | Path to the verbose.log file | required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | Dictionary containing all extracted metrics |
Source code in goliat/analysis/parse_verbose_log.py
parse_and_save ¶
Parse a verbose.log file and save metrics to JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_path | str | Path | Path to the verbose.log file | required |
output_path | str | Path | None | Optional output path for JSON. Defaults to same directory as log. | None |
Returns:
| Type | Description |
|---|---|
Path | Path to the saved JSON file |
Source code in goliat/analysis/parse_verbose_log.py
main ¶
Main entry point for CLI usage.
Source code in goliat/analysis/parse_verbose_log.py
Plotter¶
goliat.analysis.plotter.Plotter ¶
Bases: BasePlotter
Generates publication-ready plots from simulation results.
Creates bar charts, line plots, boxplots, and heatmaps for SAR analysis. All plots are saved to the configured plots directory.
Uses composition to delegate to specialized plot modules for better organization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plots_dir | str | Directory where all plots will be saved. | required |
phantom_name | str | None | Optional phantom model name for titles. | None |
plot_format | str | Output format for plots ('pdf' or 'png'), default 'pdf'. | 'pdf' |
Source code in goliat/analysis/plotter.py
Methods:¶
plot_average_sar_bar ¶
plot_average_pssar_bar ¶
plot_whole_body_sar_bar ¶
plot_peak_sar_line ¶
plot_pssar_line ¶
plot_sar_line ¶
plot_pssar_line_individual_variations ¶
Plots individual variation lines for each placement variation.
plot_sar_line_individual_variations ¶
plot_far_field_direction_polarization_lines ¶
Creates line plots showing frequency dependence for far-field direction/polarization.
plot_far_field_direction_polarization_comparison ¶
Generates frequency-dependent comparison plots for all direction/polarization combos.
Source code in goliat/analysis/plotter.py
plot_sar_distribution_boxplots ¶
Creates boxplots showing SAR value distributions across placements.
plot_sar_distribution_boxplot_single ¶
Creates a single boxplot showing distribution of one metric across frequencies.
plot_sar_heatmap ¶
Creates a combined heatmap showing Min/Avg/Max SAR per tissue and frequency.
plot_peak_sar_heatmap ¶
Creates a heatmap for peak SAR values across tissues and frequencies.
plot_far_field_direction_polarization_heatmap ¶
Creates a heatmap comparing SAR across incident directions and polarizations.
plot_far_field_direction_polarization_summary ¶
Creates a multi-panel summary of SAR across directions/polarizations.
plot_peak_location_3d_interactive ¶
plot_peak_location_2d_projections ¶
Creates 2D scatter plots showing peak locations projected onto XY, XZ, YZ planes.
plot_correlation_head_vs_eye_sar ¶
Creates scatter plot showing correlation between Head SAR and Eye psSAR10g.
plot_tissue_group_correlation_matrix ¶
Creates heatmap showing correlation coefficients between tissue group SAR values.
plot_bubble_mass_vs_sar ¶
plot_bubble_mass_vs_sar_interactive ¶
Creates an interactive bubble plot with common axis limits across frequencies.
plot_top20_tissues_ranking ¶
Creates horizontal bar chart showing top 20 tissues ranked by various metrics.
plot_power_efficiency_trends ¶
Creates line plot showing antenna efficiency and power component percentages.
plot_power_absorption_distribution ¶
Creates pie chart or stacked bar chart showing power distribution across tissue groups.
plot_power_balance_overview ¶
plot_penetration_depth_ratio ¶
Creates line plot showing SAR penetration depth ratio (Brain/Skin) vs frequency.
plot_max_local_vs_pssar10g_scatter ¶
Creates scatter plot showing relationship between Max Local SAR and psSAR10g.
plot_tissue_frequency_response ¶
Creates line plot showing how a specific tissue responds across frequencies.
plot_tissue_mass_volume_distribution ¶
Creates histograms and scatter plot showing tissue mass and volume distributions.
plot_cdf ¶
Creates CDF plot for a metric with optional aggregation by independent variables.
identify_outliers ¶
plot_cross_phantom_comparison ¶
plot_polarization_ratio_lines ¶
Plots theta/phi polarization ratio vs frequency for each direction.
plot_polarization_ratio_heatmap ¶
plot_polarization_ratio_heatmaps_per_frequency ¶
Plots polarization ratio heatmaps for each frequency separately.
Plots¶
goliat.analysis.plots.bar.BarPlotter ¶
Bases: BasePlotter
Generates bar chart plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_average_sar_bar ¶
plot_average_sar_bar(scenario_name: str, avg_results: DataFrame, progress_info: Series, scenario_results_df: DataFrame | None = None)
Creates a bar chart of average Head and Trunk SAR by frequency.
Shows completion progress in x-axis labels. Used for near-field analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name | str | Placement scenario name (e.g., 'by_cheek'). | required |
avg_results | DataFrame | DataFrame with average SAR values, indexed by frequency. | required |
progress_info | Series | Series with completion counts like '⅚' per frequency. | required |
Source code in goliat/analysis/plots/bar.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
plot_average_pssar_bar ¶
plot_average_pssar_bar(scenario_name: str, avg_results: DataFrame, progress_info: Series, scenario_results_df: DataFrame | None = None)
Creates a bar chart of average psSAR10g values by frequency for a scenario.
Symmetric counterpart to plot_average_sar_bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name | str | Placement scenario name (e.g., 'by_cheek'). | required |
avg_results | DataFrame | DataFrame with average psSAR10g values, indexed by frequency. | required |
progress_info | Series | Series with completion counts like '⅚' per frequency. | required |
Source code in goliat/analysis/plots/bar.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
plot_whole_body_sar_bar ¶
Creates a bar chart of average whole-body SAR by frequency.
Source code in goliat/analysis/plots/bar.py
goliat.analysis.plots.base.BasePlotter ¶
Base class for plot modules with shared utilities.
Provides common helper methods for subdirectory management, data filtering, and title generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plots_dir | str | Directory where all plots will be saved. | required |
phantom_name | str | None | Optional phantom model name for titles. | None |
plot_format | str | Output format for plots ('pdf' or 'png'), default 'pdf'. | 'pdf' |
Source code in goliat/analysis/plots/base.py
Methods:¶
goliat.analysis.plots.boxplot.BoxplotPlotter ¶
Bases: BasePlotter
Generates boxplot plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_sar_distribution_boxplots ¶
Creates boxplots showing SAR value distributions across frequencies.
Generates separate boxplots for each SAR and psSAR10g metric. Shows spread and outliers for each frequency. Used by near-field analysis which generates multiple plots per scenario.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name | str | Placement scenario name. | required |
scenario_results_df | DataFrame | DataFrame with detailed results for all placements. | required |
Source code in goliat/analysis/plots/boxplot.py
plot_sar_distribution_boxplot_single ¶
plot_sar_distribution_boxplot_single(results_df: DataFrame, metric: str = 'SAR_whole_body', scenario_name: str | None = None)
Creates a single boxplot showing distribution of one metric across frequencies.
Generates one boxplot for a specified metric. Shows spread and outliers for each frequency. Used by far-field analysis which calls this per-metric. Symmetric counterpart to plot_sar_distribution_boxplots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with detailed results. | required |
metric | str | Column name of the SAR metric to plot. | 'SAR_whole_body' |
scenario_name | str | None | Optional scenario name for filename (default: None uses 'all'). | None |
Source code in goliat/analysis/plots/boxplot.py
goliat.analysis.plots.bubble.BubblePlotter ¶
Bases: BasePlotter
Generates bubble plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_bubble_mass_vs_sar ¶
plot_bubble_mass_vs_sar(organ_results_df: DataFrame, sar_column: str = 'mass_avg_sar_mw_kg', scenario_name: str | None = None, frequency_mhz: int | None = None)
Creates bubble plot showing how tissue mass affects SAR values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with columns: ['tissue', 'Total Mass', 'Total Volume', sar_column, 'frequency_mhz'] | required |
sar_column | str | Column name for SAR values (default: 'mass_avg_sar_mw_kg'). | 'mass_avg_sar_mw_kg' |
scenario_name | str | None | Optional scenario name for filtering. | None |
frequency_mhz | int | None | Optional frequency for filtering. | None |
Source code in goliat/analysis/plots/bubble.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
plot_bubble_mass_vs_sar_interactive ¶
plot_bubble_mass_vs_sar_interactive(organ_results_df: DataFrame, sar_column: str = 'mass_avg_sar_mw_kg', scenario_name: str | None = None)
Creates an interactive bubble plot (plotly) with common axis limits across frequencies.
Uses Plotly for interactive visualization (not affected by scienceplots).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with columns: ['tissue', 'Total Mass', 'Total Volume', sar_column, 'frequency_mhz', 'placement'] | required |
sar_column | str | Column name for SAR values (default: 'mass_avg_sar_mw_kg'). | 'mass_avg_sar_mw_kg' |
scenario_name | str | None | Optional scenario name for filtering. | None |
Source code in goliat/analysis/plots/bubble.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
goliat.analysis.plots.cdf.CdfPlotter ¶
Bases: BasePlotter
Generates CDF plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_cdf ¶
plot_cdf(results_df: DataFrame, metric: str, group_by: str | list[str] | None = None, scenario_name: str | None = None, frequency_mhz: int | None = None)
Creates CDF plot for a metric with optional aggregation by independent variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with simulation results. | required |
metric | str | Column name for the metric to plot. | required |
group_by | str | list[str] | None | Column name(s) to group by for multiple CDF lines (e.g., 'scenario', 'frequency_mhz', 'placement'). Can be a single string or list of strings. If None, plots single CDF. | None |
scenario_name | str | None | Optional scenario name for filtering. | None |
frequency_mhz | int | None | Optional frequency for filtering. | None |
Source code in goliat/analysis/plots/cdf.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
goliat.analysis.plots.correlation.CorrelationPlotter ¶
Bases: BasePlotter
Generates correlation plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_correlation_head_vs_eye_sar ¶
Creates scatter plot showing correlation between Head SAR and Eye psSAR10g with linear regression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with columns: ['SAR_head', 'psSAR10g_eyes', 'frequency_mhz', 'scenario'] | required |
scenario_name | str | Scenario to filter for (default: 'front_of_eyes'). | 'front_of_eyes' |
Source code in goliat/analysis/plots/correlation.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
plot_tissue_group_correlation_matrix ¶
Creates heatmap showing correlation coefficients between different tissue group SAR values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with tissue group SAR columns (SAR_eyes, SAR_brain, etc.) | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
Source code in goliat/analysis/plots/correlation.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
goliat.analysis.plots.heatmap.HeatmapPlotter ¶
Bases: BasePlotter
Generates heatmap plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_sar_heatmap ¶
Creates separate heatmaps for Min, Avg, and Max SAR per tissue and frequency.
Generates three separate heatmaps instead of a combined summary. Each heatmap has two panels: top shows individual tissues, bottom shows group summaries. Uses log-scale colormap for better visibility.
Source code in goliat/analysis/plots/heatmap.py
plot_peak_sar_heatmap ¶
plot_peak_sar_heatmap(organ_df: DataFrame, group_df: DataFrame, tissue_groups: dict, value_col: str = 'peak_sar_10g_mw_kg', title: str = 'Peak SAR')
Creates a heatmap for peak SAR values across tissues and frequencies.
Similar structure to plot_sar_heatmap but focused on peak SAR metrics. Shows individual tissues and group summaries in separate panels. 'All Regions' is excluded as it's a whole-body aggregate, not a real tissue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_df | DataFrame | DataFrame with organ-level peak SAR data. | required |
group_df | DataFrame | DataFrame with group-level summaries. | required |
tissue_groups | dict | Dict mapping groups to tissue lists. | required |
value_col | str | Column name containing the peak SAR values. | 'peak_sar_10g_mw_kg' |
title | str | Title for the plot. | 'Peak SAR' |
Source code in goliat/analysis/plots/heatmap.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
plot_far_field_direction_polarization_heatmap ¶
plot_far_field_direction_polarization_heatmap(results_df: DataFrame, metric: str = 'SAR_whole_body', frequency_mhz: int | None = None)
Creates a heatmap comparing SAR values across incident directions and polarizations.
This visualization is specific to far-field analysis where simulations are run for different incident wave directions (from left, right, front, back, above, below) and polarizations (theta, phi). The heatmap shows where SAR is highest and lowest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with 'placement' column containing direction/polarization info. | required |
metric | str | SAR metric to plot (default: 'SAR_whole_body'). | 'SAR_whole_body' |
frequency_mhz | int | None | Optional frequency to filter. If None, averages across all frequencies. | None |
Source code in goliat/analysis/plots/heatmap.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
plot_far_field_direction_polarization_summary ¶
plot_far_field_direction_polarization_summary(results_df: DataFrame, metrics: list[str] | None = None)
Creates a multi-panel summary comparing SAR metrics across directions/polarizations.
Generates both individual metric heatmaps and a combined multi-panel figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with 'placement' column containing direction/polarization info. | required |
metrics | list[str] | None | List of metrics to plot. If None, plots common metrics. | None |
Source code in goliat/analysis/plots/heatmap.py
plot_polarization_ratio_heatmap ¶
Plots heatmap of theta/phi polarization ratio for each direction and metric.
Creates a heatmap showing frequency-averaged polarization ratios. Ratios > 1.0 indicate theta dominates; < 1.0 indicates phi dominates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with placement column containing direction and polarization info. | required |
metrics | list[str] | None | List of metrics to analyze. If None, uses common metrics. | None |
Source code in goliat/analysis/plots/heatmap.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | |
plot_polarization_ratio_heatmaps_per_frequency ¶
plot_polarization_ratio_heatmaps_per_frequency(results_df: DataFrame, metrics: list[str] | None = None)
Plots polarization ratio heatmaps for each frequency separately.
Creates individual heatmaps showing theta/phi ratios for each frequency, allowing detailed analysis of frequency-dependent polarization effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with placement column containing direction and polarization info. | required |
metrics | list[str] | None | List of metrics to analyze. If None, uses common metrics. | None |
Source code in goliat/analysis/plots/heatmap.py
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
goliat.analysis.plots.line.LinePlotter ¶
Bases: BasePlotter
Generates line plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_peak_sar_line ¶
Plots peak SAR trend across frequencies for far-field analysis.
Source code in goliat/analysis/plots/line.py
plot_pssar_line ¶
Plots average psSAR10g trends for tissue groups by frequency.
Shows how peak spatial-average SAR varies with frequency for eyes, skin, and brain groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name | str | Placement scenario name. | required |
avg_results | DataFrame | DataFrame with average psSAR10g values. | required |
Source code in goliat/analysis/plots/line.py
plot_sar_line ¶
Plots average SAR trends for tissue groups by frequency.
Symmetric counterpart to plot_pssar_line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name | str | Placement scenario name. | required |
avg_results | DataFrame | DataFrame with average SAR values. | required |
Source code in goliat/analysis/plots/line.py
plot_pssar_line_individual_variations ¶
plot_pssar_line_individual_variations(results_df: DataFrame, scenario_name: str, metric_column: str = 'psSAR10g_eyes')
Plots individual variation lines for each placement/direction/polarization.
Similar to boxplots but shows individual lines instead of aggregating variability. Each placement variation gets its own line with a legend entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with detailed results including 'placement' column. | required |
scenario_name | str | Scenario name for filtering. | required |
metric_column | str | Column name for the metric to plot (e.g., 'psSAR10g_eyes'). | 'psSAR10g_eyes' |
Source code in goliat/analysis/plots/line.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
plot_sar_line_individual_variations ¶
plot_sar_line_individual_variations(results_df: DataFrame, scenario_name: str, metric_column: str = 'SAR_head')
Plots individual variation lines for SAR metrics.
Symmetric counterpart to plot_pssar_line_individual_variations for SAR metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with detailed results including 'placement' column. | required |
scenario_name | str | Scenario name for filtering. | required |
metric_column | str | Column name for the SAR metric to plot (e.g., 'SAR_head'). | 'SAR_head' |
Source code in goliat/analysis/plots/line.py
plot_far_field_direction_polarization_lines ¶
plot_far_field_direction_polarization_lines(results_df: DataFrame, metric: str = 'SAR_whole_body', group_by: str = 'direction')
Creates line plots showing frequency dependence for far-field direction/polarization.
This visualization shows how SAR varies with frequency for each direction/polarization combination, enabling comparison of frequency-dependent effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with 'placement' column containing direction/polarization info. | required |
metric | str | SAR metric to plot (default: 'SAR_whole_body'). | 'SAR_whole_body' |
group_by | str | How to group lines - 'direction' (one line per direction, panels for polarization), 'polarization' (one line per polarization, panels for direction), or 'both' (all combinations on one plot). | 'direction' |
Source code in goliat/analysis/plots/line.py
plot_far_field_direction_polarization_comparison ¶
plot_far_field_direction_polarization_comparison(results_df: DataFrame, metrics: list[str] | None = None)
Generates frequency-dependent comparison plots for all direction/polarization combos.
Creates multiple line plots showing how SAR varies with frequency for different direction/polarization combinations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with 'placement' column containing direction/polarization info. | required |
metrics | list[str] | None | List of metrics to plot. If None, uses common metrics. | None |
Source code in goliat/analysis/plots/line.py
plot_cross_phantom_comparison ¶
plot_cross_phantom_comparison(all_phantom_data: dict[str, DataFrame], metrics: list[str] | None = None)
Plots SAR vs frequency comparing different phantoms.
Creates line plots showing how SAR varies with frequency for each phantom, revealing age/body-size dependent absorption patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_phantom_data | dict[str, DataFrame] | Dictionary mapping phantom names to their results DataFrames. | required |
metrics | list[str] | None | List of metrics to plot. If None, uses common metrics. | None |
Source code in goliat/analysis/plots/line.py
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | |
plot_polarization_ratio_lines ¶
Plots theta/phi polarization ratio vs frequency for each direction.
Shows how the polarization sensitivity changes with frequency for different incident directions. This is unique to far-field analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with placement column containing direction and polarization info. | required |
metrics | list[str] | None | List of metrics to analyze. If None, uses common metrics. | None |
Source code in goliat/analysis/plots/line.py
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 | |
goliat.analysis.plots.outliers.OutliersPlotter ¶
Bases: BasePlotter
Generates outlier detection plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
identify_outliers ¶
identify_outliers(results_df: DataFrame, metrics: str | list[str], scenario_name: str | None = None, method: str = 'iqr', threshold: float = 1.5)
Identifies and visualizes outliers in SAR metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with simulation results. | required |
metrics | str | list[str] | Single metric column name or list of metric column names to check for outliers. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
method | str | Method for outlier detection ('iqr' for Interquartile Range, 'zscore' for Z-score). | 'iqr' |
threshold | float | Threshold multiplier for IQR method or Z-score threshold. | 1.5 |
Returns:
| Type | Description |
|---|---|
| DataFrame containing outlier rows, or None if no outliers found. |
Source code in goliat/analysis/plots/outliers.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
goliat.analysis.plots.penetration.PenetrationPlotter ¶
Bases: BasePlotter
Generates penetration depth plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_penetration_depth_ratio ¶
plot_penetration_depth_ratio(results_df: DataFrame, scenario_name: str | None = None, metric_type: str = 'psSAR10g')
Creates line plot showing SAR penetration depth ratio (Brain/Skin) vs frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with psSAR10g_brain/psSAR10g_skin or SAR_brain/SAR_skin columns. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
metric_type | str | Type of SAR metric to use ('psSAR10g' or 'SAR'). | 'psSAR10g' |
Source code in goliat/analysis/plots/penetration.py
goliat.analysis.plots.power.PowerPlotter ¶
Bases: BasePlotter
Generates power balance plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_power_efficiency_trends ¶
Creates line plot showing antenna efficiency and power component percentages across frequencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with power balance columns. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
Source code in goliat/analysis/plots/power.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
plot_power_absorption_distribution ¶
plot_power_absorption_distribution(organ_results_df: DataFrame, scenario_name: str | None = None, frequency_mhz: int | None = None)
Creates pie chart or stacked bar chart showing how total power is distributed across tissue groups.
Pie charts are kept as-is (not using scienceplots) as they work well with default matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with tissue-level data including 'Total Loss' column. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
frequency_mhz | int | None | Optional frequency for filtering. | None |
Source code in goliat/analysis/plots/power.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
plot_power_balance_overview ¶
Creates power balance overview heatmap with all components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_df | DataFrame | DataFrame with power balance columns. | required |
Source code in goliat/analysis/plots/power.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
goliat.analysis.plots.ranking.RankingPlotter ¶
Bases: BasePlotter
Generates ranking plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_top20_tissues_ranking ¶
plot_top20_tissues_ranking(organ_results_df: DataFrame, metric: str = 'max_local_sar_mw_kg', scenario_name: str | None = None, frequency_mhz: int | None = None)
Creates horizontal bar chart showing top 20 tissues ranked by various metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with tissue-level data. | required |
metric | str | Metric to rank by (e.g., 'max_local_sar_mw_kg', 'mass_avg_sar_mw_kg', 'Total Loss'). | 'max_local_sar_mw_kg' |
scenario_name | str | None | Optional scenario name for filtering. | None |
frequency_mhz | int | None | Optional frequency for filtering. | None |
Source code in goliat/analysis/plots/ranking.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
goliat.analysis.plots.spatial.SpatialPlotter ¶
Bases: BasePlotter
Generates spatial/3D plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_peak_location_3d_interactive ¶
plot_peak_location_3d_interactive(peak_data: DataFrame, scenario_name: str | None = None, axis_limits: dict | None = None)
Creates an interactive 3D plot of peak SAR locations as wireframe boxes.
Each box represents the spatial averaging cube (10g) centered at the peak location. Uses Plotly for interactive visualization (not affected by scienceplots).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peak_data | DataFrame | DataFrame with columns: ['PeakLocation', 'PeakCubeSideLength', 'PeakValue', 'placement', 'frequency_mhz', 'scenario'] | required |
scenario_name | str | None | Optional scenario name for filtering and filename. | None |
axis_limits | dict | None | Optional dict with 'x', 'y', 'z' keys containing (min, max) tuples. If None, calculates from filtered data. | None |
Source code in goliat/analysis/plots/spatial.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
plot_peak_location_2d_projections ¶
Creates 2D scatter plots showing peak locations projected onto XY, XZ, YZ planes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peak_data | DataFrame | DataFrame with columns: ['PeakLocation', 'PeakValue', 'placement', 'frequency_mhz', 'scenario'] | required |
scenario_name | str | None | Optional scenario name for filtering and filename. | None |
Source code in goliat/analysis/plots/spatial.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
goliat.analysis.plots.tissue_analysis.TissueAnalysisPlotter ¶
Bases: BasePlotter
Generates tissue analysis plots for SAR analysis.
Source code in goliat/analysis/plots/base.py
Methods:¶
plot_max_local_vs_pssar10g_scatter ¶
plot_max_local_vs_pssar10g_scatter(organ_results_df: DataFrame, scenario_name: str | None = None, frequency_mhz: int | None = None)
Creates scatter plot showing relationship between Max Local SAR and psSAR10g.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with max_local_sar_mw_kg and psSAR10g columns. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
frequency_mhz | int | None | Optional frequency for filtering. | None |
Source code in goliat/analysis/plots/tissue_analysis.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
plot_tissue_frequency_response ¶
plot_tissue_frequency_response(organ_results_df: DataFrame, tissue_name: str, scenario_name: str | None = None)
Creates line plot showing how a specific tissue responds across frequencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with tissue-level data. | required |
tissue_name | str | Name of the tissue to plot. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
Source code in goliat/analysis/plots/tissue_analysis.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
plot_tissue_mass_volume_distribution ¶
Creates histograms and scatter plot showing tissue mass and volume distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organ_results_df | DataFrame | DataFrame with 'Total Mass' and 'Total Volume' columns. | required |
scenario_name | str | None | Optional scenario name for filtering. | None |
Source code in goliat/analysis/plots/tissue_analysis.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
GUI Components¶
Graphical user interface for monitoring simulation progress.
Analysis Gui¶
goliat.gui.analysis_gui.SignalingLogHandler ¶
Bases: Handler, QObject
Log handler that emits Qt signals for log records.
Source code in goliat/gui/analysis_gui.py
Methods:¶
emit ¶
Format record and emit as Qt signal.
Source code in goliat/gui/analysis_gui.py
Progress Gui¶
goliat.gui.progress_gui.ProgressGUI ¶
ProgressGUI(queue: Queue, stop_event: Event, process: Process, init_window_title: str = '', use_web: bool = True, auto_close: bool = False)
Bases: QWidget
Main GUI window for monitoring simulation progress.
Provides real-time progress tracking via progress bars, ETA estimation, and status logs. Runs in the main process and communicates with worker process through a multiprocessing queue.
The GUI architecture: - Main window runs in main process, worker runs in separate process - Communication via multiprocessing.Queue for thread-safe message passing - QueueHandler polls queue every 100ms and updates UI - Multiple timers handle different update frequencies (queue, clock, graphs)
Features: - Overall progress bar (weighted across all simulations) - Stage progress bar (current phase: setup/run/extract) - Real-time ETA calculation based on profiler estimates - Status log with color-coded messages - Timings table showing execution statistics - Pie charts showing phase/subtask breakdowns - Time series plots for progress and ETA trends - System tray integration for background operation
Initializes data manager, status manager, UI builder, timers, and queue handler. Sets up Qt timers for periodic updates (queue polling, clock updates, graph refreshes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue | Queue | Queue for receiving messages from worker process. | required |
stop_event | Event | Event to signal termination to worker process. | required |
process | Process | Worker process running the study. | required |
init_window_title | str | Initial window title. | '' |
use_web | bool | Whether to enable web bridge for remote monitoring. | True |
auto_close | bool | Whether to automatically close GUI on successful completion. | False |
Source code in goliat/gui/progress_gui.py
Methods:¶
update_overall_progress ¶
Updates overall progress bar across all simulations.
update_stage_progress ¶
update_stage_progress(stage_name: str, current_step: int, total_steps: int, sub_stage: str = '') -> None
Updates stage-specific progress bar and label.
Source code in goliat/gui/progress_gui.py
start_stage_animation ¶
Starts smooth animated progress bar for a stage.
Instead of jumping to discrete progress values, animates smoothly over the estimated duration. This provides visual feedback during long-running tasks where progress updates are infrequent.
The animation uses linear interpolation between current value and target (always 100% = 1000). Updates every 50ms via Qt timer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimated_duration | float | Estimated task duration in seconds (from profiler). | required |
end_step | int | Target step value (unused, always animates to 100%). | required |
Source code in goliat/gui/progress_gui.py
end_stage_animation ¶
update_animation ¶
Updates progress bar animation frame and syncs overall progress.
Called every 50ms by Qt timer when animation is active. Calculates current progress based on elapsed time and estimated duration, then updates stage progress bar. Also syncs overall progress bar using weighted progress calculation from profiler.
Source code in goliat/gui/progress_gui.py
update_simulation_details ¶
Updates simulation counter and details labels.
update_status ¶
Appends message to status log with color formatting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | Message text. | required |
log_type | str | Log type for color coding. | 'default' |
Source code in goliat/gui/progress_gui.py
update_utilization ¶
update_utilization_plot ¶
update_clock ¶
update_graphs ¶
hide_to_tray ¶
show_from_tray ¶
stop_study ¶
Sends stop signal to worker process.
Source code in goliat/gui/progress_gui.py
study_finished ¶
Handles study completion, stopping timers and updating UI.
Called when worker process signals completion. Stops all timers, updates final progress to 100%, sets stage label, and schedules window auto-close after 3 seconds (if no errors).
For memory errors (exit code 42), the GUI auto-closes even with errors so the batch worker can retry the assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error | bool | Whether study finished with errors (affects UI styling). | False |
memory_error | bool | Whether this was a memory error (exit code 42). Memory errors auto-close to allow batch retry. | False |
Source code in goliat/gui/progress_gui.py
closeEvent ¶
Handles window close event, ensuring worker process termination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event | Any | Close event. | required |
Source code in goliat/gui/progress_gui.py
Queue Gui¶
goliat.gui.queue_gui.QueueGUI ¶
QueueGUI(queue: Queue, stop_event: Event, profiler: Profiler, progress_logger: Logger, verbose_logger: Logger)
Bases: LoggingMixin
Proxy for ProgressGUI that operates in a separate process.
Mimics the ProgressGUI interface but routes all calls through a multiprocessing queue, enabling thread-safe communication between worker and GUI processes. All methods serialize their arguments and send them via queue for the GUI process to handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue | Queue | Multiprocessing queue for IPC. | required |
stop_event | Event | Event flagging user cancellation. | required |
profiler | Profiler | Profiler for ETA calculations. | required |
progress_logger | Logger | Logger for progress-level messages. | required |
verbose_logger | Logger | Logger for detailed messages. | required |
Source code in goliat/gui/queue_gui.py
Methods:¶
log ¶
Sends a log message to the GUI via queue.
All messages are forwarded through the queue for terminal output (S4L 9.2 fix). Progress messages update the GUI status box; verbose messages only print to terminal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | Log message text. | required |
level | str | Log level ('progress' or 'verbose'). | 'verbose' |
log_type | str | Type for color coding in GUI. | 'default' |
Source code in goliat/gui/queue_gui.py
update_simulation_details ¶
Sends current simulation case details to GUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim_count | int | Current simulation number (1-indexed). | required |
total_sims | int | Total simulations in study. | required |
details | str | Human-readable description of current case. | required |
Source code in goliat/gui/queue_gui.py
update_overall_progress ¶
Updates overall study progress bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_step | float | Current step number or percentage (0-100). | required |
total_steps | int | Total steps in study. | required |
Source code in goliat/gui/queue_gui.py
update_stage_progress ¶
update_stage_progress(stage_name: str, current_step: int, total_steps: int, sub_stage: str = '') -> None
Updates progress for a specific stage (setup/run/extract).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage_name | str | Stage name like 'Setup' or 'Running Simulation'. | required |
current_step | int | Current step within stage. | required |
total_steps | int | Total steps for stage. | required |
sub_stage | str | Optional sub-stage description. | '' |
Source code in goliat/gui/queue_gui.py
start_stage_animation ¶
Starts animated progress bar for a stage.
Looks up time estimate from profiler and starts animation that progresses toward end_value over that duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name | str | Task name ('setup', 'run', 'extract', or subtask name). | required |
end_value | int | Target progress value (typically 100). | required |
Source code in goliat/gui/queue_gui.py
end_stage_animation ¶
update_profiler ¶
process_events ¶
Components¶
goliat.gui.components.clock_manager.ClockManager ¶
Manages elapsed time, ETA, and window title updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance. | required |
Source code in goliat/gui/components/clock_manager.py
Methods:¶
update ¶
Updates elapsed time, ETA labels, and window title.
Called every second by Qt timer. Calculates elapsed time from start, gets ETA from profiler (if available), and updates window title with current status and progress percentage.
The window title shows: [progress%] GOLIAT | Sim X/Y | Status where Status is 'Booting...', 'Running...', or 'Finished'.
Source code in goliat/gui/components/clock_manager.py
goliat.gui.components.data_manager.DataManager ¶
Manages CSV data files for time remaining and overall progress tracking.
Writes timestamped data points to CSV files for plotting and analysis. Automatically cleans up old files (keeps last 50) to prevent disk bloat. Creates unique session files using timestamp and process hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir | str | Directory where data files will be stored. | required |
verbose_logger | Logger | Logger for verbose messages. | required |
Source code in goliat/gui/components/data_manager.py
Methods:¶
write_time_remaining ¶
Appends a time remaining data point to CSV.
Writes timestamp and hours remaining to session-specific CSV file. Used for plotting ETA trends over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hours_remaining | float | Estimated hours remaining as float. | required |
Source code in goliat/gui/components/data_manager.py
write_overall_progress ¶
Appends an overall progress data point to CSV.
Writes timestamp and progress percentage to session-specific CSV file. Used for plotting progress trends over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_percent | float | Overall progress percentage (0-100). | required |
Source code in goliat/gui/components/data_manager.py
write_system_utilization ¶
write_system_utilization(cpu_percent: float, ram_percent: float, gpu_percent: Optional[float] = None, gpu_vram_percent: Optional[float] = None, disk_read_mbps: Optional[float] = None, disk_write_mbps: Optional[float] = None) -> None
Appends a system utilization data point to CSV.
Writes timestamp and CPU, RAM, GPU utilization, GPU VRAM, and disk I/O throughput to session-specific CSV file. Used for plotting utilization trends over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cpu_percent | float | CPU utilization percentage (0-100). | required |
ram_percent | float | RAM utilization percentage (0-100). | required |
gpu_percent | Optional[float] | GPU utilization percentage (0-100), or None if unavailable. | None |
gpu_vram_percent | Optional[float] | GPU VRAM utilization percentage (0-100), or None if unavailable. | None |
disk_read_mbps | Optional[float] | Disk read throughput in MB/s, or None if unavailable. | None |
disk_write_mbps | Optional[float] | Disk write throughput in MB/s, or None if unavailable. | None |
Source code in goliat/gui/components/data_manager.py
goliat.gui.components.graph_manager.GraphManager ¶
Manages time remaining and overall progress graph updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance. | required |
Source code in goliat/gui/components/graph_manager.py
Methods:¶
update ¶
Updates time remaining, overall progress, and system utilization graphs (called every 5 seconds).
Gets current ETA and progress values, writes them to CSV files (via DataManager), and adds data points to matplotlib plots. The plots show trends over time, helping users see if ETA is converging or progress is steady.
This runs less frequently than clock updates (5s vs 1s) because plotting is more expensive and the trends don't need millisecond precision.
Source code in goliat/gui/components/graph_manager.py
goliat.gui.components.machine_id_detector.MachineIdDetector ¶
Detects machine ID (public IP or local IP) for web monitoring.
Tries external service first with retries, then falls back to local IP. Matches the logic in run_worker.py to ensure consistency.
Methods:¶
detect staticmethod ¶
Auto-detects machine ID (public IP or local IP).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose_logger | Logger | Logger for verbose messages. | required |
Returns:
| Type | Description |
|---|---|
Optional[str] | Machine ID string, or None if detection failed. |
Source code in goliat/gui/components/machine_id_detector.py
goliat.gui.components.progress_animation.ProgressAnimation ¶
Manages smooth progress bar animations based on estimated durations.
Provides linear interpolation animation for progress bars when explicit progress updates aren't available. Animates from current value to target (100%) over estimated duration, giving visual feedback during long tasks.
Updates every 50ms via Qt timer, calculating progress ratio from elapsed time and duration. Stops automatically when target is reached or stopped explicitly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_bar | QProgressBar | Progress bar widget to animate (0-1000 range). | required |
timer | QTimer | QTimer instance for animation updates (50ms interval). | required |
debug | bool | Enable debug logging (currently unused). | False |
Source code in goliat/gui/components/progress_animation.py
Methods:¶
start ¶
Starts smooth animation for progress bar.
Begins linear interpolation from current value to 100% over estimated duration. If already at 100%, skips animation. Starts Qt timer if not already active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimated_duration | float | Estimated task duration in seconds (from profiler). | required |
end_step | int | Target step value (unused, always animates to 100%). | required |
Source code in goliat/gui/components/progress_animation.py
stop ¶
Stops the progress bar animation.
update ¶
Updates progress bar animation frame by frame.
Calculates current progress ratio based on elapsed time and duration, then interpolates between start and end values. Updates progress bar value and format string. Called every 50ms by Qt timer when active.
Source code in goliat/gui/components/progress_animation.py
goliat.gui.components.progress_manager.ProgressManager ¶
Manages progress bar updates for overall and stage progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance. | required |
Source code in goliat/gui/components/progress_manager.py
Methods:¶
update_overall ¶
Updates overall progress bar across all simulations.
The progress bar uses a 0-10000 range internally (for finer granularity), but displays as percentage. Overall progress accounts for completed simulations plus progress within current simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_step | float | Current step number (0-100 range) or percentage (0-100). | required |
total_steps | int | Total number of steps (typically 100). | required |
Source code in goliat/gui/components/progress_manager.py
update_stage ¶
Updates stage-specific progress bar and label.
Shows progress within current phase (setup/run/extract). Stops any active animation when explicit progress is set. Uses 0-1000 range internally for finer granularity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage_name | str | Name of current stage (e.g., 'Setup', 'Running Simulation'). | required |
current_step | int | Current step within stage. | required |
total_steps | int | Total steps for the stage. | required |
sub_stage | str | Optional sub-stage description (currently unused). | '' |
Source code in goliat/gui/components/progress_manager.py
update_simulation_details ¶
Updates simulation counter and details labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sim_count | int | Current simulation number. | required |
total_sims | int | Total number of simulations. | required |
details | str | Description of current simulation case. | required |
Source code in goliat/gui/components/progress_manager.py
goliat.gui.components.queue_handler.QueueHandler ¶
Handles processing of messages from the worker process queue.
Polls the multiprocessing queue and dispatches messages to the matching GUI update methods. This decouples message handling from queue polling, making the code cleaner and easier to test.
Message types: - 'status': Log message with color coding - 'overall_progress': Update overall progress bar - 'stage_progress': Update stage progress bar - 'start_animation': Start animated progress bar - 'end_animation': Stop animation - 'profiler_update': Update profiler state and refresh timing displays - 'sim_details': Update simulation counter and details - 'finished': Study completed successfully - 'fatal_error': Study failed with fatal error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui_instance | ProgressGUI | ProgressGUI instance to update with messages. | required |
Source code in goliat/gui/components/queue_handler.py
Methods:¶
process_queue ¶
Processes messages from worker process queue and updates UI.
Polls queue non-blockingly and processes all available messages in one call. Routes each message type to its handler method. Catches and logs exceptions to prevent one bad message from crashing GUI.
This method is called every 100ms by Qt timer to keep UI responsive.
After processing each message for the GUI, forwards a copy to WebGUIBridge if it exists (for web dashboard monitoring).
Source code in goliat/gui/components/queue_handler.py
goliat.gui.components.screenshot_capture.ScreenshotCapture ¶
Captures screenshots of GUI tabs for web monitoring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance with tabs to capture. | required |
Source code in goliat/gui/components/screenshot_capture.py
Methods:¶
capture_all_tabs ¶
Capture all GUI tabs as JPEG bytes.
Captures each tab widget individually without switching tabs, so it doesn't interfere with the user's current view.
Returns:
| Type | Description |
|---|---|
Dict[str, bytes] | Dictionary mapping tab names to JPEG bytes. |
Dict[str, bytes] | Empty dict if capture fails or PySide6 not available. |
Source code in goliat/gui/components/screenshot_capture.py
goliat.gui.components.status_manager.StatusManager ¶
Manages status colors, counting, and message formatting for GUI.
Handles color mapping for different log types (info, warning, error, etc.), counts warnings and errors for display in error summary, and formats messages with HTML color styling for the QTextEdit widget.
Note: Uses white for 'progress' messages in GUI (unlike terminal colors) because all messages shown here are progress updates. This improves readability in the dark-themed GUI.
Source code in goliat/gui/components/status_manager.py
Methods:¶
get_color ¶
Gets HTML color code for a log type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_type | str | Type of log message. | required |
Returns:
| Type | Description |
|---|---|
str | HTML color code (hex). |
format_message ¶
Formats message with HTML color styling.
Strips any ANSI escape codes (from terminal formatters), preserves leading spaces by converting them to entities, then wraps message in a tag with the matching color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | Message text to format. | required |
log_type | str | Log type for color selection. | 'default' |
Returns:
| Type | Description |
|---|---|
str | HTML-formatted message string ready for QTextEdit. |
Source code in goliat/gui/components/status_manager.py
record_log ¶
Records log entry and updates warning/error counters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_type | str | Type of log message. | required |
Source code in goliat/gui/components/status_manager.py
get_error_summary ¶
Gets formatted summary of warnings and errors with optional web status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_connected | bool | Whether web dashboard is connected (optional). | False |
Returns:
| Type | Description |
|---|---|
str | Formatted string with emoji indicators and counts. |
Source code in goliat/gui/components/status_manager.py
goliat.gui.components.system_monitor.SystemMonitor ¶
Monitors system resource utilization (CPU, RAM, GPU).
Provides methods to get current CPU usage percentage, RAM usage in GB, and GPU utilization percentage (via nvidia-smi). Gracefully handles missing dependencies (psutil) and unavailable GPU.
Methods:¶
get_cpu_utilization staticmethod ¶
Gets current CPU utilization percentage.
Uses non-blocking approach by calling cpu_percent() without interval, which returns utilization since last call. For accurate measurement, ensure this is called at consistent intervals (e.g., every 1 second).
Returns:
| Type | Description |
|---|---|
float | CPU usage percentage (0-100), or 0.0 if psutil unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_ram_utilization staticmethod ¶
Gets current RAM usage and total RAM.
Returns:
| Type | Description |
|---|---|
Tuple[float, float] | Tuple of (used_GB, total_GB), or (0.0, 0.0) if psutil unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_ram_utilization_detailed staticmethod ¶
Gets RAM utilization with and without cacheable memory.
Returns:
| Type | Description |
|---|---|
float | Tuple of (percent_with_cache, percent_without_cache, total_GB), or (0.0, 0.0, 0.0) if psutil unavailable. |
float |
|
float |
|
Tuple[float, float, float] |
|
Source code in goliat/gui/components/system_monitor.py
get_gpu_vram_utilization staticmethod ¶
Gets current GPU VRAM usage and total VRAM.
Returns:
| Type | Description |
|---|---|
Optional[Tuple[float, float]] | Tuple of (used_GB, total_GB), or None if nvidia-smi unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_gpu_utilization staticmethod ¶
Gets current GPU utilization percentage via nvidia-smi.
Returns:
| Type | Description |
|---|---|
Optional[float] | GPU usage percentage (0-100), or None if nvidia-smi unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_gpu_name staticmethod ¶
Gets GPU name via nvidia-smi.
Returns:
| Type | Description |
|---|---|
Optional[str] | GPU name (e.g., "RTX 4090"), or None if nvidia-smi unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_cpu_cores staticmethod ¶
Gets number of CPU cores.
Returns:
| Type | Description |
|---|---|
int | Number of CPU cores, or 0 if psutil unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_total_ram_gb staticmethod ¶
Gets total RAM in GB.
Returns:
| Type | Description |
|---|---|
float | Total RAM in GB, or 0.0 if psutil unavailable. |
Source code in goliat/gui/components/system_monitor.py
get_disk_io_throughput staticmethod ¶
Gets current disk I/O throughput in MB/s.
Calculates read and write speeds by comparing current I/O counters with values from the previous call. First call returns None as there's no baseline for comparison.
Returns:
| Type | Description |
|---|---|
Optional[Tuple[float, float]] | Tuple of (read_MB_per_sec, write_MB_per_sec), or None if unavailable. |
Source code in goliat/gui/components/system_monitor.py
is_gpu_available staticmethod ¶
Checks if GPU is available via nvidia-smi.
Returns:
| Type | Description |
|---|---|
bool | True if nvidia-smi is available and returns successfully, False otherwise. |
Source code in goliat/gui/components/system_monitor.py
get_page_faults_per_second staticmethod ¶
Gets current hard page faults per second.
Hard page faults (major faults) occur when the system needs to read data from disk because it's not in RAM. High rates indicate memory pressure and can significantly impact performance.
Calculates the rate by comparing current page fault count with the previous call. First call returns None as there's no baseline.
Returns:
| Type | Description |
|---|---|
Optional[float] | Page faults per second, or None if unavailable. |
Source code in goliat/gui/components/system_monitor.py
goliat.gui.components.timings_table.TimingsTable ¶
Manages timings table displaying profiling statistics.
Shows execution time statistics (mean, median, min, max, percentiles) for all phases and subtasks. Filters out fake aggregated entries and organizes data by phase for easy inspection. Updates automatically when profiler state changes via queue messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_widget | QTableWidget | QTableWidget instance to populate with timing data. | required |
Source code in goliat/gui/components/timings_table.py
Methods:¶
update ¶
Populates table with timing statistics from profiler.
Collects all phase and subtask timing data, computes statistics (mean, median, percentiles), and displays in table. Filters out fake aggregated entries that shouldn't be shown.
Statistics computed: - Mean, median, min, max - 10th, 25th, 75th, 90th percentiles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiler | Profiler | Profiler instance containing timing data. | required |
Source code in goliat/gui/components/timings_table.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
goliat.gui.components.tray_manager.TrayManager ¶
TrayManager(parent_widget: QWidget, show_callback: Callable[[], None], close_callback: Callable[[], None])
Manages system tray icon and menu.
Handles system tray integration for background operation. Shows tray icon with favicon, provides context menu (Show/Exit), and handles click events to restore window. Allows users to minimize GUI to tray and continue monitoring via icon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_widget | QWidget | Parent widget (ProgressGUI window). | required |
show_callback | Callable[[], None] | Function to call when restoring window. | required |
close_callback | Callable[[], None] | Function to call when exiting application. | required |
Source code in goliat/gui/components/tray_manager.py
goliat.gui.components.ui_builder.UIBuilder ¶
Builds UI components for ProgressGUI.
Provides static methods to construct the complete GUI layout, including tabs, progress bars, plots, tables, and buttons. Handles styling via Qt stylesheets for dark theme appearance.
Methods:¶
get_icon_path staticmethod ¶
Gets path to window icon.
Returns:
| Type | Description |
|---|---|
str | Absolute path to favicon.svg. |
Source code in goliat/gui/components/ui_builder.py
build staticmethod ¶
Builds complete UI for the GUI instance.
Sets up window properties, applies stylesheet, creates tabs (Progress, Timings, Piecharts, Time Remaining, Overall Progress), and adds control buttons. Attaches components to gui_instance for later access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui_instance | ProgressGUI | ProgressGUI instance to build UI for. | required |
status_manager | StatusManager | StatusManager instance for error summary display. | required |
Source code in goliat/gui/components/ui_builder.py
goliat.gui.components.utilization_manager.UtilizationManager ¶
Manages CPU, RAM, and GPU utilization displays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance. | required |
Source code in goliat/gui/components/utilization_manager.py
Methods:¶
update ¶
Updates CPU, RAM, and GPU utilization displays.
Called every second by Qt timer. Gets current utilization values from SystemMonitor and updates the progress bars and labels.
Source code in goliat/gui/components/utilization_manager.py
update_plot ¶
Updates the system utilization plot with current values.
Called less frequently (every 2 seconds) to avoid excessive plot updates. Writes to CSV and adds data point to plot.
Source code in goliat/gui/components/utilization_manager.py
goliat.gui.components.web_bridge_manager.WebBridgeManager ¶
WebBridgeManager(gui: ProgressGUI, server_url: str, machine_id: Optional[str], use_web: bool = True)
Manages web GUI bridge initialization and status updates.
Handles connection to web dashboard, collects system info, and manages bridge lifecycle. Keeps web bridge code exactly as is per requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui | ProgressGUI | ProgressGUI instance. | required |
server_url | str | Web dashboard server URL. | required |
machine_id | Optional[str] | Machine ID for identification. | required |
use_web | bool | Whether to enable web bridge (default: True). | True |
Source code in goliat/gui/components/web_bridge_manager.py
Methods:¶
initialize ¶
Initializes web GUI bridge for remote monitoring.
Sets up connection to web dashboard, collects system info, and starts the bridge. Errors are caught so GUI can continue without web monitoring.
Source code in goliat/gui/components/web_bridge_manager.py
sync_progress ¶
Periodically sync actual GUI progress bar values to web dashboard.
Sends the current progress bar values to the web bridge so the dashboard always shows the actual progress, even if progress messages aren't sent.
Source code in goliat/gui/components/web_bridge_manager.py
stop ¶
Stops the web bridge and screenshot capture.
Source code in goliat/gui/components/web_bridge_manager.py
send_finished ¶
Sends final status update to web before stopping bridge.
Sends multiple 100% progress updates with delays to ensure the cloud receives them even if it's lagging behind. This prevents tasks from appearing stuck at 99% on the web interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error | bool | Whether study finished with errors. | False |
Source code in goliat/gui/components/web_bridge_manager.py
Components / Plots¶
goliat.gui.components.plots._matplotlib_imports ¶
Matplotlib imports with fallback handling for plotting components.
goliat.gui.components.plots.overall_progress_plot.OverallProgressPlot ¶
Manages overall progress plot with real-time updates.
Creates a matplotlib line plot showing progress percentage trends over time. Updates dynamically as new data points arrive. Uses green color scheme to distinguish from time remaining plot. Y-axis fixed at 0-100%.
Source code in goliat/gui/components/plots/overall_progress_plot.py
Methods:¶
add_data_point ¶
Adds data point and refreshes plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp | datetime | Timestamp for the data point. | required |
progress_percent | float | Progress percentage as float. | required |
Source code in goliat/gui/components/plots/overall_progress_plot.py
goliat.gui.components.plots.pie_charts_manager.PieChartsManager ¶
Manages four pie charts displaying timing breakdowns by phase and subtask.
Shows visual breakdown of execution time: - Top-left: Phase weights (setup/run/extract relative durations) - Top-right: Setup subtasks breakdown - Bottom-left: Run subtasks breakdown - Bottom-right: Extract subtasks breakdown
Updates automatically when profiler state changes. Filters out fake aggregated entries. Uses color palette for visual distinction.