[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[task #16192] Add the possibility of read/write vectors
From: |
Raul Infante-Sainz |
Subject: |
[task #16192] Add the possibility of read/write vectors |
Date: |
Tue, 17 May 2022 06:00:50 -0400 (EDT) |
Follow-up Comment #2, task #16192 (project gnuastro):
Thanks a lot Mohammad. This is the best way I found to make it easy to play
with: just a small Python code to generate two tables. It only needs Astropy
and will generate two fits tables.
- table-simple.fits: table containing 3 rows and 3 columns, single values.
- table-vector.fits: table containing 3 rows and 3 columns. The second column
is a vector with three elements (named as VECTOR).
I think the code is self-explanatory:
from astropy.table import Table
# Simple table with no multi-value column.
data_simple = [('row1', 1, 1),
('row2', 2, 2),
('row3', 3, 3)]
t_simple = Table(rows=data_simple, names=('A', 'B', 'C'))
t_simple.write('table-simple.fits', format='fits', overwrite=True)
# Vector-column table. Last column has multiple values (vector).
data_vector = [('row1', (11,12,13), 1),
('row2', (21,22,23), 1),
('row3', (31,32,33), 3)]
t_vector = Table(rows=data_vector, names=('A', 'VECTOR', 'C'))
t_vector.write('table-vector.fits', format='fits', overwrite=True)
Just save these lines as 'table.py', execute it and then open with Topcat. You
will see how they look like.
$ python3 table.py
$ astscript-fits-view table-simple.fits table-vector.fits
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/task/?16192>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/