Changeset 14356


Ignore:
Timestamp:
03/17/2010 04:52:35 PM (6 months ago)
Author:
dstn
Message:

dynamic indexing script

Location:
trunk/src/astrometry
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/astrometry/util/Makefile

    r14341 r14356  
    176176        $(CC) $(SHAREDLIBFLAGS) -o $@ $^ 
    177177 
    178 _healpix.so: healpix.o permutedsort.o starutil.o mathutil.o errors.o bl.o log.o gnu-specific.o 
     178_healpix.so: healpix-utils.o healpix.o permutedsort.o starutil.o mathutil.o errors.o bl.o log.o gnu-specific.o 
    179179        $(CC) $(SHAREDLIBFLAGS) -o $@ $^ 
    180180 
  • trunk/src/astrometry/util/healpix-utils.c

    r13814 r14356  
    7979 
    8080 
    81 il* healpix_approx_rangesearch(double* xyz, double radius, int Nside, il* hps) { 
     81static il* hp_rangesearch(const double* xyz, double radius, int Nside, il* hps, bool approx) { 
    8282        int hp; 
    8383        double hprad = arcmin2dist(healpix_side_length_arcmin(Nside)) * sqrt(2); 
     
    9696                nn = healpix_get_neighbours(hp, neighbours, Nside); 
    9797                for (i=0; i<nn; i++) { 
     98                        bool tst; 
    9899                        double nxyz[3]; 
    99100                        if (il_contains(frontier, neighbours[i])) 
     
    103104                        if (il_contains(hps, neighbours[i])) 
    104105                                continue; 
    105                         healpix_to_xyzarr(neighbours[i], Nside, 0.5, 0.5, nxyz); 
    106                         if (sqrt(distsq(xyz, nxyz, 3)) - hprad < radius) { 
     106                        if (approx) { 
     107                                healpix_to_xyzarr(neighbours[i], Nside, 0.5, 0.5, nxyz); 
     108                                tst = (sqrt(distsq(xyz, nxyz, 3)) - hprad <= radius); 
     109                        } else { 
     110                                tst = (healpix_distance_to_xyz(neighbours[i], Nside, xyz, NULL) <= radius); 
     111                        } 
     112                        if (tst) { 
    107113                                // in range! 
    108114                                il_append(frontier, neighbours[i]); 
     
    118124        return hps; 
    119125} 
     126 
     127il* healpix_rangesearch_xyz_approx(const double* xyz, double radius, int Nside, il* hps) { 
     128        return hp_rangesearch(xyz, radius, Nside, hps, TRUE); 
     129} 
     130 
     131il* healpix_rangesearch_xyz(const double* xyz, double radius, int Nside, il* hps) { 
     132        return hp_rangesearch(xyz, radius, Nside, hps, FALSE); 
     133} 
     134 
     135il* healpix_rangesearch_radec_approx(double ra, double dec, double radius, int Nside, il* hps) { 
     136        double xyz[3]; 
     137        radecdeg2xyzarr(ra, dec, xyz); 
     138        return hp_rangesearch(xyz, radius, Nside, hps, TRUE); 
     139} 
     140 
     141il* healpix_rangesearch_radec(double ra, double dec, double radius, int Nside, il* hps) { 
     142        double xyz[3]; 
     143        radecdeg2xyzarr(ra, dec, xyz); 
     144        return hp_rangesearch(xyz, radius, Nside, hps, FALSE); 
     145} 
  • trunk/src/astrometry/util/healpix-utils.h

    r13807 r14356  
    2323 
    2424/** 
    25  Returns healpixes that may be within range of the given point. 
     25 Returns healpixes that are / may be within range of the given point, resp. 
    2626 */ 
    27 il* healpix_approx_rangesearch(double* xyz, double radius, int Nside, il* hps); 
     27il* healpix_rangesearch_xyz(const double* xyz, double radius, int Nside, il* hps); 
     28il* healpix_rangesearch_xyz_approx(const double* xyz, double radius, int Nside, il* hps); 
     29il* healpix_rangesearch_radec_approx(double ra, double dec, double radius, int Nside, il* hps); 
     30il* healpix_rangesearch_radec(double ra, double dec, double radius, int Nside, il* hps); 
    2831 
    2932/** 
  • trunk/src/astrometry/util/healpix.c

    r14248 r14356  
    994994} 
    995995 
    996 int xyzarrtohealpix(double* xyz, int Nside) { 
     996int xyzarrtohealpix(const double* xyz, int Nside) { 
    997997        return xyztohealpix(xyz[0], xyz[1], xyz[2], Nside); 
    998998} 
    999999 
    1000 int64_t xyzarrtohealpixl(double* xyz, int Nside) { 
     1000int64_t xyzarrtohealpixl(const double* xyz, int Nside) { 
    10011001        return xyztohealpixl(xyz[0], xyz[1], xyz[2], Nside); 
    10021002} 
    10031003 
    1004 int xyzarrtohealpixf(double* xyz,int Nside, double* p_dx, double* p_dy) { 
     1004int xyzarrtohealpixf(const double* xyz,int Nside, double* p_dx, double* p_dy) { 
    10051005    return xyztohealpixf(xyz[0], xyz[1], xyz[2], Nside, p_dx, p_dy); 
    10061006} 
     
    13201320} 
    13211321 
    1322 double healpix_distance_to_radec(int hp, int Nside, double ra, double dec, 
    1323                                                                 double* closestxyz) { 
     1322double healpix_distance_to_xyz(int hp, int Nside, const double* xyz, 
     1323                                                          double* closestxyz) { 
    13241324        int thehp; 
    1325         double xyz[3]; 
    13261325        // corners 
    13271326        double cdx[4], cdy[4]; 
     
    13381337 
    13391338        // If the point is actually inside the healpix, dist = 0. 
    1340         thehp = radecdegtohealpix(ra, dec, Nside); 
     1339        thehp = xyzarrtohealpix(xyz, Nside); 
    13411340        if (thehp == hp) { 
    13421341                if (closestxyz) 
    1343                         radecdeg2xyzarr(ra, dec, closestxyz); 
     1342                        memcpy(closestxyz, xyz, 3*sizeof(double)); 
    13441343                return 0; 
    13451344        } 
    13461345 
    13471346        // Find two nearest corners. 
    1348         radecdeg2xyzarr(ra, dec, xyz); 
    13491347        for (i=0; i<4; i++) { 
    13501348                double cxyz[3]; 
     
    14071405} 
    14081406 
     1407double healpix_distance_to_radec(int hp, int Nside, double ra, double dec, 
     1408                                                                 double* closestxyz) { 
     1409        double xyz[3]; 
     1410        radecdeg2xyzarr(ra, dec, xyz); 
     1411        return healpix_distance_to_xyz(hp, Nside, xyz, closestxyz); 
     1412} 
     1413 
    14091414void healpix_radec_bounds(int hp, int nside, 
    14101415                                                  double* p_ralo, double* p_rahi, 
  • trunk/src/astrometry/util/healpix.h

    r14248 r14356  
    267267   a healpix index. 
    268268*/ 
    269 int xyzarrtohealpix(double* xyz, int Nside); 
    270  
    271 int64_t xyzarrtohealpixl(double* xyz, int Nside); 
    272  
    273 int xyzarrtohealpixf(double* xyz,int Nside, double* p_dx, double* p_dy); 
     269int xyzarrtohealpix(const double* xyz, int Nside); 
     270 
     271int64_t xyzarrtohealpixl(const double* xyz, int Nside); 
     272 
     273int xyzarrtohealpixf(const double* xyz,int Nside, double* p_dx, double* p_dy); 
    274274 
    275275/** 
     
    362362 
    363363/** 
     364 Returns the minimum distance (in degrees) between the given healpix 
     365 and the given xyz (point on unit sphere). 
     366 */ 
     367double healpix_distance_to_xyz(int hp, int Nside, const double* xyz, 
     368                                                           double* closestxyz); 
     369 
     370/** 
    364371 Computes the RA,Dec bounding-box of the given healpix.  Results are 
    365372 in degrees.  RA may be wacky for healpixes spanning RA=0. 
  • trunk/src/astrometry/util/healpix.py

    r14341 r14356  
    2020        raise IOError('_healpix.so library not found') 
    2121 
    22  
     22def il_to_list(il): 
     23        _lib.il_size.argtypes = [c_void_p] 
     24        _lib.il_size.restype = c_int 
     25        _lib.il_get.argtypes = [c_void_p, c_int] 
     26        _lib.il_get.restype = c_int 
     27        N = _lib.il_size(il) 
     28        lst = [] 
     29        for i in range(N): 
     30                x = _lib.il_get(il, c_int(i)) 
     31                lst.append(int(x)) 
     32        return lst 
     33 
     34def healpix_rangesearch(ra, dec, radius, nside): 
     35        _lib.healpix_rangesearch_radec.restype = c_void_p 
     36        hplist = _lib.healpix_rangesearch_radec(c_double(ra), c_double(dec), c_double(radius), c_int(nside), c_void_p(None)) 
     37        lst = il_to_list(hplist) 
     38        _lib.il_free.argtypes = [c_void_p] 
     39        _lib.il_free(hplist) 
     40        return lst 
    2341 
    2442def healpix_nside_for_side_length_arcmin(arcmin): 
  • trunk/src/astrometry/util/svn.c

    r14351 r14356  
    139139// 
    140140// 
     141// 
     142// 
     143// 
     144// 
Note: See TracChangeset for help on using the changeset viewer.