Changeset 14356
- Timestamp:
- 03/17/2010 04:52:35 PM (6 months ago)
- Location:
- trunk/src/astrometry
- Files:
-
- 1 added
- 7 edited
-
blind/dynamic-index.py (added)
-
util/Makefile (modified) (1 diff)
-
util/healpix-utils.c (modified) (4 diffs)
-
util/healpix-utils.h (modified) (1 diff)
-
util/healpix.c (modified) (4 diffs)
-
util/healpix.h (modified) (2 diffs)
-
util/healpix.py (modified) (1 diff)
-
util/svn.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/astrometry/util/Makefile
r14341 r14356 176 176 $(CC) $(SHAREDLIBFLAGS) -o $@ $^ 177 177 178 _healpix.so: healpix .o permutedsort.o starutil.o mathutil.o errors.o bl.o log.o gnu-specific.o178 _healpix.so: healpix-utils.o healpix.o permutedsort.o starutil.o mathutil.o errors.o bl.o log.o gnu-specific.o 179 179 $(CC) $(SHAREDLIBFLAGS) -o $@ $^ 180 180 -
trunk/src/astrometry/util/healpix-utils.c
r13814 r14356 79 79 80 80 81 il* healpix_approx_rangesearch(double* xyz, double radius, int Nside, il* hps) {81 static il* hp_rangesearch(const double* xyz, double radius, int Nside, il* hps, bool approx) { 82 82 int hp; 83 83 double hprad = arcmin2dist(healpix_side_length_arcmin(Nside)) * sqrt(2); … … 96 96 nn = healpix_get_neighbours(hp, neighbours, Nside); 97 97 for (i=0; i<nn; i++) { 98 bool tst; 98 99 double nxyz[3]; 99 100 if (il_contains(frontier, neighbours[i])) … … 103 104 if (il_contains(hps, neighbours[i])) 104 105 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) { 107 113 // in range! 108 114 il_append(frontier, neighbours[i]); … … 118 124 return hps; 119 125 } 126 127 il* healpix_rangesearch_xyz_approx(const double* xyz, double radius, int Nside, il* hps) { 128 return hp_rangesearch(xyz, radius, Nside, hps, TRUE); 129 } 130 131 il* healpix_rangesearch_xyz(const double* xyz, double radius, int Nside, il* hps) { 132 return hp_rangesearch(xyz, radius, Nside, hps, FALSE); 133 } 134 135 il* 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 141 il* 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 23 23 24 24 /** 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. 26 26 */ 27 il* healpix_approx_rangesearch(double* xyz, double radius, int Nside, il* hps); 27 il* healpix_rangesearch_xyz(const double* xyz, double radius, int Nside, il* hps); 28 il* healpix_rangesearch_xyz_approx(const double* xyz, double radius, int Nside, il* hps); 29 il* healpix_rangesearch_radec_approx(double ra, double dec, double radius, int Nside, il* hps); 30 il* healpix_rangesearch_radec(double ra, double dec, double radius, int Nside, il* hps); 28 31 29 32 /** -
trunk/src/astrometry/util/healpix.c
r14248 r14356 994 994 } 995 995 996 int xyzarrtohealpix( double* xyz, int Nside) {996 int xyzarrtohealpix(const double* xyz, int Nside) { 997 997 return xyztohealpix(xyz[0], xyz[1], xyz[2], Nside); 998 998 } 999 999 1000 int64_t xyzarrtohealpixl( double* xyz, int Nside) {1000 int64_t xyzarrtohealpixl(const double* xyz, int Nside) { 1001 1001 return xyztohealpixl(xyz[0], xyz[1], xyz[2], Nside); 1002 1002 } 1003 1003 1004 int xyzarrtohealpixf( double* xyz,int Nside, double* p_dx, double* p_dy) {1004 int xyzarrtohealpixf(const double* xyz,int Nside, double* p_dx, double* p_dy) { 1005 1005 return xyztohealpixf(xyz[0], xyz[1], xyz[2], Nside, p_dx, p_dy); 1006 1006 } … … 1320 1320 } 1321 1321 1322 double healpix_distance_to_ radec(int hp, int Nside, double ra, double dec,1323 double* closestxyz) {1322 double healpix_distance_to_xyz(int hp, int Nside, const double* xyz, 1323 double* closestxyz) { 1324 1324 int thehp; 1325 double xyz[3];1326 1325 // corners 1327 1326 double cdx[4], cdy[4]; … … 1338 1337 1339 1338 // If the point is actually inside the healpix, dist = 0. 1340 thehp = radecdegtohealpix(ra, dec, Nside);1339 thehp = xyzarrtohealpix(xyz, Nside); 1341 1340 if (thehp == hp) { 1342 1341 if (closestxyz) 1343 radecdeg2xyzarr(ra, dec, closestxyz);1342 memcpy(closestxyz, xyz, 3*sizeof(double)); 1344 1343 return 0; 1345 1344 } 1346 1345 1347 1346 // Find two nearest corners. 1348 radecdeg2xyzarr(ra, dec, xyz);1349 1347 for (i=0; i<4; i++) { 1350 1348 double cxyz[3]; … … 1407 1405 } 1408 1406 1407 double 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 1409 1414 void healpix_radec_bounds(int hp, int nside, 1410 1415 double* p_ralo, double* p_rahi, -
trunk/src/astrometry/util/healpix.h
r14248 r14356 267 267 a healpix index. 268 268 */ 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);269 int xyzarrtohealpix(const double* xyz, int Nside); 270 271 int64_t xyzarrtohealpixl(const double* xyz, int Nside); 272 273 int xyzarrtohealpixf(const double* xyz,int Nside, double* p_dx, double* p_dy); 274 274 275 275 /** … … 362 362 363 363 /** 364 Returns the minimum distance (in degrees) between the given healpix 365 and the given xyz (point on unit sphere). 366 */ 367 double healpix_distance_to_xyz(int hp, int Nside, const double* xyz, 368 double* closestxyz); 369 370 /** 364 371 Computes the RA,Dec bounding-box of the given healpix. Results are 365 372 in degrees. RA may be wacky for healpixes spanning RA=0. -
trunk/src/astrometry/util/healpix.py
r14341 r14356 20 20 raise IOError('_healpix.so library not found') 21 21 22 22 def 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 34 def 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 23 41 24 42 def healpix_nside_for_side_length_arcmin(arcmin): -
trunk/src/astrometry/util/svn.c
r14351 r14356 139 139 // 140 140 // 141 // 142 // 143 // 144 //
Note: See TracChangeset
for help on using the changeset viewer.
