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

Unable to Plot COS Apertures #336

Open Witchblade101 opened 8 months ago

Witchblade101 commented 8 months ago

I get the following errors trying to plot any COS apertures:


import pysiaf
import matplotlib.pyplot as plt
# plot an HST COS aperture
siaf = pysiaf.Siaf('HST')
aperture_names = ['LFMAC']

plt.figure(figsize=(4, 4), facecolor='w', edgecolor='k')
for aperture_name in aperture_names:
    siaf[aperture_name].plot(color='r', fill_color='darksalmon', mark_ref=True)
ax = plt.gca()
ax.set_aspect('equal')
ax.invert_yaxis()
plt.show()

/Users/dlong/pysiaf/pysiaf/aperture.py:1401: SyntaxWarning: invalid escape sequence '\*'
  """Sky to Tel frame transformation. Requires an attitude matrix.
/Users/dlong/pysiaf/pysiaf/aperture.py:1401: SyntaxWarning: invalid escape sequence '\*'
  """Sky to Tel frame transformation. Requires an attitude matrix.

{
    "name": "UnboundLocalError",
    "message": "cannot access local variable 'corners' where it is not associated with a value",
    "stack": "---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[1], line 9
      7 plt.figure(figsize=(4, 4), facecolor='w', edgecolor='k')
      8 for aperture_name in aperture_names:
----> 9     siaf[aperture_name].plot(color='r', fill_color='darksalmon', mark_ref=True)
     10 ax = plt.gca()
     11 ax.set_aspect('equal')

File ~/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 ~/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"
}