IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20795


Ignore:
Timestamp:
Nov 18, 2008, 5:50:36 PM (17 years ago)
Author:
eugene
Message:

exclude probable bad solutions from the fit; exclude bad chips from future analysis

File:
1 edited

Legend:

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

    r20746 r20795  
    11# include "psastroInternal.h"
    22# define NONLIN_TOL 0.001 /* tolerance in pixels */
     3# define DEBUG 0
    34
    45// XXX I think the 'badAstrom' tests may need to be adjusted: see eg the nominal rotation of
     
    78
    89    bool status;
     10    FILE *f;
     11    char *chipName;
    912
    1013    bool fixChips = psMetadataLookupBool (&status, config->arguments, "PSASTRO.FIX.CHIPS");
     
    6063    int nPts = 0;
    6164
     65    if (DEBUG) {
     66        f = fopen ("corners.raw.dat", "w");
     67        chipName = NULL;
     68    }
     69
    6270    pmChip *obsChip = NULL;
    6371    while ((obsChip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    6472        if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; }
     73
     74        // XXX we are currently inconsistent with marking the good vs the bad data
     75        // psastroChipAstrom sets data_exists to false if the fit is bad.  this is
     76        // probably wrong since it implies there is no data!
     77
     78        // skip chips for which the astrometry failed (NASTRO == 0)
     79        if (!obsChip->cells->n) continue;
     80        pmCell *cell = obsChip->cells->data[0];
     81        if (!cell) continue;
     82
     83        if (!cell->readouts->n) continue;
     84        pmReadout *readout = cell->readouts->data[0];
     85        if (!readout) continue;
     86
     87        psMetadata *updates = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");
     88        if (!updates) continue;
     89       
     90        int nAstro = psMetadataLookupS32 (&status, updates, "NASTRO");
     91        if (!nAstro) continue;
    6592
    6693        // set the chip astrometry using the astrom file
     
    77104        xRef->data.F32[nPts] = ptFP.x;
    78105        yRef->data.F32[nPts] = ptFP.y;
     106
     107        if (DEBUG) {
     108            chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME");
     109            fprintf (f, "%s  %f %f  %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]);
     110        }
    79111        nPts ++;
    80112
     
    86118        xRef->data.F32[nPts] = ptFP.x;
    87119        yRef->data.F32[nPts] = ptFP.y;
     120
     121        if (DEBUG) {
     122            chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME");
     123            fprintf (f, "%s  %f %f  %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]);
     124        }
    88125        nPts ++;
    89126
     
    95132        xRef->data.F32[nPts] = ptFP.x;
    96133        yRef->data.F32[nPts] = ptFP.y;
     134
     135        if (DEBUG) {
     136            chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME");
     137            fprintf (f, "%s  %f %f  %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]);
     138        }
    97139        nPts ++;
    98140
     
    104146        xRef->data.F32[nPts] = ptFP.x;
    105147        yRef->data.F32[nPts] = ptFP.y;
     148
     149        if (DEBUG) {
     150            chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME");
     151            fprintf (f, "%s  %f %f  %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]);
     152        }
    106153        nPts ++;
    107154
     
    109156    }
    110157    xObs->n = yObs->n = xRef->n = yRef->n = nPts;
     158    if (DEBUG) fclose (f);
    111159       
    112160    psPlaneTransform *map = psPlaneTransformAlloc (1, 1);
     
    129177    // the measured transformation above must be applied to make the comparison, and also then applied to the
    130178    // model transformation
     179
     180    if (DEBUG) {
     181        f = fopen ("corners.fit.dat", "w");
     182        for (int i = 0; i < xObs->n; i++) {
     183            psPlane obsCoord, refCoord;
     184            refCoord.x = xRef->data.F32[i];
     185            refCoord.y = yRef->data.F32[i];
     186            psPlaneTransformApply (&obsCoord, map, &refCoord);
     187            fprintf (f, "%f %f  %f %f  %f %f\n", xObs->data.F32[i], yObs->data.F32[i], xRef->data.F32[i], yRef->data.F32[i], obsCoord.x, obsCoord.y);
     188        }
     189        fclose (f);
     190    }
    131191
    132192    psFree (xObs);
     
    198258        // for successful chips, save the measured offsets in the header
    199259        if (!badAstrom) continue;
     260
     261        // XXX for now, let's just fail on the bad chips.  In the future, let's try to recover, but we still need to
     262        // catch the failures relative to the model
     263        psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0);
     264        continue;
    200265
    201266        psLogMsg ("psastro", PS_LOG_INFO, "fixing chip %d, angle: %f, pixel: %f,%f\n",
Note: See TracChangeset for help on using the changeset viewer.