- This topic has 10 replies, 4 voices, and was last updated 1 year, 9 months ago by AlanM.
-
AuthorPosts
-
3 February 2023 at 7:05 am #615496Nick JamesParticipant
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
3 February 2023 at 2:03 pm #615499Grant PrivettParticipantHi 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.
3 February 2023 at 5:04 pm #615502Nick JamesParticipantGrant,
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.
3 February 2023 at 9:44 pm #615506Dr Paul LeylandParticipantThanks 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.
4 February 2023 at 12:16 pm #615513Grant PrivettParticipantSo, 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.
5 February 2023 at 7:51 am #615536Nick JamesParticipantYou 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.
9 February 2023 at 7:11 am #615691AlanMParticipantNick,
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 bufferYou mentioned ‘an attached script’ in your last post but I couldn’t see any attachment.
9 February 2023 at 7:43 am #615692Nick JamesParticipantHi 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.
10 February 2023 at 6:32 am #615705AlanMParticipantHi 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
11 February 2023 at 9:28 am #615707Nick JamesParticipantHi 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.
13 February 2023 at 6:43 am #615729AlanMParticipantHi 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.
-
AuthorPosts
- You must be logged in to reply to this topic.