IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2006, 7:02:16 AM (20 years ago)
Author:
eugene
Message:

substantial updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroAstromGuess.c

    r7014 r7332  
    33// XXX this function assumes the initial astrometry arrives in the form of
    44// XXX WCS keywords in the headers corresponding to the chips.
     5// XXX this function is both converting the header WCS astrometry terms to the fpa terms
     6//     and applying the astrometry to the detected objects. 
    57bool psastroAstromGuess (pmConfig *config) {
    68
    79    bool newFPA = true;
    810    bool status = false;
     11    bool isMosaic = false;
    912    double RAmin, RAmax, RAminSky, RAmaxSky;
    1013    double DECmin, DECmax;
     
    1316    pmCell *cell = NULL;
    1417    pmReadout *readout = NULL;
     18
     19    // is this a mosaic astrometry analysis?
     20    psMetadataLookupStr (&isMosaic, config->arguments, "MOSASTRO");
    1521
    1622    // select the current recipe
     
    3036    double plateScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PLATE.SCALE");
    3137    if (!status) plateScale = 1.0;
     38    plateScale = 1.0;
    3239
    3340    pmFPAview *view = pmFPAviewAlloc (0);
     
    4148        pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
    4249
    43         pmAstromReadWCS (&fpa->projection, &fpa->toTangentPlane, &chip->toFPA, hdu->header, plateScale);
     50        pmAstromReadWCS (fpa, chip, hdu->header, plateScale, isMosaic);
    4451        if (newFPA) {
    4552            newFPA = false;
     
    4956            DECmin = DECmax = fpa->projection->D;
    5057        }
    51 
    52         // build projection inversions
    53         // XXX region should be set from image data
    54         psRegion region = {0, 0, 2000, 4500};
    55         fpa->fromTangentPlane = psPlaneDistortIdentity ();
    56         chip->fromFPA = psPlaneTransformInvert (NULL, chip->toFPA, region, 20);
    5758
    5859        // apply the new WCS guess data to all of the data in the readouts
     
    6667                if (! readout->data_exists) { continue; }
    6768
    68                 psArray *objects = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.OBJECTS");
    69                 if (objects == NULL) { continue; }
     69                psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
     70                if (rawstars == NULL) { continue; }
    7071
    71                 for (int i = 0; i < objects->n; i++) {
    72                     pmAstromObj *object = objects->data[i];
     72                for (int i = 0; i < rawstars->n; i++) {
     73                    pmAstromObj *raw = rawstars->data[i];
    7374       
    74                     psPlaneTransformApply (object->FP, chip->toFPA, object->chip);
    75                     psPlaneDistortApply (object->TP, fpa->toTangentPlane, object->FP, 0.0, 0.0);
    76                     p_psDeproject (object->sky, object->TP, fpa->projection);
     75                    psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
     76                    psPlaneDistortApply (raw->TP, fpa->toTangentPlane, raw->FP, 0.0, 0.0);
     77                    p_psDeproject (raw->sky, raw->TP, fpa->projection);
     78
     79                    if (i < 0) {
     80                        fprintf (stderr, "up: %f,%f -> %f,%f -> %f,%f -> %f,%f\n",
     81                                 raw->chip->x, raw->chip->y,
     82                                 raw->FP->x, raw->FP->y,
     83                                 raw->TP->x, raw->TP->y,
     84                                 raw->sky->r, raw->sky->d);
     85
     86                        psPlane *fp = psPlaneAlloc();
     87                        psPlane *tp = psPlaneAlloc();
     88                        psPlane *ch = psPlaneAlloc();
     89
     90                        p_psProject (tp, raw->sky, fpa->projection);
     91                        psPlaneDistortApply (fp, fpa->fromTangentPlane, tp, 0.0, 0.0);
     92                        psPlaneTransformApply (ch, chip->fromFPA, fp);
     93
     94                        fprintf (stderr, "dn: %f,%f <- %f,%f <- %f,%f <- %f,%f\n",
     95                                 ch->x, ch->y,
     96                                 fp->x, fp->y,
     97                                 tp->x, tp->y,
     98                                 raw->sky->r, raw->sky->d);
     99                    }
    77100
    78101                    // rationalize ra to sky range centered on boresite
    79                     while (object->sky->r < RAminSky) object->sky->r += M_PI;
    80                     while (object->sky->r > RAmaxSky) object->sky->r -= M_PI;
     102                    while (raw->sky->r < RAminSky) raw->sky->r += M_PI;
     103                    while (raw->sky->r > RAmaxSky) raw->sky->r -= M_PI;
    81104
    82                     RAmin = PS_MIN (object->sky->r, RAmin);
    83                     RAmax = PS_MAX (object->sky->r, RAmax);
     105                    RAmin = PS_MIN (raw->sky->r, RAmin);
     106                    RAmax = PS_MAX (raw->sky->r, RAmax);
    84107
    85                     DECmin = PS_MIN (object->sky->d, DECmin);
    86                     DECmax = PS_MAX (object->sky->d, DECmax);
     108                    DECmin = PS_MIN (raw->sky->d, DECmin);
     109                    DECmax = PS_MAX (raw->sky->d, DECmax);
    87110                }
    88111            }
Note: See TracChangeset for help on using the changeset viewer.