Skip to content

Support Quantity, Time, and Coordinates in Table objects #664

@astrofrog

Description

@astrofrog

This idea resulted from a discussion with @hamogu today - it would be nice to have the concept of columns in tables intelligently dealing with e.g. Quantity, Time, or Coordinate (once they support arrays) columns. For example, it would be nice to be able to do:

>>> t = Table()
>>> t.add_column(Column('obsdate', Time(np.array([1.,2.,3.]), scale='utc')))

and then t['obsdate] would seamlessly return a Time object. This could also work for coordinates (once they support arrays). Maybe this is too much magic, but I was trying to think of how one would actually store coordinates and times in tables in practice, and this seemed like it would make it very easy for users. Along the same lines, one could just store any arbitrary Quantity object:

>>> t.add_column(Column('d', np.array([1,2,3]) * u.m))
>>> t['d']
<Quantity [1 2 3] m>

with the unit being separated from the array and stored in the Column unit attribute until the data is accessed again. Of course, this raises the issue of whether in general, accessing a column or a cell should return the value, or a Quantity if units are present.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions