[AstroPy] Format of a FITS-LDAC file

Lehtinen Kimmo (MML) kimmo.lehtinen at nls.fi
Tue Jun 13 04:42:13 EDT 2017


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 import fits
>>> hdulist=fits.open('LDAC-template.fits')
>>> 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.
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


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


More information about the AstroPy mailing list