IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42370


Ignore:
Timestamp:
Feb 4, 2023, 12:12:53 PM (3 years ago)
Author:
eugene
Message:

merge changes from trunk: handle inversion failures and missing DETEFF

Location:
branches/eam_branches/ipp-20220316/psastro
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/psastro

  • branches/eam_branches/ipp-20220316/psastro/src/psastroAstromGuess.c

    r41895 r42370  
    320320        if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; }
    321321
    322         if (!chip->toFPA || !chip->fromFPA) {
     322        // if a chip fails during the calibration, the associated readout->data_exists
     323        // gets set to false.  This may be the wrong solution, but it does not break this
     324        // analysis here.  Note this is not the chip->data_exists field tested above.
     325        // chip->data_exists is only false if the chip data is missing.
     326
     327        // chip->fromFPA can be NULL if the inversion fails, but I'm not sure
     328        // chip->toFPA can be NULL unless it was not in the original model
     329        if (!chip->toFPA) {
    323330          char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
    324331          fprintf (stderr, "no astrom model for %s, skipping\n", name);
    325332          continue;
    326333        }
    327 
    328         // XXX we are currently inconsistent with marking the good vs the bad data
    329         // psastroChipAstrom sets data_exists to false if the fit is bad.  this is
    330         // probably wrong since it implies there is no data!
     334        if (!chip->fromFPA) {
     335          char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     336          fprintf (stderr, "inversion faiulre for %s (%d), will be skipped\n", name, view->chip);
     337        }
    331338
    332339        // skip chips for which the astrometry failed (NASTRO == 0)
     
    350357        float astError = psMetadataLookupF32 (&status, updates, "CERROR");
    351358        if (fabs(astError) < 1e-6) goto skip_chip;
     359
     360        // XXX EAM 2022.09.22 : a more robust analysis would put the corner points
     361        // on the chip metadata so we can be certain the old and new corner values
     362        // are correctly matched.
    352363
    353364        psPlane ptCH, ptFP, ptTP;
  • branches/eam_branches/ipp-20220316/psastro/src/psastroConvert.c

    r41895 r42370  
    1818# define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_BLEND | PM_SOURCE_MODE_BADPSF | \
    1919                           PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT | \
    20                            PM_SOURCE_MODE_POOR) // Mask to apply to sources for rejection
     20                           PM_SOURCE_MODE_POOR ) // Mask to apply to sources for rejection
    2121
    2222static psArray *chooseStars(psArray *inStars, char *listName, psArray *sources, psVector *index, int nMax, float iMagMin, float iMagMax, pmSourceMode skip);
     
    193193    int nBrightSkip = 0;
    194194    int nInfSkip = 0;
     195    int nCTESkip = 0;
    195196
    196197    for (int i = 0; (i < inStars->n) && (j < rawStars->n); i++) {
     
    217218          continue;
    218219        }
     220        //Also kick out stars that touch the CTE region
     221        if (source->mode2 & PM_SOURCE_MODE2_ON_CTE) {
     222            nCTESkip ++;
     223            continue;
     224        }
     225       
    219226        mMin = PS_MIN (mMin, source->psfMag);
    220227        mMax = PS_MAX (mMax, source->psfMag);
     
    225232
    226233    psLogMsg ("psastro", 4, "loaded %ld %ssources, using %ld of %ld good sources (inst mag: %f to %f)\n", sources->n, listName, rawStars->n, inStars->n, mMin, mMax);
    227     psLogMsg ("psastro", 4, "skip reasons: mode: %d, faint: %d, bright: %d, inf: %d\n", nModeSkip, nFaintSkip, nBrightSkip, nInfSkip);
     234    psLogMsg ("psastro", 4, "skip reasons: mode: %d, faint: %d, bright: %d, inf: %d, CTE: %d\n", nModeSkip, nFaintSkip, nBrightSkip, nInfSkip,nCTESkip);
    228235
    229236    return rawStars;
     
    509516  float myPltScale = fabs(pltScale[chipID]);
    510517
     518  psLogMsg ("psastro.correctKH", PS_LOG_INFO, "applying KH correction to %s (%d)\n", chipName, chipID);
     519
    511520  // apply the correction to the detections
    512521  for (int i = 0; i < inStars->n; i++) {
  • branches/eam_branches/ipp-20220316/psastro/src/psastroLoadCrosstalk.c

    r41657 r42370  
    370370          //-----------------------------------------------------------------
    371371          //new style crostalk masking, with crosstalk rules from the recipes
    372           if(!crossCheck) {
     372          if (!crossCheck) {
    373373            // load ghost model metadata structure
    374374            psMetadata *crossModel = NULL;
     
    386386
    387387            pmDetEff *de = psMetadataLookupPtr(NULL, readout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency
     388            if (!de) continue; // chip has a problem if DETEFF is missing, just skip it
    388389            if (isnan(de->magRef)) { continue; }
    389390
    390             // find the CROSSTALK.RUKE this chip lands in (if any)
     391            // find the CROSSTALK.RULE this chip lands in (if any)
    391392            psListIterator *crossIter = psListIteratorAlloc(crossRules->data.list, PS_LIST_HEAD, false);
    392393            psMetadataItem *crossItem = NULL;
     
    528529                    //check again if the crosstalk is above the target chip background level
    529530                    pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency
     531                    if (!tarde) continue;
    530532                    if (isnan(tarde->magRef)) { continue; }
    531533
     
    706708                    //check if the crosstalk is above the target chip background level
    707709                    pmDetEff *tarde = psMetadataLookupPtr(NULL, targetReadout->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency
     710                    if (!tarde) continue;
    708711                    if (isnan(tarde->magRef)) { continue; }
    709712
  • branches/eam_branches/ipp-20220316/psastro/src/psastroMosaicOneChip.c

    r41895 r42370  
    148148    if (order == 1) { minNstar = PS_MAX ( 8, minNstar); }
    149149
     150    // determine fromFPA transformation and apply new transformation to raw & ref stars
     151    psastroUpdateChipToFPA (fpa, chip);
     152
    150153    bool validSolution = true;
    151154
     
    162165    if (astNstar < minNstar) {
    163166        psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar);
     167        validSolution = false;
     168    }
     169    if (!chip->fromFPA) {
     170        psLogMsg("psastro", PS_LOG_INFO, "toFPA/fromFPA inversion failure");
    164171        validSolution = false;
    165172    }
     
    189196    psMetadataAddF32 (updates, PS_LIST_TAIL, "AST_MRY",   PS_META_REPLACE, "mosaic astrometry Y 10-90 percentile (arcsec)", results->dYrange * plateScale);
    190197
    191     // determine fromFPA transformation and apply new transformation to raw & ref stars
    192     psastroUpdateChipToFPA (fpa, chip);
    193 
    194     //plot results
     198    // plot results
    195199    pmAstromVisualPlotMosaicOneChip(rawstars, refstars, match, recipe);
    196200
  • branches/eam_branches/ipp-20220316/psastro/src/psastroOneChipFit.c

    r41895 r42370  
    217217        validSolution = false;
    218218    }
     219    if (!chip->fromFPA) {
     220        psLogMsg("psastro", PS_LOG_INFO, "toFPA/fromFPA inversion failure");
     221        validSolution = false;
     222    }
    219223
    220224    // DVO expects NASTRO = 0 if we fail to find a solution
  • branches/eam_branches/ipp-20220316/psastro/src/psastroOneChipGrid.c

    r40084 r42370  
    2222    bool status;
    2323    pmAstromStats *stats = NULL;
     24    char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     25
    2426
    2527    // do we need to get a rough initial match?
     
    4951    }
    5052
    51     psLogMsg ("psastro", 3, "grid search using %ld raw vs %ld ref stars\n", rawGridStars->n, refGridStars->n);
     53    psLogMsg ("psastro", 3, "grid search for chip %s using %ld raw vs %ld ref stars\n",chipname,rawGridStars->n, refGridStars->n);
    5254
    5355    // find initial offset / rotation / scale
    5456    pmAstromStats *gridStats = pmAstromGridMatch (rawGridStars, refGridStars, recipe);
    5557    if (gridStats == NULL) {
    56         psLogMsg ("psastro", 3, "failed to find a grid match solution\n");
     58        psLogMsg ("psastro", 3, "failed to find a grid match solution for chip %s\n",chipname);
    5759        psFree (rawGridStars);
    5860        psFree (refGridStars);
     
    6062        return false;
    6163    }
    62     psLogMsg ("psastro", 3, "basic grid search result - offset: %f,%f pixels, rotation: %f deg\n", gridStats->offset.x, gridStats->offset.y, DEG_RAD*gridStats->angle);
     64    psLogMsg ("psastro", 3, "basic grid search result for chip %s - offset: %f,%f pixels, rotation: %f deg\n",chipname, gridStats->offset.x, gridStats->offset.y, DEG_RAD*gridStats->angle);
    6365
    6466# if (1)
     
    7375        return false;
    7476    }
    75     psLogMsg ("psastro", 3, "tweak grid search result - offset: %f,%f pixels, rotation: %f deg\n", stats->offset.x, stats->offset.y, DEG_RAD*stats->angle);
     77    psLogMsg ("psastro", 3, "tweak grid search result for chip %s - offset: %f,%f pixels, rotation: %f deg\n",chipname, stats->offset.x, stats->offset.y, DEG_RAD*stats->angle);
    7678# else
    7779    // EAM TEST: skip tweak
     
    8284    // adjust the chip.toFPA terms only
    8385    pmAstromGridApply (chip->toFPA, stats);
    84     psastroUpdateChipToFPA (fpa, chip); // updates PSASTRO.RAWSTARS and PSASTRO.REFSTARS
     86    psastroUpdateChipToFPA (fpa, chip); // updates PSASTRO.RAWSTARS and PSASTRO.REFSTARS (see note below)
    8587    psFree (gridStats);
    8688    psFree (rawGridStars);
     
    9092    return true;
    9193}
     94
     95/* if psastroUpdateChiptoFPA fails to invert the toFPA transformation,
     96   the ref->chip coordinates will not be set.  This is not a problem
     97   at this stage since they are not used in the calculation.  Later
     98   passes can still yield a valid solution.
     99*/
  • branches/eam_branches/ipp-20220316/psastro/src/psastroUtils.c

    r41895 r42370  
    109109
    110110    psRegion *region = pmChipPixels (chip);
    111 
    112111    psFree (chip->fromFPA);
    113112    chip->fromFPA = psPlaneTransformInvert (NULL, chip->toFPA, *region, 50, 4);
    114113    psFree (region);
     114
     115    // XXX EAM 2022.09.22 : for a specific case, psPlaneTransformInvert fails.
     116    // This probably means the solution was poor in any case. 
     117    // Some options:
     118    // 1) skip the chip in psastroAstromGuessCheck (supply bad corners)
     119    // 2) mark this chip as bad (return an error here and trap in psastroMosaicOneChip)
     120    // 3) warn of the failure:
     121    if (!chip->fromFPA) {
     122        char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
     123        psLogMsg ("psastro", PS_LOG_INFO, "WARNING: failure to invert toFPA for %s", name);
     124    }
    115125
    116126    // loop over cells in this chip
     
    150160                    pmAstromObj *ref = refstars->data[i];
    151161                    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
     162                    // if chip->fromFPA is NULL (non-invertable), the action is skipped
    152163                }
    153164            }
Note: See TracChangeset for help on using the changeset viewer.