IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 18, 2021, 4:08:42 PM (5 years ago)
Author:
eugene
Message:

set bad data quality if too many chips fail in mosaic, but do not fail to write out the smf file

File:
1 edited

Legend:

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

    r39928 r41499  
    1414# define NONLIN_TOL 0.001 /* tolerance in pixels */
    1515
    16 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass);
     16bool psastroMosaicFit (pmFPA *fpa, psMetadata *stats, psMetadata *recipe, const char *rootname, int pass);
    1717bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe);
    1818
    1919// XXX require this fpa to have multiple chip extensions and a PHU?
    20 bool psastroMosaicAstrom (pmConfig *config) {
     20// EAM 2021.02.18 : addings 'stats' to set bad quality as appropriate
     21bool psastroMosaicAstrom (pmConfig *config, psMetadata *stats) {
    2122
    2223    bool status;
     
    2526    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
    2627    if (!recipe) {
     28        // recipe or programming error
    2729        psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n");
    2830        return false;
     
    3234    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
    3335    if (!input) {
     36        // recipe or programming error
    3437        psError(PSASTRO_ERR_CONFIG, false, "Can't find input data!\n");
    3538        return false;
     
    5356    // this should be in a loop with nIter =
    5457    for (int iter = 0; fitMosaicDistortion && (iter < nIter); iter++) {
    55         if (!psastroMosaicFit (fpa, recipe, outroot, iter)) return false;
     58        // NOTE: data quality (psastroMosaicDistortion) or recipe / config error
     59        if (!psastroMosaicFit (fpa, stats, recipe, outroot, iter)) return false;
    5660    }
    5761
     
    5963    // first, re-perform the match with a slightly tighter circle
    6064    if (!psastroMosaicSetMatch (fpa, recipe, nIter)) {
     65      // recipe or alloc error
    6166      psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (pass %d)", nIter);
    6267      return false;
    6368    }
    64     if (!psastroMosaicChipAstrom (fpa, recipe, nIter)) {
     69    if (!psastroMosaicChipAstrom (fpa, stats, recipe, nIter)) {
     70      // this cannot actually return false
    6571      psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", nIter);
    6672      return false;
     
    8389    }
    8490    if (!pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL)) {
    85         psError(psErrorCodeLast(), false, "Failed to save header terms");
    86         return false;
     91        // error here is a data quality problem (and too bad to write smf)
     92        psWarning ("Failed to save header terms");
     93        if (stats && psMetadataLookupS32(NULL, stats, "QUALITY") == 0) {
     94            psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, "Mosaic astrometry failed", PSASTRO_ERR_DATA);
     95        }
     96        return false;
    8797    }
    8898
     
    109119// 2: match 6,7
    110120// 3: match 8,9
    111 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass) {
     121bool psastroMosaicFit (pmFPA *fpa, psMetadata *stats, psMetadata *recipe, const char *rootname, int pass) {
    112122
    113123    char filename[256];
     
    117127    if (!psastroMosaicSetMatch (fpa, recipe, pass)) {
    118128        psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (pass %d)", pass);
     129        // this can only fail on alloc failure in pmAstromRadiusMatchUniq
    119130        return false;
    120131    }
     
    129140    // then recalculate raw and ref positions
    130141    if (!psastroMosaicCommonScale (fpa, recipe)) {
     142        // this can only return false if the recipe value is not set
    131143        psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (pass %d)", pass);
    132144        return false;
     
    141153    // apply the new distortion terms up and down
    142154    // refit the per-chip terms with linear fits only
     155    // NOTE: failure here is a data quality problem
    143156    if (!psastroMosaicDistortion (fpa, recipe, pass)) {
    144         psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (pass %d)", pass);
     157        psWarning ("failed to measure mosaic gradients (pass %d)", pass);
     158        if (stats && psMetadataLookupS32(NULL, stats, "QUALITY") == 0) {
     159            psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, "Mosaic astrometry failed", PSASTRO_ERR_DATA);
     160        }
    145161        return false;
    146162    }
     
    150166
    151167    // measure the astrometry for the chips under the distortion term
    152     if (!psastroMosaicChipAstrom (fpa, recipe, pass)) {
     168    if (!psastroMosaicChipAstrom (fpa, stats, recipe, pass)) {
     169        // this cannot actually return false
    153170        psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", pass);
    154171        return false;
Note: See TracChangeset for help on using the changeset viewer.