IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30782


Ignore:
Timestamp:
Mar 3, 2011, 2:37:15 PM (15 years ago)
Author:
bills
Message:

fix problem reported int ticket #1381 dvoImagesAtCoords can find coordints in 2 chips
When a match is found in chip coordinates, do a sanity check in focal plane coordinates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/getstar/src/MatchCoords.c

    r30499 r30782  
    33# define FLT_MAX 1e32
    44# endif
     5int ComputeLMLimits(double xmin, double xmax, double ymin, double ymax,
     6            double *Lmin, double *Lmax, double *Mmin, double *Mmax, Coords *coords);
    57
    68/* given coordinate, find images in list that contain the point */
     
    1214  double Xi[4], Yi[4];  /* image and original corners */
    1315  double xmin, xmax, ymin, ymax;
     16  double Lmin, Lmax, Mmin, Mmax;
    1417
    1518
     
    2023     also define the vtable entries for the images we keep  */
    2124
     25  int haveLimits = 0;
    2226  for (i = 0; i < NdbImages; i++) {
     27      haveLimits = 0;
    2328
    2429    if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue;
     
    3035    /* define image corners */
    3136    SetImageCorners (Xi, Yi, &dbImages[i]);
    32     // Xi[4] = Xi[0]; Yi[4] = Yi[0];
     37    // Xi[3] = Xi[0]; Yi[3] = Yi[0];
    3338
    3439    ymin = xmin = +FLT_MAX;
     
    5257            continue;
    5358        }
    54 
    5559       
    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);
    5761
    5862        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
    5993            totalMatches++;
    6094
     
    88122  }
    89123}
     124
     125// compute bounding box of this image in focal plane coordinates
     126int 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.