ConvergenceLogger#
- class esis.optics.ConvergenceLogger(directory, offset_energy=1000.0)[source]#
Bases:
PrintableA callback which logs the convergence of an optimization to disk.
Intended for
scipy.optimize.differential_evolution(). On every iteration, the best objective value and the standard deviation of the population energies are appended to a CSV file, the best parameter vector is appended to a text log, and a convergence plot is saved, so that long-running fits can be monitored and post-mortemed.Attributes
An offset added to the objective values before plotting on a logarithmic scale, chosen to keep the (typically negative) correlation objective of
DistortionObjectivepositive.The path of the CSV file containing the convergence history.
The path of the text file mirroring the console output.
The path of the convergence plot.
The directory where the log files are saved.
Methods
__init__(directory[, offset_energy])log(message)Print a message to the console and append it to
path_log.Save a plot of the convergence history to
path_plot.to_string([prefix])Public-facing version of the
__repr__method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.Inheritance Diagram

- log(message)[source]#
Print a message to the console and append it to
path_log.- Parameters:
message (str) – The message to log.
- Return type:
None
- to_string(prefix=None)#
Public-facing version of the
__repr__method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.
- offset_energy: float = 1000.0#
An offset added to the objective values before plotting on a logarithmic scale, chosen to keep the (typically negative) correlation objective of
DistortionObjectivepositive.