Select filter for auto focusing routine

Issue #207 resolved
Former user created an issue

Currently if an autofocus condition is met during a sequence then autofocus will be done with the presently selected filter. A problem arises if this happens during captures with narrowband filters, where the autofocus routine can be incredibly slow and give poor results (ask me how I know!).

Allowing the user to choose their preferred filter for autofocus will allow them to minimise disruption to their sequence, while there should be an option for the current, default behaviour.

Implementation would be similar to what already exists for platesolving.

This would be particularly beneficial for users who are happy with how parfocal their filters are, or use filter offsets.

Comments (15)

  1. Samuel Roehr

    (Apologies, I was the original poster for this).

    I can see a couple of ways, depending on how complex you want it to be.

    To my mind the quickest and least unintuitive solution is to include the option in the autofocus section of the sequencer. That way it is implemented on a per-sequence basis (so the user could still manually launch autofocus on the currently selected filter via the Imaging panel). It also means that you are not constrained to the filters used for imaging in the sequence (so you could sequence multiple narrowband filters, then switch to LUM when the autofocus routine is triggered).

    An alternative is to put it in Options-Equipment, my concern there is how to handle a manually launched autofocus routine? Forcing the user to go back to the Options tab just to allow them to choose what filter seems excessive.

    More advanced options could include a routine to determine the best filter for focusing (eg. in bad seeing, it might be that RED offers the best HFR/V-curve combo), then build an offset table around that. I don’t see that as essential though; manual control is effective, and while laborious, calculating your own offsets is pretty straight forward.

  2. Yannick Dutertre

    I was thinking about a default focusing filter in the filter list under the Equipment options. You are right though, you may want to use a different broadband filter depending on your target, conditions, and imaging train (which may not focus all colors at exactly the same point). And this also links back to something else I've been thinking about for OSC: After Debayering, which channel to use to do autofocus? Would be nice to have a single setting applying to mono and OSC imaging. But would imply defining mono filters as broadband Lum, R, G, and B. And then have a “Focus channel” in the sequence autofocus menu. Empty being current filter (or unweighted grayscale for OSC).

  3. Yannick Dutertre

    Otherwise, Samuel, with NB filters, have you tried setting Star Sensitivity to High and Noise Reduction to Normal? This helped me reduce my exposure time to narrowband filters

  4. Samuel Roehr

    When I first posted the suggestion I had the same thought about Options-Equipment being the place to put it, but after considering it some more, that would just create more issues than it would solve (you already have to switch filters manually before autofocus when you want to use a specific filter for the job, making the user also adjust a saved setting seems counter-intuitive). You could put a drop-down on the autofocus panel in Imaging to allow the user to manually override a setting, ala. plate solving panel, but that seemed also over the top given that a set-and-forget option really only matters for sequencing. Having the option to select the filter on the AF panel may still be beneficial for manually triggered autofocus routines, I just don’t like the design idea that has you overriding things all over the place for no gain.

    Hence I concluded that a per-sequence settings makes the most sense. Even better, there are already per-sequence autofocus options that need to be set anyway, so it fits quite naturally. The only settings there that conflicts is trigger autofocus on filter change, but that’s just a case of setting the UI so that option is disabled when a filter is specified (or vice-versa).

    OSC is trickier, I can only speculate here as I have a well corrected 'scope and my OSC is limited to DSLRs. Having the ability to focus per channel does make some sense. Green, for example, has twice the number of Bayer array sites as red and blue, is less likely to be lost in nebulosity (my current problem with Ha focusing during a sequence), red tends to be less affected by poor seeing, and blue tends to be the hardest colour for refracting optics to correct.

    From a UI design perspective, have the options influenced by the debayer setting in Options-Imaging? If the user has debayer image disabled, populate the filter list per the filterwheel, if it is enabled, R, G or B (L for OSC would just be all 3, thus the 'blank' option? Might actually be better to include it just so it is obvious). That only leaves issues for OSC users with a filter wheel (as opposed to a fixed filter in their image train) or an OSC user who doesn't debayer. The first is a pretty edge case, I can't imaging you would need too many hands to count the number of users facing that dilemma. The second is a non-issue in my mind - if you don't debayer, NINA can hardly split the channels (as it doesn't know they exist).

  5. Samuel Roehr

    Yes I did. The problem is that I was imaging an area with no really strong stars and lots of nebulosity with a 5nm Ha filter. The stars are easily lost in all the Ha signal, the curves look shockingly bad, and the best fit ends up, well, trying its best (and being off the mark).

    Looking at my images, after it spent nearly 45 minutes trying to get focus through the Ha filter, NINA settled on a focuser position that was a full integer worse HFR. I don’t blame the routine, it did what was asked - to adapt a phrase, poor data in, poor data out.

    My temporary solution now is to focus every x frames, making sure x is in a LUM portion of the sequence. Not super efficient (I prefer every x degrees in temperature change), but better some wasted time than a pile of wasted frames.

  6. Yannick Dutertre

    Oh, and do you by any chance have a screenshot of your curve? I’ve been playing with doing quadratic fitting on the curve, which should be better for noisier curves, wondering if it could have helped in this case.

  7. Samuel Roehr

    Sorry Yannick, no screen shot; it happened after I had headed off to bed, and the temperature had stabalised enough that it didn’t trigger another autofocus event for 3 hours (close to the end of astronomical darkness). Looking at the FITS headers I can see that it calculated the focus position to be about 700 steps further out of focus than the previous auto focus run (which had been done while the temperature was 1 degree higher). My setup sees 1,000 steps fall just shy of 1mm of focuser travel, so the routine moved things quite some way in the wrong direction. If I had been awake and monitoring things I would have manually fixed it pretty quickly, instead I lost several hours of imaging (such is this hobby).

    I’ll do some manual runs tonight to get some screenshots of the curves for you. The region in question is NGC 6334 (Cat’s Paw Nebula) - to add to many stars being lost in the Ha signal, this area also has some small, bright knots of Ha emitting gas; I can’t see ‘behind’ the algorithm to know exactly what your autofocuser code is looking at, but this may have also thrown things off. Setting a brightest star limit may help, but that also affects AF routines through other filters. I’ll get some snapshots at AF friendly exposure lengths for you too.

  8. Yannick Dutertre

    Thanks Samuel!

    You can have a look at the star detection results using the Annotate Image option in the Imaging Options - shows you which stars are being detected (and then you could adjust the star sensitivity settings accordingly).

  9. Samuel Roehr

    Ok, did some manual AF routines early in the evening.

    First up, lum filter - 6 second exposures, no binning, 1 exposure per focus step (for speed). End result, not a bad curve, would be improved if I went 3 exposures per focus step as seeing was pretty average.

    Now the same again with Ha. 60 second exposures, no binning, one exposure per focus step…

    Not good. The annotations on the final ‘check’ image look pretty good. Sadly from one exposure to the next it’ll move between a good number of identified stars, and a trash number of trashy stars. I tried it with a shorter exposure (30 seconds), but I didn’t even bother letting it finished - I gave up once it got to the point of detecting 0 stars in about 10 of 15 exposures.

    In both cases, star sensitivity was high, noise reduction normal.

  10. Stefan B repo owner

    Hey Samuel,

    looking at the curve screenshots it looks like the step size might be too small.

  11. Yannick Dutertre

    For the moment, I am putting in a PR for a single auto-focus default filter, which should cover 99% of cases if the offsets are properly set.

  12. Log in to comment