Changeset 30474
- Timestamp:
- Feb 3, 2011, 9:21:49 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/Ohana/src/relastro/src/select_images.c
r29001 r30474 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; … … 40 49 return NULL; 41 50 } 51 52 gettimeofday (&start, (void *) NULL); 42 53 43 54 // the comparison is made in the catalog local projection. below we set crval1,2 … … 52 63 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 53 64 ALLOCATE (index, off_t, skylist[0].Nregions); 65 66 RminSkyRegion = +360.0; 67 RmaxSkyRegion = -360.0; 68 DminSkyRegion = +90.0; 69 DmaxSkyRegion = -90.0; 54 70 55 71 /* compare with each region file */ … … 80 96 skycoords[i].Xc[3] -= dx; skycoords[i].Yc[3] += dy; 81 97 skycoords[i].Xc[4] -= dx; skycoords[i].Yc[4] -= dy; 82 } 98 99 RminSkyRegion = MIN(RminSkyRegion, skylist[0].regions[i][0].Rmin); 100 RmaxSkyRegion = MAX(RmaxSkyRegion, skylist[0].regions[i][0].Rmax); 101 DminSkyRegion = MIN(DminSkyRegion, skylist[0].regions[i][0].Dmin); 102 DmaxSkyRegion = MAX(DmaxSkyRegion, skylist[0].regions[i][0].Dmax); 103 } 104 MARKTIME("create sky region coords: %f sec\n", dtime); 83 105 84 106 dsortindex (RmaxSky, index, skylist[0].Nregions); 107 MARKTIME("sort sky coords: %f sec\n", dtime); 85 108 86 109 if (VERBOSE) fprintf (stderr, "finding images\n"); 87 110 BuildChipMatch (timage, Ntimage); 111 MARKTIME("build chip match: %f sec\n", dtime); 88 112 89 113 nimage = 0; … … 124 148 } 125 149 126 /* define image corners */ 127 Xi[0] = 0; Yi[0] = 0; 128 Xi[1] = timage[i].NX; Yi[1] = 0; 129 Xi[2] = timage[i].NX; Yi[2] = timage[i].NY; 130 Xi[3] = 0; Yi[3] = timage[i].NY; 131 Xi[4] = 0; Yi[4] = 0; 150 /* define image corners - note the DIS images (mosaic phu) are special */ 151 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { 152 Xi[0] = -0.5*timage[i].NX; Yi[0] = -0.5*timage[i].NY; 153 Xi[1] = +0.5*timage[i].NX; Yi[1] = -0.5*timage[i].NY; 154 Xi[2] = +0.5*timage[i].NX; Yi[2] = +0.5*timage[i].NY; 155 Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY; 156 Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY; 157 } else { 158 Xi[0] = 0; Yi[0] = 0; 159 Xi[1] = timage[i].NX; Yi[1] = 0; 160 Xi[2] = timage[i].NX; Yi[2] = timage[i].NY; 161 Xi[3] = 0; Yi[3] = timage[i].NY; 162 Xi[4] = 0; Yi[4] = 0; 163 } 132 164 found = FALSE; 133 165 134 166 /* transform corners to ra,dec */ 135 167 double RminImage = 360.0; 168 double RmaxImage = 0.0; 169 double DminImage = +90.0; 170 double DmaxImage = -90.0; 136 171 for (j = 0; j < 5; j++) { 137 172 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 138 173 RminImage = MIN(RminImage, Ri[j]); 139 } 174 RmaxImage = MAX(RmaxImage, Ri[j]); 175 DminImage = MIN(DminImage, Di[j]); 176 DmaxImage = MAX(DmaxImage, Di[j]); 177 } 178 if (RmaxImage - RminImage > 180.0) { 179 double tmp = RminImage; 180 RmaxImage = RminImage; 181 RminImage = tmp - 360.0; 182 } 183 184 // check that this image is even in range of the searched region 185 if (DminImage > DmaxSkyRegion) continue; 186 if (DmaxImage < DminSkyRegion) continue; 187 188 // the sky region RA is defined to be 0 - 360.0 189 if (RminImage > RmaxSkyRegion) continue; 190 if (RmaxImage < RminSkyRegion) continue; 140 191 141 192 // RA(nStart) is guaranteed to be < RminImage: … … 194 245 } 195 246 } 196 247 MARKTIME("finish image selection: %f sec\n", dtime); 248 197 249 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); 198 250
Note:
See TracChangeset
for help on using the changeset viewer.
