Storing arrays within arrays

8 views
Skip to first unread message

Branimir Sesar

unread,
Sep 6, 2012, 5:09:00 PM9/6/12
to lsd-...@googlegroups.com
Dear LSD users,

I would like to store a few arrays within an LSD table. I know I can
use, e.g., '4f4' when defining a table to define an array with 4
elements, but what if I want to have another four 10-element arrays
within an array? Something like,

[[0,1,2,3,4,..,9], [0,1,2,3...,9], [0,1,2,3...,9], [0,1,2,3...,9]]

B

Eric Morganson

unread,
Sep 6, 2012, 5:23:57 PM9/6/12
to lsd-...@googlegroups.com
From the command prompt, the syntax is:
l
sd-admin --db /a41217d5/morganson/LSD/ create table --comp blosc
--comp-level 5 --primary-key obj_id --spatial-keys ra,dec blah
obj_id:u8 ra:f8 dec:f8 median:5f8 err:5f8 nmag_ok:5i2
'lc_mags:(5,10)f4'

The last field 'lc_mags:(5,10)f4' is a 2D array.


In python, you do something like this:
out = colgroup.ColGroup(
dtype=[
('obj_id', 'u8'),
('ra', 'f8'), ('dec', 'f8'),
('median_ap', '5f4'), ('q25_ap', '5f4'),
('q75_ap', '5f4'),
('lc_mag', '(5,10)f4'), ('lc_err',
'(5,10)f4'), ('lc_mjd', '(5,10)f8'),
],
size=len(objs)
)

'f8' is just a float
'5f4' is an array of 5 floats
'(5,10)f4' is a 2d array

You then can fill up that array how you like and the write out with
something like:
result = qwriter.write(qresult.static_cell, out)

That python stuff will only make sense if you have something like that
already written.

-E
--
Dr. Eric Morganson
Max Planck Institut für Astronomie
Königstuhl 17
D-69117 Heidelberg
Germany

Branimir Sesar

unread,
Sep 7, 2012, 2:59:00 PM9/7/12
to lsd-...@googlegroups.com
This is exactly what I need. Thanks, Eric! :)

Brani
Reply all
Reply to author
Forward
0 new messages