- Timestamp:
- Jan 31, 2011, 2:47:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/Ohana/src/relphot/src/select_images.c
r29001 r30443 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \ 19 float dtime; \ 20 gettimeofday (&stop, (void *) NULL); \ 21 dtime = DTIME (stop, start); \ 22 fprintf (stderr, MSG, __VA_ARGS__); } 17 23 18 24 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { … … 25 31 Coords tcoords; 26 32 SkyRegionCoords *skycoords; 27 33 struct timeval start, stop; 34 35 double RmaxSkyRegion, RminSkyRegion, DminSkyRegion, DmaxSkyRegion; 36 28 37 double *RmaxSky; 29 38 off_t *index; … … 35 44 return NULL; 36 45 } 46 47 gettimeofday (&start, (void *) NULL); 37 48 38 49 // the comparison is made in the catalog local projection. below we set crval1,2 … … 47 58 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 48 59 ALLOCATE (index, off_t, skylist[0].Nregions); 60 61 RminSkyRegion = +360.0; 62 RmaxSkyRegion = -360.0; 63 DminSkyRegion = +90.0; 64 DmaxSkyRegion = -90.0; 49 65 50 66 /* compare with each region file */ … … 75 91 skycoords[i].Xc[3] -= dx; skycoords[i].Yc[3] += dy; 76 92 skycoords[i].Xc[4] -= dx; skycoords[i].Yc[4] -= dy; 77 } 93 94 RminSkyRegion = MIN(RminSkyRegion, skylist[0].regions[i][0].Rmin); 95 RmaxSkyRegion = MAX(RmaxSkyRegion, skylist[0].regions[i][0].Rmax); 96 DminSkyRegion = MIN(DminSkyRegion, skylist[0].regions[i][0].Dmin); 97 DmaxSkyRegion = MAX(DmaxSkyRegion, skylist[0].regions[i][0].Dmax); 98 } 99 MARKTIME("create sky region coords: %f sec\n", dtime); 78 100 79 101 dsortindex (RmaxSky, index, skylist[0].Nregions); 102 MARKTIME("sort sky coords: %f sec\n", dtime); 80 103 81 104 if (VERBOSE) fprintf (stderr, "finding images\n"); 82 105 BuildChipMatch (timage, Ntimage); 106 MARKTIME("build chip match: %f sec\n", dtime); 83 107 84 108 nimage = 0; … … 100 124 } 101 125 126 // this adds 1.3 sec for 3M images 102 127 if (!FindMosaicForImage (timage, Ntimage, i)) { 103 128 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); … … 113 138 found = FALSE; 114 139 115 /* transform corners to ra,dec */140 /* transform corners to ra,dec -- costs ~3sec for 3M images */ 116 141 double RminImage = 360.0; 142 double RmaxImage = 0.0; 143 double DminImage = +90.0; 144 double DmaxImage = -90.0; 117 145 for (j = 0; j < 5; j++) { 118 146 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 119 147 RminImage = MIN(RminImage, Ri[j]); 120 } 121 122 // RA(nStart) is guaranteed to be < RminImage: 148 RmaxImage = MAX(RmaxImage, Ri[j]); 149 DminImage = MIN(DminImage, Di[j]); 150 DmaxImage = MAX(DmaxImage, Di[j]); 151 } 152 if (RmaxImage - RminImage > 180.0) { 153 double tmp = RminImage; 154 RmaxImage = RminImage; 155 RminImage = tmp - 360.0; 156 } 157 158 // check that this image is even in range of the searched region 159 if (DminImage > DmaxSkyRegion) continue; 160 if (DmaxImage < DminSkyRegion) continue; 161 162 // the sky region RA is defined to be 0 - 360.0 163 if (RminImage > RmaxSkyRegion) continue; 164 if (RmaxImage < RminSkyRegion) continue; 165 166 // RA(nStart) is guaranteed to be < RminImage: -- costs 0.5sec for 3M images 123 167 nStart = getRegionStartByRA (RminImage, RmaxSky, skylist[0].Nregions); 124 168 125 169 /* compare with each region file */ 126 for (iSky = 0; (iSky < skylist[0].Nregions) && !found; iSky++) {170 for (iSky = nStart; (iSky < skylist[0].Nregions) && !found; iSky++) { 127 171 128 172 m = index[iSky]; … … 174 218 } 175 219 } 176 220 MARKTIME("finish image selection: %f sec\n", dtime); 221 177 222 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); 178 223 … … 295 340 return (Nlo); 296 341 } 342 343 off_t getRegionStopByRA (double R, double *Rref, off_t Nregions) { 344 345 // use bisection to find the overlapping mosaic 346 347 off_t Nlo, Nhi, N; 348 349 // find the last mosaic before start 350 Nlo = 0; Nhi = Nregions; 351 while (Nhi - Nlo > 10) { 352 N = 0.5*(Nlo + Nhi); 353 if (Rref[N] < R) { 354 Nlo = MAX(N, 0); 355 } else { 356 Nhi = MIN(N, Nregions); 357 } 358 } 359 return (Nlo); 360 }
Note:
See TracChangeset
for help on using the changeset viewer.
