Comet image stacking

Forums Comets Comet image stacking

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #615496
    Nick James
    Participant

    While browsing the images in the gallery I’ve been interested to read how people do comet image stacking. Most of the methods seem to involve a lot of steps with a risk of introducing artefacts so I thought it might be worth starting a discussion on this.

    I have written a small program which does this automatically using the predicted offset motion of the comet. It can generate three types of output FITS image: An image stacked on the stars with the comet trailed, an image stacked on the comet with the stars trailed and an image where the comet’s motion is frozen against the starfield. The first two are just simple stacks, optionally using sigma clipping, the last one is iterative. Basically, it first does a sigma-clipped stack aligned on the stars to get a star reference and then subtracts the result from each input image. It then does a sigma-clipped stack of the resulting images at the comet’s offset rate to get a comet reference and subtracts this from each input image. It iterates around a few times doing this and, if there are plenty of subs and the comet is moving relatively quickly it does a good job of separating the two. At the end it combines the comet and the stars back together into a single FITS image. The advantage of this approach is that it is completely automatic and it produces stacks which are astrometrically and photometrically valid. I used this method for the image here:

    https://britastro.org/observations/observation.php?id=20230131_220551_34520a4452726a6a

    If anyone wants to have a go at using this program you can download it from here:

    https://www.nickdjames.com/Software/fcombine

    This was built under Ubuntu LTS 22.04 and you will need to install the following libraries to get it to work:

    apt install libgd-dev libcfitsio-dev wcslib-dev libgsl-dev

    #615499
    Grant Privett
    Participant

    Hi Nick,

    Thanks for making the code available. Always interesting to hear how other people do things.

    As you mention Ubuntu, I assume fcombine does not run under Windows.

    For us heathens still using Windows, do you know if that archive can be used in a Windows WSL2 instance? Under W10 WSL2 there is a simple Linux command line environment*, but I believe W11 WSL2 instances have a full graphical interface. Have you used fcombine under that?

    Finally, what language is the code in? The mention of libcfitsio kinda suggests C. Just curious as to how you work out interframe offsets and rotations – my own code for that works but isn’t elegant or especially fast.

    *I run my astrometry.NET installation under it using Ubuntu installed on a Windows laptop via WSL2 – though Windows gave me a choice of which Linux.

    #615502
    Nick James
    Participant

    Grant,

    It’s command line so will run fine under WSL.

    It is indeed C.

    It only translates images. There is no need to rotate with an equatorial that has decent polar alignment. Translation is by integer pixels. There is no sub-pixel interpolation since that would be bad for photometry. Alignment is done by centroiding a reference star.

    #615506
    Dr Paul Leyland
    Participant

    Thanks Nick.

    Now snaffled. I already have code to do the first two functions and will implement the third based on your suggestion. My version uses Perl and SWarp.

    #615513
    Grant Privett
    Participant

    So, is it the case that you manually select an unsaturated star on the first image, which is then automatically followed, or is it that you click on the same reference star in all images?

    As I recall, you use a Paramount, so your periodic error is much smaller than with my NEQ6 – the former approach would not work well with the NEQ6 as a star can shift quite a lot at one point of the gear cycle (I lose about 15-20% of 30sec exposures – yeah, getting the OAG going sometime is on the “TO DO” list).

    If you were interested I could dig out the code for automatically working out interframe offsets, so you don’t need to do a manual selection at all. The C version I lost years ago but, I still have the Fortran, VB6 and Python code knocking about. Translating to C would not be a long job. I was sort of surprised that there’s nothing obvious to use for image alignment in AstroPy.

    #615536
    Nick James
    Participant

    You can provide the image coordinates of the guide star manually or use something like SourceExtractor to select one automatically. I don’t use a Paramount but it tracks the guide star frame by frame so you would need to have pretty awful PE for it to lose lock. The search radius is configurable and if some of the subs are trailed you can set a PSF threshold which is used to reject images from the stack.

    As an example of how it can be used the attached script uses fcombine to automatically stack stars and comets. The STAR option is simple. The COMET option is a bit more complex since it uses a local version of astrometry.net to platesolve so that it can get the offsets right.

    #615691
    AlanM
    Participant

    Nick,

    I had a go at using the program yesterday. I didn’t have anything setup on my laptop so I installed a WSL development environment.
    Running without any options (fcombine outfile infiles) generated an image stacked on the stars with the comet trailed. I then tried the -C option. This resulted in ‘Could not allocate output buffer’ error message. It gave an empty output file. I suspect it is something I haven’t got in my environment or not giving to the program. I ran with the -v option but this didn’t give any more relevant information:

    Mid time: 2023-01-27 05:44:08, Span: 1962s, Exposure: 32x60s
    Could not allocate output buffer

    You mentioned ‘an attached script’ in your last post but I couldn’t see any attachment.

    #615692
    Nick James
    Participant

    Hi Alan,

    The “could not allocate output buffer” message occurs if the program can’t allocate enough memory to do the stack or if the star and/or comet offset pixel-shift lists are incorrect. Can you post the exact command line that you are using so I can see where it might be going wrong.

    It looks as if I can’t attach scripts to the posts here but you can find it here:

    https://nickdjames.com/astrolinux/

    Nick.

    #615705
    AlanM
    Participant

    Hi Nick,

    Memory would make sense. I am limited for memory on the laptop I’m using. The command line that I’m using is:

    fcombine -C -v fitout1 IN/* (where IN is a folder with my fit files.)

    Regards

    Alan

    #615707
    Nick James
    Participant

    Hi Alan,

    The program isn’t that clever! You need to tell it the X,Y coordinates of a guide star and search radius using “-a x,y,r” (this is used to align the stacks) and then the comet offset rate and image scale using “-o rate,pa,scale”. You can also tell it the image orientation if it is not north up using “-A pa”. Have a look at the autostack script to see how I have automated this. Alternatively you can get all of these things manually. A valid example command line would be:

    fcombine -C -N -a 1006,221 -A 1.37 -o 8.86,190.2,5.49 outputfile inputfiles

    In this case -N says to normalise all of the input images to the same sky background before stacking, the guide star is at 1006,221 in the image (using the default search radius of 5 pixels). The image PA is 1.37 deg, the image scale is 5.49 arcsec/pix and the comet motion is 8.86 arcsec/min in PA 190.2.

    If you just type fcombine with no options it will list the options that it can accept.

    #615729
    AlanM
    Participant

    Hi Nick, thank you. Wishful thinking on my part! I had tried various options but the ‘Could not allocate output buffer’ error stopped me stumbling across the correct ones. I’m pleased to say applying the correct options resolves the issue.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.