CADETProcess.comparison.Comparator#
- class CADETProcess.comparison.Comparator(name)[source]#
Bases:
StructureClass for comparing simulation results against reference data.
- Attributes:
- namestr
Name of the Comparator instance.
- referencesdict
Dictionary containing the reference data to be compared against.
- solution_pathsdict
Dictionary containing the solution path for each difference metric.
metricslistlist[DifferenceBase]: List of difference metrics.
- add_difference_metric(difference_metric: DifferenceBase | str, *args: Any, **kwargs: Any) DifferenceBase[source]#
Add a difference metric to the Comparator.
- Parameters:
- difference_metricDifferenceBase
Difference metric instance to register.
- solution_pathstr
Path to the solution in SimulationResults.
- Returns:
- DifferenceBase
- Raises:
- TypeError
If difference_metric is not a DifferenceBase instance.
Notes
Passing a metric class name as a string is deprecated. Construct the metric directly instead:
metric = SSE(reference) comparator.add_difference_metric(metric, 'outlet.outlet')
The string form will be removed in v1.0.
- add_reference(reference: SolutionBase, update: bool | None = False, smooth: bool | None = False) None[source]#
Add reference to the Comparator.
Deprecated since version Use: the new API instead: construct the metric with the reference directly and pass the instance to
add_difference_metric(). This method will be removed in v1.0.- Parameters:
- referenceSolutionBase
Reference for comparison with SimulationResults.
- updateOptional[bool], default=False
If True, update existing reference.
- smoothOptional[bool], default=False
If True, smooth data before comparison.
- Raises:
- TypeError
If reference is not an instance of SolutionBase.
- CADETProcessError
If Reference already exists.
- evaluate(simulation_results: SimulationResults) list[float][source]#
Evaluate all metrics for a given simulation and return the results as a list.
- Parameters:
- simulation_resultsSimulationResults
The SimulationResults object containing the solutions for all metrics.
- Returns:
- list[float]
A list containing the values of all difference of metrics after comparison.
- extract_solution(simulation_results: SimulationResults, metric: DifferenceBase) SolutionBase[source]#
Extract the solution for a given metric from the SimulationResults object.
- Parameters:
- simulation_resultsSimulationResults
The SimulationResults object containing the solution.
- metricDifferenceBase
The difference metric object for which to extract the solution.
- Returns:
- SolutionBase
The solution for the given metric.
- Raises:
- CADETProcessError
If the solution path for the given metric is not found.
- property metrics: list[DifferenceBase]#
list[DifferenceBase]: List of difference metrics.
- name#
Parameter descriptor constrained to string values.
- plot_comparison(simulation_results: SimulationResults, x_axis_in_minutes: bool | None = True, ax: ndarray[Axes] | None = None, setup_figure_kwargs: dict | None = None) tuple[Figure, ndarray[tuple[Any, ...], dtype[Axes]]][source]#
Plot the comparison of the simulation results with the reference data.
- Parameters:
- simulation_resultsSimulationResults
Simulation results to compare to reference data.
- x_axis_in_minutes: Optional[bool], default=True
If True, the x-axis will be plotted using minutes. The default is True.
- axnp.ndarray[plt.Axes] | None, default=None
Optional array of Matplotlib Axes. If not provided, a new figure is created.
- setup_figure_kwargsdict | None, default=None
Additional options to setup the figure.
- Returns:
- tuple
A tuple containing: - list[plt.Figure]: A list of Matplotlib Figure objects. - npt.NDArray[plt.Axes]: An array of Axes objects with one Axes per
difference metric.