[AstroPy] Format of a FITS-LDAC file

David Shupe shupe at ipac.caltech.edu
Tue Jun 13 13:47:45 EDT 2017


A solution I’ve used is to provide an ascii header file to SCAMP. The astrometry solution represented by the WCS keywords in the ascii header will override that in the LDAC_IMHEAD extension of the FITS-LDAC catalog.

As others pointed out, SCAMP does not recognize the SIP keywords. There are some modules in  https://github.com/stargaser/sip_tpv/ <https://github.com/stargaser/sip_tpv/> that can be used to convert your astropy header object with SIP keywords to the TPV format. Then you can use the .totextfile method of your header to write the ascii header for SCAMP to use.

David

> On Jun 13, 2017, at 1:42 AM, Lehtinen Kimmo (MML) <kimmo.lehtinen at nls.fi> wrote:
> 
> Hi 
> 
> I need to make a FITS-LDAC file for the SCAMP program. 
> Normally this file is made with the Sextractor program but this time I am 
> calculating the star positions outside Sextractor, within Python. 
> 
> I am using a FITS-LDAC file made with Sextractor as a template so that I do not
> need to make eveything from scratch. Let's open the FITS-LDAC template:
> 
> >>> from astropy.io <http://astropy.io/> import fits
> >>> hdulist=fits.open('LDAC-template.fits')
> >>> hdulist.info <http://hdulist.info/>()
> Filename: LDAC-template.fits
> No.    Name         Type      Cards   Dimensions   Format
>   0  PRIMARY     PrimaryHDU       4   ()      
>   1  LDAC_IMHEAD  BinTableHDU     12   1R x 1C   [17760A]   
>   2  LDAC_OBJECTS  BinTableHDU     57   1762R x 13C   [1J, 1E, 1E, 1J, 1D, 1D, 1E, 1E, 1E, 1I, 1I, 1J, 1E]  
> 
> So there are three HDU objects. 
> The hdulist[2] includes the positions and fluxes of the stars. I am able to replace 
> hdulist[2] with a binary table HDU object made with the BinTableHDU.from_columns 
> function. 
> 
> The problem is hdulist[1] which includes the astrometry of the image. 
> The content of hdulist[1]:
> 
> >>> hdulist[1].header
> XTENSION= 'BINTABLE'           / THIS IS A BINARY TABLE (FROM THE LDACTOOLS)    
> BITPIX  =                    8 /                                                
> NAXIS   =                    2 /                                                
> NAXIS1  =                17760 / BYTES PER ROW                                  
> NAXIS2  =                    1 / NUMBER OF ROWS                                 
> PCOUNT  =                    0 / RANDOM PARAMETER COUNT                         
> GCOUNT  =                    1 / GROUP COUNT                                    
> TFIELDS =                    1 / FIELDS PER ROWS                                
> EXTNAME = 'LDAC_IMHEAD'        / TABLE NAME                                     
> TTYPE1  = 'Field Header Card'                                                   
> TFORM1  = '17760A  '                                                            
> TDIM1   = '(80, 222)'                
> 
> 
> >>> hdulist[1].data
> FITS_rec([ (chararray([ 'SIMPLE  =                    T  /,
>        'BITPIX  =                  -32 / Number of bits per data pixel',
>        'NAXIS   =                    2 / Number of data axes',
>        'NAXIS1  =                 8736 /',
> ... many fits keywords...
>        'SEXDWSCL=   0.000000000000E+00 / Detection-weight re-scaling factor',
>        'END'], 
>       dtype='|S80'))], 
>       dtype=[('Field Header Card', 'S80', (222,))])
> 
> 
> 
> I need to replace hdulist[1].data with a header that I read from a separate 
> FITS-file. The header includes astrometry made with www.astrometry.net <http://www.astrometry.net/>.
> Lets open that file:
> 
> >>> wcs = fits.open('wcs.fits')
> >>> wcs[0].header
> SIMPLE  =                    T / Standard FITS file                             
> BITPIX  =                    8 / ASCII or bytes array                           
> NAXIS   =                    0 / Minimal header                                 
> EXTEND  =                    T / There may be FITS ext                          
> WCSAXES =                    2 / no comment                                     
> CTYPE1  = 'RA---TAN-SIP' / TAN (gnomic) projection + SIP distortions            
> CTYPE2  = 'DEC--TAN-SIP' / TAN (gnomic) projection + SIP distortions            
> EQUINOX =               2000.0 / Equatorial coordinates definition (yr)         
> LONPOLE =                180.0 / no comment                                     
> LATPOLE =                  0.0 / no comment                                     
> CRVAL1  =        304.317023912 / RA  of reference point                         
> CRVAL2  =        45.3045531672 / DEC of reference point                         
> CRPIX1  =        4123.62069546 / X reference pixel                              
> CRPIX2  =        3118.81777021 / Y reference pixel                              
> CUNIT1  = 'deg     ' / X pixel scale units                                      
> CUNIT2  = 'deg     ' / Y pixel scale units                                      
> CD1_1   =    0.000187351090429 / Transformation matrix                          
> CD1_2   =    3.58456619667E-06 / no comment                                     
> CD2_1   =    3.68116182084E-06 / no comment                                     
> CD2_2   =   -0.000187399195345 / no comment                         
> ... many fits keywords ... 
> 
> 
> ** The problem is: how do I replace record array hdulist[1].data with another 
> array made from wcs[0].header or how to remove/update keywords in hdulist[1].data ? **
> 
> I am confused about the format of hdulist[1].data, is it some kind of record array ?
> 
> Thanks for your help, Kimmo Lehtinen
> 
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org <mailto:AstroPy at python.org>
> https://mail.python.org/mailman/listinfo/astropy <https://mail.python.org/mailman/listinfo/astropy>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20170613/7afa4100/attachment-0001.html>


More information about the AstroPy mailing list