Comments (11)
Hello,
Yes, the issue is similar to the one in scikit-image issue you mentioned. The endian-ness from the source of your data doesn't match the endian-ness of your local computer where you're running astroaling.
Fortunately Numpy lets you swap the endianness quite easy:
https://numpy.org/doc/stable/user/basics.byteswapping.html
target = target.newbyteorder()
source = source.newbyteorder()
I don't think astroalign should deal with different endian issues but the above workaround works well.
Let me know if that fixes the issue for you.
from astroalign.
#Allgignment of Images
image_path='image path'
filename='image / file name'
files=sorted(glob.glob(os.path.join(image_path,filename)))
print(len(files))
ref_image=fits.open(files[0], )
reference_image=ref_image[0].data
for i in range(0,len(files)):
image_data=fits.open(files[i])
source_image=image_data[0].data + 0 #here the addition of zero (0) solves the the endian compiler issue.
header=image_data[0].header
image_aligned,footprint=aa.register(source_image,reference_image)
aligned_file=files[i].replace('.fits','')
fits.writeto(aligned_file+'_aligned'+'.fits',image_aligned,header,overwrite=True)
print('No. %i alignment done'%i)
(after for loop the rest of the code is in indentation)
from astroalign.
i hope it helps
from astroalign.
Thank you for your reply.
It doesn't work.
import astroalign as aa
from astropy.io import fits
target = fits.getdata('target.fits')
source = fits.getdata('source.fits')
target = target.newbyteorder()
source = source.newbyteorder()
reg_im, footprint = aa.register(source, target)
ValueError: Troublesome data array: [ nan nan nan nan 755. nan nan nan nan nan nan nan
nan 151. nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan 1296. nan nan nan nan nan
nan nan]
I am using an intel-Mac with OS 10.15.
I did not expect facing an endian issue.
Thanks
from astroalign.
Well, at least this time you got a different error, it seems like the endian issues you were having before are not a problem.
The problem now is that you have a bunch of nan
s in your arrays. Astroalign will not work if there is missing data. You should fill your nan's with some value, like the background median, or gaussian noise.
from astroalign.
The program without .newbyteorder() lines works for the same FITS files with scikit-image==0.15.0.
The FITS files does not contain nan
s and , for example, DS9 displays the FITS file properly.
It seems .newbyteorder() destroyed data.
target = fits.getdata('target.fits')
source = fits.getdata('source.fits')
print('original')
print(np.max(target), np.min(target))
print(np.max(source), np.min(source))
target_new = target.newbyteorder()
source_new = source.newbyteorder()
print('newbyte')
print(np.max(target_new), np.min(target_new))
print(np.max(source_new), np.min(source_new))
original
38990.938 345.18137
39516.312 -2829.9492
newbyte
nan nan
nan nan
from astroalign.
That is strange. Would you mind sending me the problem images so I can take a look? Thanks.
from astroalign.
Thanks, Martin. I sent you the FITS files.
By the way, the FITSVERIFY yields no errors for them.
I tried with an intel 64bit PC + CentOS 7 and obtained the same results.
from astroalign.
target_fixed = np.array(target, dtype="<f4")
source_fixed = np.array(source, dtype="<f4")
is a workaround.
from astroalign.
- target = target.newbyteorder()
- source = source.newbyteorder()
+ target = target.byteswap().newbyteorder()
+ source = source.byteswap().newbyteorder()
FYI. byteswap() is needed.
Because skimage.transform.warp does not accept Big-endian,
I would suggest adding .byteswap().newbyteorder() in def apply_transform
or def _data
of astroalign.py.
from astroalign.
Yes, this is a known issue that was introduced in a recent version of scikit-image.
from astroalign.
Related Issues (20)
- Aligning two xy arrays, running into Max iterations exceeded for even the simplest cases HOT 9
- repeated find_transform on same sets of (x,y) tuples give different results HOT 5
- TypeError when using Pillow Image object HOT 5
- Initial Update
- Implement "downsampling" HOT 1
- different results from find_transform and estimate_transform HOT 4
- propagate_mask HOT 2
- Add Airspeed velocity benchmarking
- skimage ransac
- Unhelpful error when alignging (large) nan-padded arrays HOT 4
- Add "inverse" on affine transform in Astroalign HOT 2
- [2.4.1] TestFewSources.test_register_threesources fails now (passed before) HOT 1
- Use numpy.random.Generator.shuffle instead of np.random.shuffle HOT 2
- Different results for parallel and sequential implementations of find_transform HOT 1
- Query regarding a section of the source code in `find_transform` HOT 4
- Utilise masking provided by sep HOT 1
- astroalign.MaxIterError: List of matching triangles exhausted before an acceptable transformation was found HOT 5
- Best guide to use for a mosaic?? HOT 4
- Test against numpy 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from astroalign.