- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/relphot/src/select_images.c
r21508 r27839 13 13 } SkyRegionCoords; 14 14 15 Image *select_images (SkyList *skylist, Image *timage, int Ntimage, int **LineNumber, int *Nimage) { 15 void dsortindex (double *X, off_t *Y, int N); 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { 16 19 17 20 Image *image; 18 int i, j, k, m, found, nimage, NIMAGE; 19 int InRange, ecode; 21 off_t i, j, k, m, nStart, iSky, nimage, NIMAGE; 22 off_t *line_number; 23 int InRange, ecode, found; 20 24 double Ri[5], Di[5], Xi[5], Yi[5], dx, dy; 21 int *line_number;22 25 Coords tcoords; 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); … … 71 85 NIMAGE = 100; 72 86 ALLOCATE (image, Image, NIMAGE); 73 ALLOCATE (line_number, int, NIMAGE);87 ALLOCATE (line_number, off_t, NIMAGE); 74 88 75 89 // go through the complete list of images, selecting ones which overlap any region … … 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 */ … … 146 170 NIMAGE += 100; 147 171 REALLOCATE (image, Image, NIMAGE); 148 REALLOCATE (line_number, int, NIMAGE);172 REALLOCATE (line_number, off_t, NIMAGE); 149 173 } 150 174 } 151 175 } 152 176 153 if (VERBOSE) fprintf (stderr, "found % d images\n",nimage);177 if (VERBOSE) fprintf (stderr, "found %lld images\n", (long long) nimage); 154 178 155 179 REALLOCATE (image, Image, MAX (nimage, 1)); 156 REALLOCATE (line_number, int, MAX (nimage, 1));180 REALLOCATE (line_number, off_t, MAX (nimage, 1)); 157 181 free (skycoords); 158 182 … … 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.
