Changeset 27480 for trunk/Ohana/src/relphot/src/select_images.c
- Timestamp:
- Mar 26, 2010, 1:54:17 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/relphot/src/select_images.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/src/select_images.c
r27435 r27480 13 13 } SkyRegionCoords; 14 14 15 void dsortindex (double *X, off_t *Y, int N); 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 15 18 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { 16 19 17 20 Image *image; 18 off_t i, j, k, m ;19 off_t *line_number , nimage, NIMAGE;21 off_t i, j, k, m, nStart, iSky, nimage, NIMAGE; 22 off_t *line_number; 20 23 int InRange, ecode, found; 21 24 double Ri[5], Di[5], Xi[5], Yi[5], dx, dy; … … 23 26 SkyRegionCoords *skycoords; 24 27 28 double *RmaxSky; 29 off_t *index; 30 25 31 if (skylist[0].Nregions < 1) { 26 32 *Nimage = 0; … … 38 44 39 45 ALLOCATE (skycoords, SkyRegionCoords, skylist[0].Nregions); 46 47 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 48 ALLOCATE (index, off_t, skylist[0].Nregions); 40 49 41 50 /* compare with each region file */ … … 56 65 skycoords[i].Yc[4] = skycoords[i].Yc[0]; 57 66 67 RmaxSky[i] = skylist[0].regions[i][0].Rmax; 68 index[i] = i; 69 58 70 dx = 0.02*(skycoords[i].Xc[2] - skycoords[i].Xc[0]); 59 71 dy = 0.02*(skycoords[i].Yc[2] - skycoords[i].Yc[0]); … … 65 77 } 66 78 79 dsortindex (RmaxSky, index, skylist[0].Nregions); 80 67 81 if (VERBOSE) fprintf (stderr, "finding images\n"); 68 82 BuildChipMatch (timage, Ntimage); … … 86 100 } 87 101 88 if (!FindMosaicForImage (timage, Ntimage, i)) continue; 102 if (!FindMosaicForImage (timage, Ntimage, i)) { 103 fprintf (stderr, "cannot find mosaic for %lld\n", (long long) i); 104 continue; 105 } 89 106 90 107 /* define image corners */ … … 96 113 found = FALSE; 97 114 98 /* transform to ra,dec */ 115 /* transform corners to ra,dec */ 116 double RminImage = 360.0; 99 117 for (j = 0; j < 5; j++) { 100 118 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 101 } 119 RminImage = MIN(RminImage, Ri[j]); 120 } 121 122 // RA(nStart) is guaranteed to be < RminImage: 123 nStart = getRegionStartByRA (RminImage, RmaxSky, skylist[0].Nregions); 102 124 103 125 /* compare with each region file */ 104 for (m = 0; (m < skylist[0].Nregions) && !found; m++) { 126 for (iSky = 0; (iSky < skylist[0].Nregions) && !found; iSky++) { 127 128 m = index[iSky]; 105 129 106 130 /* we make positional comparisons in the projection of catalog */ … … 238 262 } 239 263 264 void dsortindex (double *X, off_t *Y, int N) { 265 266 # define SWAPFUNC(A,B){ double tmpf; off_t tmpi; \ 267 tmpf = X[A]; X[A] = X[B]; X[B] = tmpf; \ 268 tmpi = Y[A]; Y[A] = Y[B]; Y[B] = tmpi; \ 269 } 270 # define COMPARE(A,B)(X[A] < X[B]) 271 272 OHANA_SORT (N, COMPARE, SWAPFUNC); 273 274 # undef SWAPFUNC 275 # undef COMPARE 276 277 } 278 279 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions) { 280 281 // use bisection to find the overlapping mosaic 282 283 off_t Nlo, Nhi, N; 284 285 // find the last mosaic before start 286 Nlo = 0; Nhi = Nregions; 287 while (Nhi - Nlo > 10) { 288 N = 0.5*(Nlo + Nhi); 289 if (Rref[N] < R) { 290 Nlo = MAX(N, 0); 291 } else { 292 Nhi = MIN(N, Nregions); 293 } 294 } 295 return (Nlo); 296 }
Note:
See TracChangeset
for help on using the changeset viewer.
