Open meindertsma opened 2 years ago
I see, astroalign
can't deal with NaN's unfortunately. Try padding with zeros or the median value of the background or compatible noise. Also before sending to register
check that the array dimensions are correct and that the type makes sense.
I can't only be due to the NaNs though, as some of the padded frames did align, and some gave the (normal) MaxIterError
. I don't think I can use 0 or any other number as the fill value, as this will affect the outcome when combing the arrays using a median. I can use nan, because np.nanmedian
ignores them, but any other value might already be in the array.
The dimensions make sense as far as I can tell, and I think the TypeError
is due first error message not being able to handle NaN
s, which is a sep issue.
Is there a way to increase the internal pixel buffer without importing sep
? Or is this unlikely to solve the issue?
I think you have several issues going on and it's hard for me to pinpoint what's not working for you. I'll try to advice you as much as I can, but I suggest you try to reduce the problem to the smallest that reproduce the error.
MaxIterError
it means no transformation was found. Not much you can do about it I'm afraid.np.nanmedian
afterwards, but astroalign just doesn't use it and it may spill the NaN's (or not, just try it)If you want, you can send me a (1) problem image pair and the code you used and I'll try to figure out what's wrong.
My code is:
import numpy as np
import astroalign as aa
from astropy.io import fits
target = fits.open('Combined_band_A13_Lum.fits')[0].data.byteswap().newbyteorder("<")
toalign = fits.open('Combined_band_A12_R*.fits')[0].data.byteswap().newbyteorder("<")
target = np.pad(target, ((target.shape[0], target.shape[0]), (target.shape[1], target.shape[1])), constant_values=np.nan)
toalign = np.pad(toalign, ((toalign.shape[0], toalign.shape[0]), (toalign.shape[1], toalign.shape[1])), constant_values=np.nan)
aa.register(target, toalign, max_control_points=200)
The target is Combined_band_A13_Lum.fits
for each of the below:
with max_control_points=50
:
Works: Combined_band_A18_G*.fits
MaxIterError: Combined_band_A12_Lum.fits
Exception + TypeError: Combined_band_A12_R*.fits
with max_control_points=200
:
Works: Combined_band_A12_Lum.fits
MaxIterError: Combined_band_A12_G*.fits
Exception + TypeError: Combined_band_A12_R*.fits
I have uploaded the files in zip folder here: https://drive.google.com/file/d/1O_mr10SEndYwsTKag0Y7GugyzjFKyUUz/view?usp=sharing The images do all overlap, I checked using Astrometry.net, however the overlap between A18 and A13 is a lot more than between A13 and A12. I think this 'solved' issue with SEP is also related: https://github.com/kbarbary/sep/issues/15
I have 4656x3520 arrays from fits files that I have padded with numpy.nan to be 13968x10560 (a bit excessive, but I wanted to be sure there would be enough space). Minimum example that gives the error for aligning the images:
I want to combine the images into a mosaic, so my idea was to pad them with NaNs, and then align and stack the images, and then trimming excess NaNs.
And this is what I get from running the code above:
Any help with solving my problem would be appreciated. I can provide the fits files if necessary. Edit: The type error is probably because of the NaNs, so I think that that is not the main problem. Edit2: I have tried increasing the detection sigma upto 10, and still got the same error, and then my other images didn't align. I have multiple images that I want to align, and they should all overlap the target I'm using. Some work, some give MaxIterError (possibly due to them not overlapping), but a lot give this error.