aixcalibuha.utils package
Package containing utility functions used in different packages. Contains a statistics analyzer and a visualizer.
- exception aixcalibuha.utils.MaxIterationsReached[source]
Bases:
Exception
Exception raised for when the calibration ends because the maximum number of allowed iterations is reached.
- aixcalibuha.utils.validate_cal_class_input(calibration_classes: CalibrationClass | List[CalibrationClass]) List[CalibrationClass] [source]
Check if given list contains only CalibrationClass objects or is one and return a list in both cases. Else raise an error
Submodules
aixcalibuha.utils.configuration module
Module to with configs and functions to read configs for objects in this repository.
- aixcalibuha.utils.configuration.get_calibration_classes_from_config(config)[source]
Read the data for a CalibrationClass object.
- Parameters:
config (list) – List of dicts with configs holding the following cols for - names - start_time - stop_time - Optional: goals, tuner_paras, relevant_intervals
- Returns:
TunerParas tuner_paras Loaded Goals object
- aixcalibuha.utils.configuration.get_goals_from_config(config)[source]
Read the data for a Goals object.
- Parameters:
config (dict) – Config holding the following cols for - meas_target_data - variable_names - Optional: weightings
- Returns:
Goals goals Loaded Goals object
- aixcalibuha.utils.configuration.get_tuner_paras_from_config(config)[source]
Read the data for a TunerParas object.
- Parameters:
config (dict) – Config holding the following cols for - names - initial_values - bounds
- Returns:
TunerParas tuner_paras Loaded Goals object
aixcalibuha.utils.visualizer module
Module with classes and function to help visualize different processes inside the framework. Both plots and print-function/log-function will be implemented here. The Visualizer Class inherits the Logger class, as logging will always be used as a default.
- class aixcalibuha.utils.visualizer.CalibrationLogger(cd, name, calibration_class, logger=None)[source]
Bases:
object
Base class for showing the process of functions in this Framework with print-statements and saving everything relevant as a log-file.
- Parameters:
cd (str,os.path.normpath) – Directory where to store the output of the Logger and possible child-classes. If the given directory can not be created, an error will be raised.
name (str) – Name of the reason of logging, e.g. classification, processing etc.
calibration_class (aixcalibuha.CalibrationClass) – Calibration class used in the calibration-process.
logger (logging.Logger) – If given, this logger is used to print and or save the messsages. Else, a new one is set up.
- calibrate_new_class(calibration_class, cd=None, for_validation=False)[source]
Function to setup the figures for a new class of calibration. This function is called when instantiating this Class. If you uses continuuos calibration classes, call this function before starting the next calibration-class.
- Parameters:
- calibration_callback_func(xk, obj, verbose_information, penalty=None)[source]
Logs the current values of the objective function.
- property calibration_class: CalibrationClass
Get current calibration class object
- decimal_prec = 6
- integer_prec = 4
- log_initial_names()[source]
Function to log the initial names and the statistical measure before calibration.
- log_intersection_of_tuners(intersected_tuner_parameters, **kwargs)[source]
If an intersection for multiple classes occurs, an information about the statistics of the dataset has to be provided.
- Parameters:
intersected_tuner_parameters (dict) – Dict with cols being the name of the tuner parameter and the value being the list with all the different “best” values for the tuner parameter.
- save_calibration_result(best_iterate, model_name, **kwargs)[source]
Process the result, re-run the simulation and generate a logFile for the minimal quality measurement
- property tuner_paras: TunerParas
- class aixcalibuha.utils.visualizer.CalibrationVisualizer(cd, name, calibration_class, logger=None, **kwargs)[source]
Bases:
CalibrationLogger
More advanced class to not only log ongoing function evaluations but also show the process of the functions by plotting interesting causalities and saving these plots.
- Parameters:
show_plot (boolean) – If False, all created plots are not shown during calibration but only stored at the end of the process.
create_tsd_plot (boolean) – If False, the plot of the time series data (goals) is not created and thus shown in during calibration. It therefore is also not stored, even if you set the save_tsd_plot keyword-argument to true.
save_tsd_plot (boolean) – If True, at each iteration the created plot of the time-series is saved. This may make the process much slower
show_plot_pause_time (float) – Set the time (in seconds) the plt.draw() pauses. May be altered if show_plot yields plot which disappear to fast. Default is 1-e3 s.
- calibrate_new_class(calibration_class, cd=None, for_validation=False)[source]
Function to setup the figures for a new class of calibration. This function is called when instantiating this Class. If you uses continuuos calibration classes, call this function before starting the next calibration-class.
- Parameters:
- calibration_callback_func(xk, obj, verbose_information, penalty=None)[source]
Logs the current values of the objective function.
- log_intersection_of_tuners(intersected_tuner_parameters, **kwargs)[source]
If an intersection for multiple classes occurs, an information about the statistics of the dataset has to be provided.
- Parameters:
intersected_tuner_parameters (dict) – Dict with cols being the name of the tuner parameter and the value being the list with all the different “best” values for the tuner parameter.
- save_calibration_result(best_iterate, model_name, **kwargs)[source]
Process the result, re-run the simulation and generate a logFile for the minimal quality measurement
- Parameters:
best_iterate (scipy.optimize.minimize.result) – Result object of the minimization
model_name (str) – Name of the model being calibrated