spacetelescope/pysiaf

convert method fails for HST apertures

Russell-Ryan opened this issue · 9 comments

I was trying to convert coordinates for the HST apertures, and pysiaf fails. This is what I did:

import pysiaf
hst=pysiaf.Siaf('HST')
uvis1=hst['IUVIS1']
uvis1.convert(1,1,'sci','det')

The traceback is very long, but the last stanza gives:

~/miniconda3/envs/astroconda37/lib/python3.7/site-packages/pysiaf/aperture.py in linear_transform_model(from_system, to_system, parity, angle_deg)
   2017     if type(angle_deg) not in [int, float, np.float64, np.int64]:
   2018         raise TypeError('Angle has to be a float. It is of type {} and has the value {}'.format(
-> 2019             type(angle_deg), angle_deg))
   2020 
   2021     # check for allowed system pairs

TypeError: Angle has to be a float. It is of type <class 'NoneType'> and has the value None

This is running:
pysiaf.version
'0.7.1'

I did this with the JWST apertures, and things seemed to work. Any advice here? Is this a issue with the HST reference files?

This is a missing functionality. In all my HST use cases so far I worked with Science pixels and did not convert to Detector pixels.

One would have to find out what the HST equivalent of DetSciAngle is and add it to _hst_to_jwst_keys in aperture.py. (This is also what the error refers to.)

I suggest to consult with @ColinRCox

In the HST SIAF we did not really have any connection with the detector layout. We always worked with a set of image pixels which correspond to the displayed images. Unless anything else is known I would assume these frames are aligned with the detector. The DetSciAngle is the angle between the detector Y axis and the Science (or for HST the iraf) frame Y axis. For JWST this is almost always zero. We have a couple of cases where it is 180 degrees. I would assume for HST you can always assume zero.

You could try to insert

uvis1.DetSciParity = 1     
uvis1.DetSciYAngle = 0. 

before the call to .convert

I ran into this same issue.

I had to do the following to get det_to_tel to work:

uvis1.DetSciParity = 1
uvis1.DetSciYAngle = 0.
uvis1.XDetRef = uvis1.XSciRef
uvis1.YDetRef = uvis1.YSciRef