JuliaAstro / FITSIO.jl

Flexible Image Transport System (FITS) file support for Julia
http://juliaastro.org/FITSIO.jl/
MIT License
55 stars 29 forks source link

Adjust header output formatting for better compatibility #180

Closed sefffal closed 2 years ago

sefffal commented 2 years ago

In working on https://github.com/JuliaAstro/AstroImages.jl/issues/29, I found that for some images WCSLib could parse the headers in some FITS files just fine, but loading the headers with FITSIO and then calling string created headers that WCSLib could not read.

Doing a before and after diff, I found there were some minor differences in how string values are formatted.

This PR changes the formatting so that WCS.jl and WCSLib can read headers loaded by FITSIO from more images.

Before:

OBJECT  =                  ' ' / Name of the object observed
DATE    = '2009-09-03T04:30:56' / Date FITS file was generated
IRAF-TLM= '00:30:56 (03/09/2009)' / Time of last modification
EQUINOX =               2000.0 / Mean equinox
RADECSYS=               'ICRS' / Astrometric system
CTYPE1  =           'GLON-CAR' / WCS projection type for this axis
CUNIT1  =                'deg' / Axis unit
CRPIX1  =       1800.950026799 / Reference pixel on this axis
CD1_1   =   -0.099999998509884 / Linear projection matrix
CTYPE2  =           'GLAT-CAR' / WCS projection type for this axis
CUNIT2  =                'deg' / Axis unit

After:

OBJECT  = '        '           / Name of the object observed
DATE    = '2009-09-03T04:30:56' / Date FITS file was generated
IRAF-TLM= '00:30:56 (03/09/2009)' / Time of last modification
EQUINOX =               2000.0 / Mean equinox
RADECSYS= 'ICRS    '           / Astrometric system
CTYPE1  = 'GLON-CAR'           / WCS projection type for this axis
CUNIT1  = 'deg     '           / Axis unit
CRPIX1  =       1800.950026799 / Reference pixel on this axis
CD1_1   =   -0.099999998509884 / Linear projection matrix
CTYPE2  = 'GLAT-CAR'           / WCS projection type for this axis
CUNIT2  = 'deg     '           / Axis unit

Original (loaded in DS9):

OBJECT  = '        '           / Name of the object observed                    
DATE    = '2009-09-03T04:30:56' / Date FITS file was generated                  
IRAF-TLM= '00:30:56 (03/09/2009)' / Time of last modification                   
EQUINOX =      2.000000000E+03 / Mean equinox                                   
RADECSYS= 'ICRS    '           / Astrometric system                             
CTYPE1  = 'GLON-CAR'           / WCS projection type for this axis              
CUNIT1  = 'deg     '           / Axis unit                                      
CRPIX1  =       1800.950026799 / Reference pixel on this axis                   
CD1_1   =   -0.099999998509884 / Linear projection matrix                       
CTYPE2  = 'GLAT-CAR'           / WCS projection type for this axis              
CUNIT2  = 'deg     '           / Axis unit  

As you can see, string values are now left aligned and padded to 8 characters.

codecov[bot] commented 2 years ago

Codecov Report

Merging #180 (3616797) into master (0c6e209) will increase coverage by 0.05%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
+ Coverage   91.11%   91.16%   +0.05%     
==========================================
  Files           5        5              
  Lines         675      679       +4     
==========================================
+ Hits          615      619       +4     
  Misses         60       60              
Impacted Files Coverage Δ
src/header.jl 85.63% <100.00%> (+0.32%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0c6e209...3616797. Read the comment docs.

sefffal commented 2 years ago

Looks like there is one more challenge with trialling white space in some files! I will make a new PR for that as well.