Changeset 30783
- Timestamp:
- Mar 3, 2011, 2:38:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20110218/Ohana/src/getstar/src/MatchCoords.c
- Property svn:mergeinfo set to
r30499 r30783 3 3 # define FLT_MAX 1e32 4 4 # endif 5 int ComputeLMLimits(double xmin, double xmax, double ymin, double ymax, 6 double *Lmin, double *Lmax, double *Mmin, double *Mmax, Coords *coords); 5 7 6 8 /* given coordinate, find images in list that contain the point */ … … 12 14 double Xi[4], Yi[4]; /* image and original corners */ 13 15 double xmin, xmax, ymin, ymax; 16 double Lmin, Lmax, Mmin, Mmax; 14 17 15 18 … … 20 23 also define the vtable entries for the images we keep */ 21 24 25 int haveLimits = 0; 22 26 for (i = 0; i < NdbImages; i++) { 27 haveLimits = 0; 23 28 24 29 if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue; … … 30 35 /* define image corners */ 31 36 SetImageCorners (Xi, Yi, &dbImages[i]); 32 // Xi[ 4] = Xi[0]; Yi[4] = Yi[0];37 // Xi[3] = Xi[0]; Yi[3] = Yi[0]; 33 38 34 39 ymin = xmin = +FLT_MAX; … … 52 57 continue; 53 58 } 54 55 59 56 if (VERBOSE) fprintf(stderr, "%ld %8.1f %8.1f %s\n", i, x, y, dbImages[i].name);60 if (VERBOSE) fprintf(stderr, "%ld %8.1f %8.1f %s\n", i, x, y, dbImages[i].name); 57 61 58 62 if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) { 63 if (VERBOSE) fprintf(stderr, "\tpotential overlap for point %d image %i\n", j, (int) i); 64 65 // We may be using the astrometry far outside it's range of validity. 66 // As a sanity check make sure that the focal plane coords are in bounds. 67 // See ticket 1381 68 if (!haveLimits) { 69 // We defer computing the focal plane limits until we need them 70 status = ComputeLMLimits(xmin, xmax, ymin, ymax, 71 &Lmin, &Lmax, &Mmin, &Mmax, &dbImages[i].coords); 72 if (!status) { 73 continue; 74 } 75 haveLimits = 1; 76 } 77 78 double L, M; 79 status = RD_to_LM(&L, &M, pt->ra, pt->dec, &dbImages[i].coords); 80 if (!status) { 81 // This won't happen because RD_to_XY succeeded above 82 continue; 83 } 84 85 if (VERBOSE) fprintf(stderr, "L: %f M: %f\n", L, M); 86 87 if (L < Lmin || L > Lmax || M < Mmin || M > Mmax) { 88 if (VERBOSE) fprintf(stderr, "\trejecting match for because focal plane coordinates are out of range\n"); 89 continue; 90 } 91 if (VERBOSE) fprintf(stderr, "\tmatch confirmed\n"); 92 59 93 totalMatches++; 60 94 … … 88 122 } 89 123 } 124 125 // compute bounding box of this image in focal plane coordinates 126 int ComputeLMLimits(double xmin, double xmax, double ymin, double ymax, 127 double *Lmin, double *Lmax, double *Mmin, double *Mmax, Coords *coords) 128 { 129 double L0, L1, M0, M1; 130 int status = XY_to_LM(&L0, &M0, xmin, ymin, coords); 131 if (!status) { 132 fprintf(stderr, "failed to transform image corner to LM\n"); 133 return 0; 134 } 135 status = XY_to_LM(&L1, &M1, xmax, ymax, coords); 136 if (!status) { 137 fprintf(stderr, "failed to transform image corner to LM\n"); 138 return 0; 139 } 140 141 if (L1 > L0) { 142 *Lmin = L0; 143 *Lmax = L1; 144 } else { 145 *Lmin = L1; 146 *Lmax = L0; 147 } 148 if (M1 > M0) { 149 *Mmin = M0; 150 *Mmax = M1; 151 } else { 152 *Mmin = M1; 153 *Mmax = M0; 154 } 155 if (VERBOSE) fprintf(stderr, "Lmin: %f Lmax: %f Mmin: %f Mmax: %f\n", *Lmin, *Lmax, *Mmin, *Mmax); 156 return 1; 157 }
Note:
See TracChangeset
for help on using the changeset viewer.
