INPUT TO QUAD CALCULATION: star-RA star-Dec star-Mag 1 1 1 1 1 1 1 1 1 1 1 1 OUTPUT OF QUAD CALCULATION (9 columns). MULTI-THREADED Steps: 1) NO HEALPIX(!) Just grid the range of RA/DEC in relative box sizes (5x5). 2) 5 brightest stars in each healpix (10 healpixes = 50 stars (max) = 50 quads (max)) -----muti-threaded----- 3) for each star, look in a circle the radius of the healpix. 3.1) find N, N-2, N-4 most distant stars within that circle. Also account for big difference in brightness (larger than error). 3.2) Calculate the quad hashes for that star. ----------------------- EXAMPLE Brightness component: (position of star A in sorted quad stars) 3 (position of star B in sorted quad stars) 2 (position of star C in sorted quad stars) 0 (brightest: lowest numerical magnitude value) (position of star D in sorted quad stars) 1 (next brightest) Through a 4*4 bit unsigned integer and bit-shifting. Cx Cy Dx Dy Rel-Bright star-A-index star-B-index star-C-index star-D-index (doule) (double) (double) (double) (uint16_t) (uint64_t) (uint64_t) (uint64_t) (uint64_t) 1 1 1 1 1 i i 1 1 1 1 1 i i 1 1 1 1 1 i i 1 1 1 1 1 i i INPUT TO KD-TREE: Cx, Cy, Dx, Dy OUTPUT OF KD-TREE (index in OUTPUT of QUAD CALCULATION) left right (size_t) (size_t) x x x x x x x x WHAT GETS WRITTEN TO A FILE: Cx, Cy, Dx, Dy, Rel-Bright, left, right, star-A-index, star-B-index, star-C-index, star-D-index ======================================= Matching with inidividual catalogs ======================================= 1) Load the necessary tables: 1) Reference catalog (RA, Dec, Mag) 2) kd-tree and quad tables (11 columns) 3) Catalog to-match (X, Y, Mag). 2) Find all quads in to-match catalog. Divide the full X,Y range in each dimension into N boxs (maybe 5x5). 3) Find all the quads and a match with the kd-tree (in parallel). 4) Now we know the (X,Y) ---> (RA,Dec) for random points in input catalog. 4.1) Fit a distortional model onto this tranformation. 4.2) And this will give us the WCS!