icosfit_optimizer - nthallen/icosfit GitHub Wiki

icosfit_optimizer class

This class provides a framework for optimizing icosfit configurations. The basic approach for using all of the optimizers derived from this class is:

  • Create a basic configuration, e.g. via fitline, specifying some limited number of scans to use as a test case.
  • Create an optimizer object
  • Select the first configuration, run icosfit over the test region and add the results to the optimizer object
  • The results are displayed with application-specific menu items

The user interface displayed allows the user to directly compare fit outputs from any two runs including:

  • any fit parameters that are allowed to float
  • chi^2: a measure of the quality of the fit
  • iterations: a measure of how long it took the fit to run
  • nfev: number of function evaluations, another measure of how long the fit took to run

There are several customized tools designed to address specific common optimizations:

  • baseline_optimizer: build an optimal baseline file
  • epsilon2_optimizer: select the best value of epsilon2 for the fastest fits
  • maxiterations_optimizer: select the best value of MaxIterations for the fastest fits

Analysis of long runs

The basic idea of the optimizer classes is to run icosfit over a small number of representative scans to select the best fit configuration. It is not always possible to find a short contiguous set of scans that is representative of a longer run. In this case, it would be nice to select a small number of non-contiguous scans spanning the entire run. Unfortunately this presents challenges of its own. icosfit works best when the current scan is similar to the previous scan, i.e. the fit parameters are not too different, but when skipping dozens of scans, that is not always the case. In particular, icosfit has a particularly hard time if the baseline polynomial values are not 'pretty close' to the correct value.

To work around this, the optimizer regenerates the baseline file for each scan (hence reinitializing the polynomial coefficients) and doing a single scan fit. (Note: This also could be resolved by incorporating a linear least squares polynomial fit of the baseline polynomial coefficients into icosfit.)

Another potential problem is if the line position drifts during the long time skips. For this reason, the nscans option requires that you already have a good enough fit to determine the nu_F0 value for every scan and have created a PTE file with that value in column 12.

Specifying a number for the 'nscans' parameter, will select that many evenly-spaced scans from the entire ScanNumRange and fit those for each optimization step. The optimizer will regenerate the baseline file for each scan, reinitializing the polynomical coefficients in order to avoid startup issues.