mommermi / photometrypipeline

automated photometry pipeline for small to medium-sized observatories
GNU General Public License v3.0
62 stars 26 forks source link

header keyword values are strings. #16

Closed boada closed 7 years ago

boada commented 7 years ago

I don't know if this is an issue with PP or with SCAMP. After the pipeline has completed and all of the header keywords have been updated, the values are often given as strings. For example:

PV1_0 = '-6.07203233558e-06' / / Projection distortion parameter

PV1_1 = '1.00009356016' / / Projection distortion parameter
PV1_2 = '0.000109062147791' / / Projection distortion parameter
PV1_4 = '-0.000165347506398' / / Projection distortion parameter
PV1_5 = '0.00059124044575' / / Projection distortion parameter
PV1_6 = '-0.000106843007282' / / Projection distortion parameter
PV2_0 = '-3.9237160343e-05' / / Projection distortion parameter
PV2_1 = '1.00004779852' / / Projection distortion parameter
PV2_2 = '-0.000114143177142' / / Projection distortion parameter
PV2_4 = '0.00091173019759' / / Projection distortion parameter
PV2_5 = '-0.000173258009464' / / Projection distortion parameter
PV2_6 = '0.000342091928913' / / Projection distortion parameter

If you wanna do something like run Sextractor on the image with everything all updated, it works fine. However, Sextractor gives the coordinates of the objects in X_IMAGE and Y_IMAGE so you'll need to convert those into RA and DEC using the WCS of the image.

Ok. So you fire up astropy and get a copy of the header/WCS information, but because the values of the keywords are strings and not floating point numbers astropy doesn't know what to do and the conversion from X_IMAGE to RA fails. This is probably something that should be changed in astropy, but if it is an easy fix in PP then we could do that too.

I'm not sure where the header keywords are getting written by PP or if the problem is really something with SCAMP and I'll need to write a work around.

boada commented 7 years ago

I wrote a work around to get everything converted to the right type. Now the problem is that SCAMP adds a bunch of non standard keywords to the FITS header. This causes problems when trying to read one of the calibrated images with something like astropy.

https://github.com/astropy/astropy/issues/3559

mommermi commented 7 years ago

Sorry for being late on this. I use something similar already in diagnostics.py and it seems to work as a workaround:

        # turn relevant header keys into floats
        # astropy.io.fits bug
        for key, val in list(header.items()):
            if 'CD1_' in key or 'CD2_' in key or \
               'CRVAL' in key or 'CRPIX' in key or \
               'EQUINOX' in key:
                header[key] = float(val)

On the converted header I can then apply astropy.wcs functions.

boada commented 7 years ago

What are you doing with the SCAMP header keywords? Because it sounds like they aren't supported by astropy.

https://mail.scipy.org/pipermail/astropy/2014-April/003156.html

mommermi commented 7 years ago

Nothing specifically. astropy might simply ignore them, but I've never had problems with them...

boada commented 7 years ago

Hmmm. Ok. Seems ok to me.