Reconstruction mosaics

After mosaics scripts have been run, one must reconstruct the mosaic from the individual frames that were stored. Parts of the mosaic reconstruction pipeline are under development, and might change. There is no fully automated process yet.

Guider-assisted alignment

Cross-correlation techniques do not work 100% of the time on images. However, the telescope guider has coarse information of the position of the images, which does work 100% of the time. This information is used as a first estimate, which can later be improved with cross-correlation techniques. Before anything else, the burstlog recorded by a science camera daemon should be augmented with the position recorded in the rmslog of the guider camera daemon. This is done with the burstlog_mosaic tool from the dotutils. Assuming we have the logs from tintin (H-alpha) and beaker (the guider camera):

burstlog_mosaic burstlog_tintin rmslog_beaker >burstlog_tintin_augmented

Mosaic detection

The second step is figuring out which frames were part of a mosaic, how many different mosaics were made, how many frames per mosaic image, and how many mosaic images in total in a run. This information is extracted from the augmented burstlog by the dump_mosaic tool. It will do almost everything automatically, except it needs to know the size of the images (in pixels) and the scaling factor (the ratio of arcsec/pixel between the guider and science camera images). The ratios are:

List of scale factors
Camera Scale factor Size
scott 49.620 1296×1030
virgil 49.620 1296×1030
alan 49.620 1296×1030
gordon 49.620 1296×1030
john 49.620 1296×1030
parker 32.321 1024×1024
tintin 32.321 1024×1024

So, to continue with the previously generated augmented burstlog:

dump_mosaic burstlog_tintin_augmented 32.321 1024 1024

This will generate a number of files names mosaic_N_SSS, where N is the ID of the mosaic, starting from 0, and SSS is the subburst number (there is one subburst for each wavelength used in the script). You can inspect the files yourself. They should look like this:

12 30 2322.702785 2681.011579
FS_W21N23arfmos_001_1290592319_tintin 6 1655
FS_W21N23arfmos_001_1290592344_tintin 650 1656
FS_W21N23arfmos_001_1290592369_tintin 1285 1665
...

The first line contains the number of images in each mosaic image, then the number of mosaic images, and then the estimated size in pixels of the mosaic images.

The following lines contain the base filenames of the frames which make up the mosaic, and the estimated offset within the mosaic based on the information from the guider.

Flat and dark correction

There is now a separate tool for flat and dark correction, which, for each frame, will determine the closest flats and darks before and after that frame was taken, interpolate between them, and apply them. It uses a burstlog as input. Note that this overwrites the FITS files, so only do this on a copy of the originals.

darkflat_fits burstlog_tintin

Mosaic generation

The next step is generating the intermediate images which need to be blended into mosaic images. This is done by feeding one of the mosaic_N_SSS files into the mosaic2jpeg tool. This tool has a few options that change the way it works. The most useful ones at the moment are:

For Halpha and red continuum, the images need to be flipped both horizontally and vertically. While generating the intermediate images, mosaic2jpeg also prints the commands necessary to run ImageMagick’s convert tool and Enblend. This output can be redirected to a file:

mosaic2jpeg -H -V mosaic_0_001 >commands

If everything went OK, then the commands can be executed in this way:

source commands

The commands look like this:

convert -size 2372x2715 null: -alpha transparent FS_W21N23arfmos_001_1290592319_tintin.jpeg -geometry +24+1676 -composite enblend_FS_W21N23arfmos_001_1290592319_tintin.png
convert -size 2372x2715 null: -alpha transparent FS_W21N23arfmos_001_1290592344_tintin.jpeg -geometry +668+1677 -composite enblend_FS_W21N23arfmos_001_1290592344_tintin.png
convert -size 2372x2715 null: -alpha transparent FS_W21N23arfmos_001_1290592369_tintin.jpeg -geometry +1303+1686 -composite enblend_FS_W21N23arfmos_001_1290592369_tintin.png
...
enblend --output=mosaic_0_001_000.png enblend_FS_W21N23arfmos_001_1290592319_tintin.png enblend_FS_W21N23arfmos_001_1290592344_tintin.png enblend_FS_W21N23arfmos_001_1290592369_tintin.png enblend_FS_W21N23arfmos_001_1290592394_tintin.png enblend_FS_W21N23arfmos_001_1290592419_tintin.png enblend_FS_W21N23arfmos_001_1290592444_tintin.png enblend_FS_W21N23arfmos_001_1290592469_tintin.png enblend_FS_W21N23arfmos_001_1290592494_tintin.png enblend_FS_W21N23arfmos_001_1290592519_tintin.png enblend_FS_W21N23arfmos_001_1290592544_tintin.png enblend_FS_W21N23arfmos_001_1290592569_tintin.png enblend_FS_W21N23arfmos_001_1290592594_tintin.png
enblend --output=mosaic_0_001_001.png enblend_FS_W21N23arfmos_001_1290592619_tintin.png enblend_FS_W21N23arfmos_001_1290592644_tintin.png enblend_FS_W21N23arfmos_001_1290592669_tintin.png enblend_FS_W21N23arfmos_001_1290592694_tintin.png enblend_FS_W21N23arfmos_001_1290592719_tintin.png enblend_FS_W21N23arfmos_001_1290592744_tintin.png enblend_FS_W21N23arfmos_001_1290592769_tintin.png enblend_FS_W21N23arfmos_001_1290592794_tintin.png enblend_FS_W21N23arfmos_001_1290592819_tintin.png enblend_FS_W21N23arfmos_001_1290592844_tintin.png enblend_FS_W21N23arfmos_001_1290592869_tintin.png enblend_FS_W21N23arfmos_001_1290592894_tintin.png
enblend --output=mosaic_0_001_002.png enblend_FS_W21N23arfmos_001_1290592919_tintin.png enblend_FS_W21N23arfmos_001_1290592944_tintin.png enblend_FS_W21N23arfmos_001_1290592969_tintin.png enblend_FS_W21N23arfmos_001_1290592994_tintin.png enblend_FS_W21N23arfmos_001_1290593019_tintin.png enblend_FS_W21N23arfmos_001_1290593044_tintin.png enblend_FS_W21N23arfmos_001_1290593069_tintin.png enblend_FS_W21N23arfmos_001_1290593094_tintin.png enblend_FS_W21N23arfmos_001_1290593119_tintin.png enblend_FS_W21N23arfmos_001_1290593144_tintin.png enblend_FS_W21N23arfmos_001_1290593169_tintin.png enblend_FS_W21N23arfmos_001_1290593194_tintin.png
...
convert mosaic_0_001_000.png -resize 50% -fill white -background black -pointsize 20 -font FreeMono-Vet -pointsize 20 -gravity SouthWest -splice 0x28 -annotate +8+8 "2010-11-24 09:51:59 Halpha   6562.748 ARF" mosaic_0_001_000.jpg
convert mosaic_0_001_001.png -resize 50% -fill white -background black -pointsize 20 -font FreeMono-Vet -pointsize 20 -gravity SouthWest -splice 0x28 -annotate +8+8 "2010-11-24 09:56:59 Halpha   6562.748 ARF" mosaic_0_001_001.jpg
convert mosaic_0_001_002.png -resize 50% -fill white -background black -pointsize 20 -font FreeMono-Vet -pointsize 20 -gravity SouthWest -splice 0x28 -annotate +8+8 "2010-11-24 10:01:59 Halpha   6562.748 ARF" mosaic_0_001_002.jpg

The first set of convert commands creates transparent PNG files the size of the final mosaics, and puts the intermediate JPEG files in the right position. Then follows a set of enblend commands which takes a group of those PNG files, and blends them together, such that no seam is visible. The second set of convert commands adds the annotation to the bottom of the blended images, and converts them to JPEG.

The mosaic2jpeg tool calculates the shift between successive images using cross-correlations. It calculates the shift between successive images in space (ie, between the slightly overlapping images as the guider movies from one point to the next), and in time (ie, between images taken at the same point). A spring relaxation algorithm is used, which optimizes the positions of all images.

Generating movies

Finally, the resulting mosaic JPEGs can be combined into a movie. There are many tools and formats. One way to make movies is to use the transcode command:

ls mosaic_*.jpg >imlist
transcode -x imlist,null -i imlist -y ffmpeg,null -o mosaic_0_001.mpg -V rgb24 -g 2372x2743 -F mpeg2video -R 3

The MPEG movies generated by transcode have a fixed framerate of 25 fps however, which is a bit too fast for solar movies.