You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please make it possible to store Frame objects that do not have data in Astropy tables.
I am working on an Astropy-based observation planning and scheduling toolkit for space missions, primarily for tiled imaging observations with wide-field cameras. A natural way for my code to represent the fields to observe is as SkyOffsetICRS objects without any attached data: these objects represent the RA, Dec, and roll of the spacecraft for the observation.
I would like my code to be able to save the planned timeline of observations as a Table which has a column of type SkyOffsetICRS. However, I find that Astropy does not allow me to do this. Here's a minimal reproducer:
fromastropy.coordinatesimportSkyCoord, SkyOffsetFramefromastropy.tableimportTablefromastropyimportunitsasuimportnumpyasnpra= [1, 2, 3] *u.degde= [4, 5, 6] *u.degpa= [7, 8, 9] *u.deg# SkyOffsetFrame with dummy values is happy, but it's not what I want.dummy=np.zeros(3) *u.degframe_with_dummy_data=SkyOffsetFrame(
dummy, dummy, origin=SkyCoord(ra, de), rotation=pa)
Table({'frame': frame_with_dummy_data})
# SkyCoord with dummy values is happy, but it's not what I want either.dummy_coord_with_frame=SkyCoord(
dummy, dummy, frame=SkyOffsetFrame(origin=SkyCoord(ra, de), rotation=pa))
Table({'coord': dummy_coord_with_frame})
# This is what I want: a bare frame with no data. But the Table constructor# raises the following exception: `ValueError: The frame object# "<SkyOffsetICRS ...>" does not have associated data`frame=SkyOffsetFrame(origin=SkyCoord(ra, de), rotation=pa)
Table({'frame': frame})
Describe the desired outcome
Add support for adding Frame objects that do not have data as columns in tables.
Because my data is a series of many SkyOffsetFrames. Each planned observation is a row in the table, with a SkyOffsetFrame that represents the attitude of the telescope, a Time for the start of the observation, an exposure time, an integer to represent the observing mode, etc.
@lpsinger - I agree that should be possible. Looking at the traceback from what you actually want, a problem is that len(frame) does not work, but really it breaks down earlier: frame should be recognized as a mixin column, but isn't:
from astropy.table import QTable
qt = QTable()
qt._is_mixin_for_table(frame)
# False
And the reason for that is that SkyOffsetFrame does not have an info attribute. That seems a pure oversight. But oddly, the oversight actually starts with BaseCoordinateFrame not having info either. As a result,
from astropy.table import QTable
from astropy import units as u
from astropy.coordinates import ICRS
icrs = ICRS(np.arange(10.)*u.deg, np.arange(10.)*u.deg)
QTable({'icrs': icrs})
<QTable length=10>
icrs
object
-------------------------------------------------
<ICRS Coordinate: (ra, dec) in deg\n (0., 0.)>
<ICRS Coordinate: (ra, dec) in deg\n (1., 1.)>
<ICRS Coordinate: (ra, dec) in deg\n (2., 2.)>
<ICRS Coordinate: (ra, dec) in deg\n (3., 3.)>
<ICRS Coordinate: (ra, dec) in deg\n (4., 4.)>
<ICRS Coordinate: (ra, dec) in deg\n (5., 5.)>
<ICRS Coordinate: (ra, dec) in deg\n (6., 6.)>
<ICRS Coordinate: (ra, dec) in deg\n (7., 7.)>
<ICRS Coordinate: (ra, dec) in deg\n (8., 8.)>
<ICRS Coordinate: (ra, dec) in deg\n (9., 9.)>
This is clearly wrong: it should have been an ICRS column.
Activity
eerovaher commentedon Aug 13, 2024
Why does the
SkyOffsetFrameneed to be stored in a column? Is there some reason you can't store it in metadata?lpsinger commentedon Aug 14, 2024
Because my data is a series of many SkyOffsetFrames. Each planned observation is a row in the table, with a SkyOffsetFrame that represents the attitude of the telescope, a Time for the start of the observation, an exposure time, an integer to represent the observing mode, etc.
mhvk commentedon Aug 14, 2024
@lpsinger - I agree that should be possible. Looking at the traceback from what you actually want, a problem is that
len(frame)does not work, but really it breaks down earlier:frameshould be recognized as a mixin column, but isn't:And the reason for that is that
SkyOffsetFramedoes not have aninfoattribute. That seems a pure oversight. But oddly, the oversight actually starts withBaseCoordinateFramenot havinginfoeither. As a result,This is clearly wrong: it should have been an ICRS column.
mhvk commentedon Aug 14, 2024
A fix is in
#16381#16831 - was much more painful than I had hoped...lpsinger commentedon Aug 14, 2024
Do you mean #16831?
mhvk commentedon Aug 14, 2024
Indeed, silly, now corrected.