-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Starting with the documented way of making a table:
from astropy.table import Table
from astropy.time import Time
from astropy.coordinates import SkyCoord
tm = Time(['2000:002', '2002:345'])
sc = SkyCoord([10, 20], [-45, +40], unit='deg')
t = Table([tm, sc], names=['time', 'skycoord'])
print(t)
gives
time skycoord
deg,deg
--------------------- ----------
2000:002:00:00:00.000 10.0,-45.0
2002:345:00:00:00.000 20.0,40.0
But if I try to add another row:
# Add another row
t.add_row((Time('2017:001'),sc[0]))
I get
ValueError: Unable to insert row because of exception in column 'time':
'Time' object has no attribute 'insert'
Trying different things:
t = Table([[tm[0]],[sc[0]]], names=['time', 'skycoord'])
t.add_row([tm[1],sc[1]])
works giving:
time skycoord
--------------------- ----------------------------------------------------
2000:002:00:00:00.000 <SkyCoord (ICRS): (ra, dec) in deg
( 10., -45.)>
2002:345:00:00:00.000 <SkyCoord (ICRS): (ra, dec) in deg
( 20., 40.)>
So if you use astropy array objects, you can't add rows. But if you use scalar values, you can add rows and later extract the values as a list .
Reactions are currently unavailable