QUADRATIC best fit Focus routine TESTING - SEND LOGS

Send me all the logs you have saved and I will send you some results that you can validate your runs against.

Finally, after 6 weeks of intense effort by all involved, we have released our Quadratic Best Fit Focus routine. Ken is now evaluating it.

Those working on this project include @bulrichl, @mikaelA, @jmacon, and an early recruit NicolĂ s de Hilster.

We have developed a system that allows us to compare our new routine with the current routine in SGP. I should be clear about what it does and does not do. It has nothing to do with star detection. It is the routine that evaluates the focus data comprising the set of Focuser Positions vs average HFR for each image to decide what the new best focus position should be.
To demonstrate the improvement our routine provides we have plotted graphs of Temperature versus Focuser Position, comparing what SGP produces versus our new Quadratic routine. To visually observe how the routine is operating, we have produced graphs of all 3233 focus runs that our log contributors have provided. An example:
FORUM1 FORUM2

This example illustrates one of the kinds of focus curves that SGP has difficulty with. The quadratic curve models this curve nicely. The red X shows a data point that the routine decided was bad data and ignored. The purple down arrow centered on the quadratic curve is the best focus determined by the quadratic routine.

The following charts display the results of a single night of taking continuous auto focus runs with my Televue NP127is refractor, a total of 154 focus runs. The first graph plots the SGP focus positions vs Temperature, the second plots the Quadratic Routine focus position vs Temperature. Quadratic clearly produces superior results.


The routine has evolved through many iterations over the past 6 weeks and has been thoroughly tested on a wide range of hardware, focus settings, observing conditions, and focus curve quality.

2 Likes

In Proposal of a "Quadratic Fit" Auto Focus evaluation method - Auto Focus - Main Sequence Software I suggested Quadratic Fit (QF) as an alternative method for the evaluation of best focus from Auto focus data. This is the base of Jerry’s application.

For the comparison of best focus results obtained from different evaluation methods an objective measure is needed to judge which one is superior. In the thread cited above, a simple method for this judgement was presented as well:
For both of the methods best focus vs. temperature (T) charts were plotted, a linear regression was made, and the temperature coefficient c (= negative slope of the fitting line) and the coefficient of determination, R^2, were calculated. The better method for evaluating best focus is the one which results in a better correlation of best focus with temperature, i.e. which results in the larger R^2.

In the course of our cooperation I developed a spreadsheet that is capable of processing the results of hundreds of AF runs at one blow. It calculates, displays and exports as graphic the quadratic fitting curve from the AF data of each AF run. Furthermore it displays the best focus vs. T plot for the whole data set, both for SGP’s and QF’s best focus results. The comparison of the best focus vs. T plots and the comparison of the calculated R^2 immediately shows which method is superior. The graphics Jerry presented are generated with this spreadsheet.

The underlying data were extracted from the SGP logfiles by Mikael’s (mikaelA) SGP AutoFocus LogViewer - Auto Focus - Main Sequence Software .

Actually the improvement of the best focus values that Jerry demonstrated above is such that a previously unvisible feature of his used instrument (Televue NP 127is) is revealed: the temperature coefficient is temperature dependent. At higher temperature, the temperature coefficient is larger than at lower temperature. This dependence is better described by a polynome of grade 2. Therefore I append one additional chart [3] that complements the charts presented by Jerry above:

[1] SGP: best focus vs. T, linear regression, R^2 = 0.9104, c = -5.2
[2] Quadratic: best focus vs. T, linear regression, R^2 = 0.9865, c = -5.2
[3] Quadratic: best focus vs. T, polynomial regression grade 2, R^2 = 0.9933, c: temperature dependent, see below

For case [3] the polynome is calculated as:
f(T) = 0.0905 T^2 - 4.90 T + 25365.2
The first derivative which gives the temperature coefficient then is:
f’(T) = 0.181 T - 4.90
(Important: T is specified in degrees F!)

This function must not be applied beyond the upper and lower bounds of the measured data, so the function is valid only in the temperature range from 48 to 64 degrees F. The change of the temperature coefficient is like this:

T [°F]	c [steps/°F]
  48       -3.8
  50       -4.2
  52       -4.5
  54       -4.9
  56       -5.2
  58       -5.6
  60       -6.0
  62       -6.3
  64       -6.7

best_focus_vs_T_JM_20190917_Quadratic_polynomial
I guess this is a convincing example for the superiority of QF to SGP’s current method.

Bernd

1 Like

The improvement on the temperature versus focus plot is very impressive and gives credence to the quadratic fit method.

It is mentioned that this has been tested over a large range of hardware. Is the improvement on the temperature plot significant over all cases, or it is marginal for some configurations or settings?

Another issue in general with autofocus is the imaging time wasted. I think there would be value in minimizing the number of AF points needed. What’s your thoughts on this? Does the benefit of QF comes at the expense of more points needed?

On the other hand the QF AF scan range can be smaller since there is no need to go in the linear region of the V-curve, so the time the focuser is moving is reduced.

Anyway, I am looking forward to having the QF focus as an option in SGP.

@MARA25 you make some good points. The benefit does extend to all the configurations we had logs for. However, the benefit is proportional to the quality of your curves. If your curves are really good, just about any method gives good results, the bottom of a sharp V curve is easy to find. The more problematic curves you have, perhaps with a little irregularity around the bottom, that is where the quadratic improves the results dramatically. Choppy bottoms have little effect on the center point of a fitted quadratic curve. You will be able to get good results with fewer data points.

Guys. I’m really impressed. When I next have my RCT on the PMX, I will store some logs. I know from the past that I get asymmetrical curves when it’s slightly out of collimating.
Is it best to give images or use the focus log extractor that was linked to an earlier post of bulrichl?

Hi Chris,

images or the extract generated by SGP AF LogViewer will not be sufficient, we would need the SGP logfiles. If you are interested to have your data evaluated, please specify a link to the corresponding SGP logfiles.

For the next 14 days Jerry is travelling in Europe, so you can send the link to me via personal message. Then I will send back a report containing the results (text file and charts).

Bernd

Thanks Bernd - no rush - I have to finish the squid neb first before I swap over to the RCT. Most online images have 20h +, just for OIII.

Hi Jerry, only just now saw your post, thanks for including me, much appreciated!

For those not directly involved: I have only suggested to implement a robust detection of outliers based on the Mean Absolute Deviation (MAD) algorithm, which seems to do its job quite well on the focus runs. In addition I supplied a number of logfiles, verified some of the calculations done, and shared my thoughts.

So most of the real work has been done by the rest of the team, but I am glad my input is appreciated.

NicolĂ s

PS: today we had confirmation that Jared is working on the implementation, which he hopes to test later this evening.

My first try with the new autofocus routine!
image

The autofocus log viewer does unfortunately not handle the new routine without modifications

Just wanted to thank Jerry M, Jared and Ken for adding this focusing routine…I meant to write this several months ago when I did the upgrade with this new focus feature. For me, it works flawlessly and seems quicker. A few years ago, I saw this video that helped me with my settings which translated to this knew routine seamlessly. It is a two part youtube video, Sequence generator Pro - Part 1 of 2 Setting up auto focus - YouTube