Theory Of Operation
In order to focus an image, Ekos needs to establish a numerical method for gauging how good your focus is. It's easy when you look at an image and can see it as unfocused, as the human is very good at detecting that, but how can Ekos possibly know that?
There are multiple methods. One is to calculate the Full Width at Half Maximum (FHWM) of a star profile within an image, and then adjust the focus until an optimal (narrower) FWHM is reached. The problem with FWHM is that it assumes the initial focus position to be close to the critical focus. Additionally, FWHM does not perform very well under low intensity fluxes. An Alternative method is Half-Flux-Radius (HFR), which is a measure of the width in pixels counting from the center of the stars until the accumulated intensity is half of the total flux of the star. HFR proved to be much more stable in conditions where you might have unfavorable sky conditions, when the brightness profile of the stars is low, and when the starting position of the focus is far from the optimal focus.
After Ekos processes an image, it selects either a single star and starts measuring its HFR, or it selects a set of stars matching the criteria that have been set and calculates an average HFR. It can automatically select stars, or you can select a single star manually. It is recommended to allow Ekos to select a set of stars.
Ekos supports 4 different focus algorithms: Iterative, Polynominal, Linear and Linear 1 Pass.
- Linear: In the Linear algorithm, Ekos steps outward from its starting point then moves inward taking regular datapoints through the point of optimum focus and then further inward, to draw a V-Curve. It then fits a quadratic curve to the datapoints and calculates the point of optimum focus. It then moves out again past the point of optimum focus, halves the stepsize and moves in again for a second pass. It looks to follow the curve from the first pass and find the minimum HFR. Due to randomness in the HFR measurements it uses the % tolerance to help decide when it has found a solution. Key features include:
- The algorithm compensates for focuser backlash and can deal with both consistent and inconsistent backlash.
- The algorithm is slow, taking 2 passes to identify optimum focus.
- The algorithm uses curve fitting to pinpoint the optimum focus position in pass 1, but then uses % Tolerance to try to stop as close as possible to this HFR on pass 2.
- The algorithm is highly configurable with user control over many parameters like step size and number of steps.
- Polynomial: In the Polynomial algorithm, the process starts off in Iterative mode, but once we cross to the other side of the V-Curve (once HFR values start increasing again after decreasing for a while), then Ekos performs quadratic curve fitting to find a solution that predicts the minimum possible HFR position. Key features include:
- The algorithm relies on the focuser having well controlled backlash.
- The algorithm can be fast using a minimum number of steps.
- The algorithm uses curve fitting to pinpoint the optimum focus position.
- Iterative: In the Iterative algorithm, Ekos operates iteratively by moving in discrete steps, decided initially by the user-configurable step size and later by the slope of the V-Curve, to get closer to the optimal focus position where it then changes gears and performs smaller, finer moves to reach the optimal focus. The focus process stops when the measured HFR is within the configurable tolerance of the minimum recorded HFR in the process. In other words, whenever the process starts searching for a solution within a narrowly limited range, it checks if the current HFR is within % difference compared to the minimum HFR recorded, and if this condition is met then the Autofocus process is considered successful. The default value is set to 1% and is sufficient for most situations. The Step options specify the number of initial ticks the focuser has to move. If the image is severely out of focus, we set the step size high (i.e. greater than 250). On the other hand, if the focus is close to optimal focus, we set the step size to a more reasonable range (less than 50). It takes trial and error to find the best starting tick, but Ekos only uses that for the first focus motion, as all subsequent motions depend on the V-Curve slope calculations. Key features include:
- The algorithm relies on the focuser having well controlled backlash.
- The algorithm can be fast using a minimum number of steps.
- The algorithm works on a "good enough" paradigm whereby it stops when the HFR is within % Tolerance of the perceived minimum,
Linear 1 Pass: In the Linear 1 Pass algorithm, Ekos initially performs like the Linear algorithm in establishing the first pass V-Curve and fitting a curve to it to find the solution. Then, however, it moves directly to the calculated minimum. Key features include:
- The algorithm compensates for focuser backlash, providing that backlash is consistent.
- The algorithm is fast, taking 1 pass to identify optimum focus.
- The algorithm uses more sophisticated curve fitting to pinpoint the optimum focus position.
Each module has it's own train. You can use a specific train for Focus module. Click here to know more about Optical trains.
Any INDI-compatible focuser is supported. It is recommended to use absolute focusers since their absolute position is known on power up. In INDI, the focuser zero position is when the drawtube is fully retracted. When focusing outwards, the focuser position increases, while it decreases when focusing inwards. The following focuser types are supported:
- Absolute: Absolute Position Focusers such as RoboFocus, MoonLite..etc
- Relative: Relative Position Focusers.
- Simple Focusers: DC/PWM focusers with no position feedback.
For absolute focusers, you can set the ticks count. To view a continuous feed of the camera, click the Framing button. An image shall be captured repeatedly according to the CCD settings in the CCD and Filter Wheel group. You can focus in and out by pressing the respective buttons, and each shall move by the step size indicated in the focus settings. For absolute and relative focusers, the step size is in units of ticks and for simple DC focusers, the step size is in milliseconds. The step size can be changed by specifying its value in the 2nd Steps field. To set an initial focus position or go to a focus position, click on the Go to absolute focus position button. To stop the focus motion, click on the Stop focuser motion button.
To begin the autofocus process, simply click the Auto Focus button. To stop the Auto Focus process, click on the Stop button.
CCD & Filter Wheel Group
For DSLRs cameras, you can change the ISO settings. You may reset the focusing subframe to full frame capture if you click the Reset button.
- Live Video : If your camera supports live video feed, then you can click the Live Video button to start streaming. The video stream window enables recording and subframing of the video stream
- Exp: Specify exposure duration in seconds.
- Toggle Fullscreen : Shows the focus frame in fullscreen, clicking on the button again will place the focus frame back into the docked position.
- Show in FITS Viewer : Shows the focus frame image in FITS Viewer.
- Bin: Specify horizontal (X) and vertical (Y) binning.
- Gain: Specify the value of gain between 0% to 100%. This will increase the signal to noise level of your image.
- ISO: For DSLR cameras, specify the ISO value.
- Filter: Specify desired filter.
- Filter Settings: Use the Filter Manager to specify various settings for each filter including exposure, offset, autofocus, and locking policy.
- Auto Select Star: Automatically detect and select best star for guiding in the image.
- Subframe: Subframe around the focus star during the autofocus procedure. Enabling subframing can significantly speed up the focus process.
- Full field: Measure average HFR from all stars combined in a full frame. This method defaults to the Centroid detection, but can use SEP detection too. Its performance decreases as the number of stars increases.
- Suspend Guiding: Suspend Guiding while autofocus in progress. If the focus process can disrupt the guide star (e.g. when using Integrated Guide Port IGP whereas the guider is physically attached to the primary CCD), then it is recommended to enable this option. When using Off-Axis guider, then this option is not necessary.
- Dark Frame: Check this option to capture a dark frame if necessary and perform dark-frame subtraction. This option can be useful in noisy images.
- Box: Sets the box size used to enclose the focus star. Increase if you have very large stars.
- Annulus: During full field focusing, stars which are inside this percentage of the frame are filtered out of HFR calculation (default 0%). Detection algorithms may also have an inherent filter.
- Settle: Sets the amount of seconds to wait before resuming guiding.
- Detection: Select star detection algorithm. Each algorithm have its strengths and weaknesses. It is recommended to keep the default value unless it fails to properly detect stars.
- SEP: Source Extractor and Photometry, an efficient source detection method based on Source Extractor (Bertin and Arnouts 1996; Bertin 2016). See SEP: Source Extractor as a library in the Journal of Open Source Software.
- Centroid: a source detection based on estimating star mass around signal peaks.
- Gradient: a single source detection based on the Sobel filter. Initial or full-field analysis will use SEP instead of this method.
- Threshold: a single source detection based on pixel values. Initial or full-field analysis will use SEP instead of this method.
- Bahtinov: This is useful for users who do not have a motorized focuser and prefer to focus manually with the aid of a Bahtinov Mask. The telescope has to be pointing at a bright star with the mask placed. Set the detection mode to 'Bahtinov'. After capturing an image, the user has to select a star to focus on. Once the overlay is shown, it is recommended to increase the 'box size' to contain 60-80% of the Bahtinov diffraction pattern. It is preferred to get the smallest HFR possible, ideally less than 1. To do so, adjust the focus knob until the desired focus, then take a capture and compare the HFR value. If the HFR value has increased, the focus knob has to be turned in the other direction. Once the desired HFR value has been reached, ensure to tighten the focus lock screw to prevent the focus from slipping, and afterward, take a photo to confirm everything is in working order.
- Threshold: Threshold percentage value is used for star detection using the Threshold detection algorithm. Increase to restrict the centroid to bright cores. Decrease to enclose fuzzy stars.
- Effect: Apply filter to image after capture to enhance it for preview purposes. It is highly advisable to turn off any effects during the focusing process as it may interfere with HFR calculations.
- Kernel size: This is the gaussian blur kernel size. Used for blurring the image before for instance the Bahtinov edge detection.
- Sigma: This is the gaussian blur sigma value. Used for blurring the image before for instance the Bahtinov edge detection.
- Algorithm: Select the autofocus process algorithm:
- Iterative: Moves focuser by discreet steps initially decided by the step size. Once a curve slope is calculated, further step sizes are calculated to reach optimal solution. The algorithm stops when the measured HFR is within percentage tolerance of the minimum HFR recorded in the procedure.
- Polynomial: Starts with iterative method. Upon crossing to the other side of the V-Curve, polynomial fitting coefficients along with possible minimum solution are calculated. This algorithm can be faster than purely iterative approach given a good data set.
- Linear: Samples focus inward in a regular fashion, using 2 passes. The algorithm can be slow, but it is more resilient to backlash. Start with the focuser positioned near good focus. Set Initial Step Size and Max Travel for the desired sampling interval and range around start focus position. Tolerance should be around 5%.
- Tolerance: The tolerance percentage values decides when the autofocus process stops in the Iterative algorithm. During the autofocus process, HFR values are recorded, and once the focuser is close to optimal position, it starts measuring HFRs against the minimum recorded HFR in the sessions and stops whenever a measured HFR value is within % difference of the minimum recorded HFR. Decrease value to narrow optimal focus point solution radius. Increase to expand dsolution radius.
Caution: Setting the value too low might result in repetitive loop and would most likely result in a failed autofocus process.
- Average over: Sets the number of frames to capture in order to average the HFR value at the current focuser position.
- Num. of rows: The number of rows set in this field will be combined in the Bahtinov max average calculation. Changing this value might help to match the Bahtinov lines on the star pattern more accurately.
- Initial Step size: Initial step size in ticks to cause a noticeable change in HFR value. For timer based focuser, it is the initial time in milliseconds to move the focuser inward or outward.
- Max Step size: The maximum single step size the algorithm is allowed to command as it searches for the critical focus zone. The calculated step size would be limited to this maximum value.
- Settle: Sets the amount of seconds to wait after moving the focuser before capturing the next image during Auto Focus.
- Max Travel: Maximum travel in ticks before the autofocus process aborts.
- Backlash: Number of average frames to capture. During each capture, an HFR is recorded. If the instantaneous HFR value is unreliable, you can average a number of frames to increase the signal to noise ratio.
- Out Step Multiple: This is the number that is multiplied by initial-step-size to get the number of outward steps that the Linear Focus algorithm moves away from the initial position at the start of focusing.
- Capture Timeout: Maximum time in seconds to wait for a captured image to be received before declaring a timeout.
The V-shaped curve displays absolute position versus Half-Flux-Radius (HFR) values. The center of the V-curve is the optimal focus position. Once Ekos crosses from one side of the V-curve to the other, it backtracks and tries to find the optimal focus position. The final focus position is decided by which algorithm is selected.
When framing, the horizontal axis denotes the frame number. This is to aid you in the framing process as you can see how HFR changes between frames.
The relative profile is a graph that displays the relative HFR values plotted against each other. Lower HFR values correspond to narrower shapes and vice-versa. The solid red curves is the profile of the current HFR value, while the dotted green curve is for the previous HFR value. Finally, the magenta curve denotes the first measured HFR and is displayed when the autofocus process concludes. This enables you to judge how well the autofocus process improved the relative focus quality.