Sky Flats Assistant MaximDL Application

This app for use with MaximDL allows the user to take a series of sky flats while automatically compensating for the changing sky brightness. It is also useful for users with light boxes since the exposure duration will need to be adjusted for different filters.


The app can be operated in one of two modes - manual for a single filter or driven by a config file to capture flats for multiple filters in sequence.

In manual mode, you specify the camera binning levels to use and the number of flats you require, which are then taken using whichever filter (if any) is currently in place.

The multi-filter mode allows you to capture a full set of flats using different filters and binning levels in one go - the configuration is entered into a simple text file which the app then processes automatically in the appropriate order.

There is some common setup between the two modes - you need to enter the initial, min and max exposure durations, the target ADU level and error range, along with whether to use the main or guide camera.

The app also supports dithering between exposures to allow the median stacking of the results to remove any stars which may otherwise impare the effectiveness of the flats. The dithering config allows the user to select the ASCOM driver for their mount, plus to specify the starting Alt/Az coords for the run as well as the range in arcsecs the dithering mount slews will fall within. The best location on the sky for flats is ~15 degrees from the zenith in the opposite direction to the sunrise/sunset, so Alt=75 and Az=90 (at dusk) or Az=270 (at dawn).

In multi-filter mode, you create a simple text file with one line per filter/binning combination for which you wish to take flats, as described below.

The initial exposure duration should be chosen to be reasonable for the desired target ADU count – this reduces the iterations required to get to the starting level. It doesn’t need to be accurate though, the app will iterate to get to the correct value.

The target ADU selected should be about 33% of the saturation level of your camera. This will give the most accurate and noise free raw flats which will result in the best master flat once stacked. Going too high can result in pixels outside the linear range of the CCD and too low can result in poor signal-to-noise in the flat. The allowable error percentage allows you to control how close to the target ADU count the flats must be - exposures outside this range will not be saved, rather a new exposure time will be calculated and the exposure retaken. Making this too restrictive may result in a lot of exposures being thrown away.

The app will take the initial exposure and then calculate the exposure duration required for the next exposure, to get it near to the target ADU count.
It continues to take and discard exposures until the average ADU of the image is within the configured allowable error percentage of the target ADU.

The app then loops through the specified number of flat exposures, calculating the exposure duration for the next based on the results of the previous exposure, thus compensating automatically for the dimming/brightening of the sky over the sequence of the flats run. There is also an option to use a predictive algorithm which compares the actual result with the theoretical result of the linear extrapolation, applying a dynamic scaling factor to the subsequent time estimates to compensate for the difference. This is especially useful for cameras which have a long download time.

If the sky is too bright to reach the desired ADU range even using the min exposure duration, then if being run at dusk the app will simply wait for the sky to darken sufficiently, but if being run at dawn the sky will only get brighter so the app aborts taking that set of flats, moving on to the next filter if in multi-filter mode. The inverse mechanism is also supported, when the app will wait for the sky to brighten when run at dawn.

The ideal target number of flats somewhat depends on the noise characteristics of your CCD, but after stacking about 10 flats the signal-to-noise ratio in the flat drops to a level which will generally be insignificant once applied to the light image.

The flats which meet the configured error range are saved in an automatically created timestamped subdir created under the user specified base directory.
Files are saved with a naming convention indicating the scope used, filter and ccd binning, e.g.

I also discovered that by deleting the “FILTER” FITS keyword from the flat files, the calibration group created could be applied to images taken with any filter. This is useful if you don’t need different flats for each filter type since it reduces the number of flats runs required substantially. A filter independent flat is useful to compensate for dust on the ccd or uneven illumination over the ccd, but obviously not for dust on the filter itself. However, it’s generally easy to get to the filter to clean it, compared to the ccd.

Config options:

- Initial exposure, target ADU, allowable error range, number of flats, X and Y binning
- Option to delete the filter keyword.
- Option to use the guide camera rather than the main camera.
- Option to use a predictive algorithm rather than the standard reactive algorithm.
- Path to directory in which to save flats.
- Option to use a multi-filter config file for multiple filter/binning combinations.
- Path to config file.
- Button to bring up the config file for editing in Notepad.
- Option to use enable mount slew/dithering control.
- Initial Alt/Az in degrees.
- Max mount dither distance in arcsecs.

Setup Screen:

Progress Screen:

Multi-filter Config File Format:

The config file format is very simple - it is a tabular list of comma separated values, with each line listing the filter number, target number of flats, X binning, Y binning, plus a free text comment. The comment must not contain any commas itself and must be present in some form.
The order of the entries is important - they should be ordered from darkest filter to brightest, that is the filter/binning combination which is least sensitive to light to the most sensitive.
A typical example would be to start with your Ha filter at 1x1 binning and finish with your Clear filter at 4x4 binning.
When the app performs a multi-filter run at dusk (the evening according to the Windows system clock) it uses the entries in the order they are entered and when it runs at dawn (morning by the clock) it runs them in reverse order.
Thus you can use the same config file for either dusk or dawn flats and the app will adjust the order accordingly.
You must not include any other lines in the config file besides the configuration lines.
An example config file contents may look as follows (without the bounding dashed lines):

0, 10, 1, 1, Ha Filter binned 1x1
0, 10, 2, 2, Ha Filter binned 2x2
2, 10, 1, 1, Red Filter binned 1x1
3, 10, 1, 1, Green Filter binned 1x1
4, 10, 1, 1, Blue Filter binned 1x1
1, 10, 1, 1, Clear Filter binned 1x1
2, 10, 2, 2, Red Filter binned 2x2
3, 10, 2, 2, Green Filter binned 2x2
4, 10, 2, 2, Blue Filter binned 2x2
1, 10, 2, 2, Clear Filter binned 2x2

The filter numbers are those expected by MaximDL and are the same order as shown in the MaximDL filter configuration. Note that the first entry in the MaximDL filter list is number zero (0).
To recap, the fields are:
FilterNumber, FlatsCount, XBinning, YBinning, Comment

Version history:
v1.0 - Initial release.
v1.1 – Fixed overflow bug with 16bit images. Plugin now finds correct exposure before starting run.
v1.2 – Added binning support.
v1.3 – Changed default values for target ADU and number of flats.
v1.4 – Improved file naming to avoid runs with different filters overwriting each other.
v1.5 – Allow filter independent flats to be captured. Increased default number of flats to 10.
v1.6 – Add option to take a flat for the configured guide camera.
v1.7 – Filter out invalid characters from the filename.
v1.8 – Disable debug messages left on in 1.7.
v2.0 – Implement saving of config, user specified target directory, predictive duration estimation algorithm.
v2.1 – Add browse box for save path. Save each run into a timestamped directory. Add min and max exposure time limits. Use subframe to quickly find start exposure time. Validate file save path.
v3.0 – Add multi-filter scripted operation. Support guide camera binning and filters.
v3.1 – Fix saving of binning values in filename for scripted operation.
v4.0 – Move to stand-alone app rather than plugin. Add mount slew/dither control.

SkyFlats v4.0

If you download this to give it a go, please post feedback on the MaximDL Yahoo group, or email me directly at: winfij_AT_gmail_DOT_com
One final note - if you have any errors, please note the exact error messages and let me know!



Up to Home Page