Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing FITS file error #101

Closed
dan-adi opened this issue May 27, 2023 · 5 comments
Closed

Importing FITS file error #101

dan-adi opened this issue May 27, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@dan-adi
Copy link

dan-adi commented May 27, 2023

Bug Report

How To Reproduce

I tried to load a fits file, but I get an error probably related to WCS

Code sample

image = FITSImage("C:\\Users\\dan\\Desktop\\notebook\\FWHM\\abell.fits")

Environment

Windows 10

python 3.11.2

A part of my fits header:

DATE-OBS= '2023-05-10T19:50:04.641600' /UT date of Observation                  
UT      = '19:50:04.64       ' /UT begining of observation                      
EXPOSURE=            300.00000 /Exposure time seconds                           
XPIXELSZ=                 6.00 /X pixel size microns                            
CDELTM1 = 6.00000000000000012E-003 /Size of a pixel (x) in mm**                   
XPIXSZ  =                  6.0 /X Binned pixel size as microns                  
YPIXELSZ=                 6.00 /Y pixel size microns                            
CDELTM2 = 6.00000000000000012E-003 /Size of a pixel (y) in mm**                   
YPIXSZ  =                  6.0 /X Binned pixel size as microns                  
INSTRUME= 'ASCOM_Moravian Instruments, G3-16200' /Camera which created data     
FILTERS = 'Green             ' /Filters                                         
CVF     =                5.000 /Conversion factor (e-/adu)                      
READOUTT=                23.40 /Image readout time (sec)                        
X1      =                    1 /X1 image windowing                              
Y1      =                    1 /Y1 image windowing                              
X2      =                 4524 /X2 image windowing                              
Y2      =                 3624 /Y2 image windowing  

Error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[42], line 1
----> 1 image = FITSImage("C:\\Users\\dan\\Desktop\\notebook\\FWHM\\abell.fits")

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\prose\core\image.py:718, in FITSImage(filepath_or_hdu, verbose, load_units, load_data, telescope)
    716     image.metadata["jd"] = Time(image.date).jd
    717 image.fits_header = header
--> 718 image.wcs = WCS(header)
    719 image.telescope = telescope
    721 return image

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\astropy\wcs\wcs.py:612, in WCS.__init__(self, header, fobj, key, minerr, relax, naxis, keysel, colsel, fix, translate_units, _do_set)
    609         self.fix(translate_units=translate_units)
    611 if _do_set:
--> 612     self.wcs.set()
    614 for fd in close_fds:
    615     fd.close()

ValueError: ERROR 5 in wcsset() at line 2775 of file cextern\wcslib\C\wcs.c:
Invalid parameter value.
ERROR 4 in linset() at line 737 of file cextern\wcslib\C\lin.c:
Failed to initialize distortion functions.
ERROR 3 in dssset() at line 2697 of file cextern\wcslib\C\dis.c:
Coefficient scale for DSS on axis 1 is zero..

Attached FITS file

abell.fits.zip

@dan-adi dan-adi added the bug Something isn't working label May 27, 2023
@lgrcia
Copy link
Owner

lgrcia commented May 27, 2023

Hi @dan-adi and thanks for reporting this bug! I can reproduce it.

Would a skip_wcs keyword argument to the FITSImage help? Like

image = FITSImage("C:\\Users\\dan\\Desktop\\notebook\\FWHM\\abell.fits", skip_wcs=True)

Or do you need something fancier? The downside is that an Image.wcs object will not be available but it seems you error is rather from the astropy.wcs module, so you might need to build a new WCS solution anyway.

Whatever solution we agree on, we can make that part of the 3.2.0 (next minor release).

@dan-adi
Copy link
Author

dan-adi commented May 27, 2023

Hi @dan-adi and thanks for reporting this bug! I can reproduce it.

Would a skip_wcs keyword argument to the FITSImage help? Like

image = FITSImage("C:\\Users\\dan\\Desktop\\notebook\\FWHM\\abell.fits", skip_wcs=True)

Or do you need something fancier? The downside is that an Image.wcs object will not be available but it seems you error is rather from the astropy.wcs module, so you might need to build a new WCS solution anyway.

Whatever solution we agree on, we can make that part of the 3.2.0 (next minor release).

Hello, thanks for replying.

I did try:

image = FITSImage("C:\\Users\\dan\\Desktop\\notebook\\FWHM\\abell.fits", skip_wcs=True)

But got:

TypeError: FITSImage() got an unexpected keyword argument 'skip_wcs'

@dan-adi
Copy link
Author

dan-adi commented May 27, 2023

I think you meant insert the option

skip_wcs=True

with the next minor release.. Yes it will be just fine. Thank you

@lgrcia
Copy link
Owner

lgrcia commented May 29, 2023

I released this feature as a patch, available in 3.1.1 (documented here)

Thanks a lot for this issue and please do not hesitate to open more in the future!

Cheers

@lgrcia lgrcia closed this as completed May 29, 2023
@dan-adi
Copy link
Author

dan-adi commented May 29, 2023

I released this feature as a patch, available in 3.1.1 (documented here)

Thanks a lot for this issue and please do not hesitate to open more in the future!

Cheers

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants