Giter Site home page Giter Site logo

Comments (11)

martinberoiz avatar martinberoiz commented on July 26, 2024 1

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.

Jayesh6999 avatar Jayesh6999 commented on July 26, 2024 1
#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.

Jayesh6999 avatar Jayesh6999 commented on July 26, 2024 1

i hope it helps

from astroalign.

yas-nakajima avatar yas-nakajima commented on July 26, 2024

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.

martinberoiz avatar martinberoiz commented on July 26, 2024

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 nans 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.

yas-nakajima avatar yas-nakajima commented on July 26, 2024

The program without .newbyteorder() lines works for the same FITS files with scikit-image==0.15.0.
The FITS files does not contain nans 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.

martinberoiz avatar martinberoiz commented on July 26, 2024

That is strange. Would you mind sending me the problem images so I can take a look? Thanks.

from astroalign.

yas-nakajima avatar yas-nakajima commented on July 26, 2024

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.

yas-nakajima avatar yas-nakajima commented on July 26, 2024
target_fixed = np.array(target, dtype="<f4")
source_fixed = np.array(source, dtype="<f4")

is a workaround.

from astroalign.

yas-nakajima avatar yas-nakajima commented on July 26, 2024
- 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.

martinberoiz avatar martinberoiz commented on July 26, 2024

Yes, this is a known issue that was introduced in a recent version of scikit-image.

from astroalign.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.