spacetelescope / pysiaf

Handling of Science Instrument Aperture Files (SIAF) for space telescopes
https://pysiaf.readthedocs.io
BSD 3-Clause "New" or "Revised" License
13 stars 28 forks source link

plot function doesn't work for circular apertures #343

Open mperrin opened 2 months ago

mperrin commented 2 months ago

Some HST apertures are defined as circles. The Aperture.plot function doesn't know what to do with these:

cos_aperture = pysiaf.Siaf('hst').apertures['LNPSA']
cos_aperture.plot()

yields:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[8], line 3
      1 cos_aperture = pysiaf.Siaf('hst').apertures['LNPSA']
----> 3 cos_aperture.plot()

File ~/Dropbox (Personal)/Documents/software/git/pysiaf/pysiaf/aperture.py:666, in Aperture.plot(self, frame, label, ax, title, units, show_frame_origin, mark_ref, fill, fill_color, fill_alpha, label_rotation, **kwargs)
    663     ax.set_xlabel('X pixels ({0})'.format(frame))
    664     ax.set_ylabel('Y pixels ({0})'.format(frame))
--> 666 x, y = self.corners(frame, rederive=False)
    667 x2, y2 = self.closed_polygon_points(frame, rederive=False)
    669 if units.lower() == 'arcsec':

File ~/Dropbox (Personal)/Documents/software/git/pysiaf/pysiaf/aperture.py:1792, in HstAperture.corners(self, to_frame, rederive)
   1789     y_Idl = np.array([self.v1y, self.v2y, self.v3y, self.v4y])
   1790     corners = SiafCoordinates(x_Idl, y_Idl, 'idl')
-> 1792 return self.convert(corners.x, corners.y, corners.frame, to_frame)

UnboundLocalError: cannot access local variable 'corners' where it is not associated with a value
mperrin commented 2 months ago

Oh I just realized this is a duplicate of #336 reported by @Witchblade101