Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple...

18
Markus Nullmeier Zentrum für Astronomie der Universität Heidelberg Astronomisches Rechen-Institut [email protected] Versatile access to HEALPix-based sky region objects within PostgreSQL data bases with PgSphere

Transcript of Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple...

Page 1: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Markus Nullmeier

Zentrum für Astronomie der Universität HeidelbergAstronomisches Rechen­Institut

[email protected]

Versatile access toHEALPix­based sky region objects

within PostgreSQL data bases with PgSphere

Page 2: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Markus Nullmeier

Zentrum für Astronomie der Universität HeidelbergAstronomisches Rechen­Institut

[email protected]

● Overview: retrieving spherical objects with pgSphere

● Requirements for sky region objects and their implementation

Versatile access toHEALPix­based sky region objects

within PostgreSQL data bases with PgSphere

Page 3: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● PostgreSQL“The world's most advanced  open source database”

● Store and retrievedata living on thecelestial sphere

● PostgreSQL extension:SQL data types, functions, indexes

About PgSphere

Page 4: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

                 

● Spherical points (RA, DEC)

● Spherical lines

● Spherical paths

● Spherical polygons

● Spherical circles

● Spherical ellipses

● Spherical coordinate ranges

● Spherical transformations (rotations)

PgSphere: spherical data types        

Page 5: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

psql=# create extension pg_sphere;

psql=# create table my_table (name varchar, ra_dec spoint); psql=# insert into my_table values ('Aldebaran', '(4h 35m 55.24s, +16d 30m 33.49s)');psql=# insert into my_table values ('Betelgeuse', '(5h 55m 10.31s, +7d 24m 25.43s)');psql=# insert into my_table values ('Antares', '(16h 29m 24.46s, -26d 25m 55.21s)');

psql=# select length(spath(ra_dec)) from my_table; length ------------------ 3.02828754

psql=# select * from my_table where ra_dec <@ scircle '<(80d, 10d), 15d>';

name | ra_dec ------------+--------------------------- Aldebaran | (68.98017d , 16.5093d) Betelgeuse | (88.79296d , 7.407064d)

Pgsphere demonstration

Page 6: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

psql=# create extension pg_sphere;

psql=# create table my_table (name varchar, ra_dec spoint); psql=# insert into my_table values ('Aldebaran', '(4h 35m 55.24s, +16d 30m 33.49s)');psql=# insert into my_table values ('Betelgeuse', '(5h 55m 10.31s, +7d 24m 25.43s)');psql=# insert into my_table values ('Antares', '(16h 29m 24.46s, -26d 25m 55.21s)');

psql=# select length(spath(ra_dec)) from my_table; length ------------------ 3.02828754

psql=# select * from my_table where ra_dec <@ scircle '<(80d, 10d), 15d>';

name | ra_dec ------------+--------------------------- Aldebaran | (68.98017d , 16.5093d) Betelgeuse | (88.79296d , 7.407064d)

Pgsphere demonstration

utility functions

cone search— accerleated by indexes

Page 7: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Pgsphere internals

R­treeR1

R3

R4

R9

R11

R13

R10

R12

R16

R15

R14R8

R2

R6

R7

R17

R18

R19

R5

R1 R2

R3 R4 R5 R6 R7

R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19

Page 8: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Pgsphere internals

R­treeR1

R3

R4

R9

R11

R13

R10

R12

R16

R15

R14R8

R2

R6

R7

R17

R18

R19

R5

R1 R2

R3 R4 R5 R6 R7

R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19

 •

Page 9: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Pgsphere development history

Janko Richter

Teodor Sigaev Oleg Bartunov

Igor Chilingarian

Page 10: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Pgsphere development today

 Dmitry Ivanov

  Alexander Korotkov

Markus Nullmeier

contributors: Pat Dowler, Serge Monkewitz

http://pgsphere.github.io

Page 11: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Based on HEALPix

● Start with 12 diamonds

● Subdivide by fours

Requirements for sky region objects (I)

Page 12: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

F

MOC = Multi­order coverage   (HEALPix Multi­Order Coverage map)

● Concise mapping of a catalog's coverage of the sphere

 

● MOC is an IVOA standard

Requirements for sky region objects (II)

Page 13: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Utility functions / operators for, e. g., contains queries

● Fast access to objects spanning multiple PostgreSQL pages:– internally store a sky region object as a (read­only) B­tree

● Efficient representation of multiple HEALPix levels asintervals on the finest level

● Create sky region object from table columns or queries

● Indexes for columns of sky region objects

Requirements for sky region objects (III)

Page 14: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

Indexing: R­trees fail for for large objectsR1

R3

R4

R9

R11

R13

R10

R12

R16

R15

R14R8

R2

R6

R7

R17

R18

R19

R5

R1 R2

R3 R4 R5 R6 R7

R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19

Page 15: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Comes down to well­known set indexing problem

● Set elements are intervals of HEALPix numbers

● Most basic set indexing technique: “inverted files”

● Use modified B­tree index, customised from a loadable indexing module for PostgreSQL 9.6+ (https://github.com/postgrespro/rum)

Sky region indexing (I)

Page 16: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Internal logic of indexing with an “inverted file” stucture:

● Accelerated operations:                                       containment, union, cross section, ...

Sky region indexing (II)

sorted intervals of HEALPix numbers

Sets of “pointers” tosky region objects

interval0 { obj7, obj11 }

interval1 { obj2, obj108, obj109 }

interval2 { obj108, obj732, obj11030 }

... ...

Page 17: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Create the sky coverage of a given database table “my_cat”:

SELECT smoc(my_cat.ra_dec, level = 15) FROM my_cat ;

● Search all catalogs that fully contain the sky region of auser­specified MOC region:

SELECT name FROM catalogs                                     WHERE my_moc <@ catalogs.moc ;

Use cases for sky region objects

Page 18: Versatile access to HEALPixbased sky region objects ... · Fast access to objects spanning multiple PostgreSQL pages: – internally store a sky region object as a (readonly) Btree

● Send in feature requests● Soon, download the code from https://github.com/mnullmei/ivoa_moc

● Send in bug reports● Send in test cases● Send in patches

Interested? Your involvement: