IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2020, 4:01:13 PM (6 years ago)
Author:
eugene
Message:

adding recipe values PSASTRO.REFSTAR.CLUMP.NITER, PSASTRO.REFSTAR.CLUMP.SCALE (defaulting to 150, 3 as previously defined); adding log messages to track timing; adding chip-only iteration-depended fitting order; chip-only fitting needs to use bilevel astrometry if the toTPA transformation has order > 1

File:
1 edited

Legend:

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

    r39926 r41285  
    2828    }
    2929
     30    // In this function, we are fitting the chip->FPA model, keeping the toTPA static. 
     31    // If the toTPA model has order > 1, then the WCS terms need to use the BiLevel
     32    // model.  It is possible for this conversion to fail.  However, if we are going to try
     33    // again with the mosaic model (fitting both), then we need to react to failure differently
     34    bool mosastro  = psMetadataLookupBool (&status, config->arguments, "PSASTRO.MOSAIC.MODE");
     35    if (!status) {
     36        mosastro  = psMetadataLookupBool (&status, recipe, "PSASTRO.MOSAIC.MODE");
     37    }
     38
    3039    // select the input data sources
    3140    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT");
     
    3948
    4049    int numGoodChips = 0;               // Number of chips for which astrometry succeeds
     50
     51    bool useBilevelWCS = (fpa->toTPA->x->nX > 1) || (fpa->toTPA->x->nY > 1);
    4152
    4253    while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
     
    145156                psU64 astrom_chip_val = 1;
    146157                astrom_chip_val <<= view->chip;
    147                 psMetadataAddU64 (updates, PS_LIST_TAIL, "ASTROM_CHIPS", PS_META_REPLACE,
    148                     "chips that passed astrometry", astrom_chip_val);
     158                psMetadataAddU64 (updates, PS_LIST_TAIL, "ASTROM_CHIPS", PS_META_REPLACE, "chips that passed astrometry", astrom_chip_val);
    149159
    150160                // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called
    151161                psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis"));
    152162               
    153                 fpa->wcsCDkeys = psMetadataLookupBool(&status, recipe , "PSASTRO.WCS.USECDKEYS");
    154                 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
     163                // if the toTPA distortion model uses higher-order terms, then we need to use BiLevel astrometry
     164                if (useBilevelWCS) {
     165                    // create the header keywords to descripe the results
     166                    if (!pmAstromWriteBilevelChip (updates, chip, NONLIN_TOL)) {
     167                        if (!mosastro) { readout->data_exists = false; } // unless we are going to try again, give up on this chip
     168                        psError(PS_ERR_UNKNOWN, false, "invalid solution for %d,%d,%d\n", view->chip, view->cell, view->readout);
     169                        psErrorStackPrint(stderr, "failure to generate WCS keywords for one chip\n");
     170                        psErrorClear();
     171                        continue;
     172                    }
     173                } else {
     174                    fpa->wcsCDkeys = psMetadataLookupBool(&status, recipe , "PSASTRO.WCS.USECDKEYS");
     175                    pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
     176                }
    155177
    156178                if (psTraceGetLevel("psastro.dump") > 0) {
     
    179201    }
    180202
     203    if (useBilevelWCS) {
     204        // save WCS and analysis metadata in update header.
     205        // (pull or create local view to entry on readout->analysis)
     206        psMetadata *updates = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER");
     207        if (!updates) {
     208            updates = psMetadataAlloc ();
     209            psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", updates);
     210            psFree (updates);
     211        }
     212        if (!pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL)) {
     213            psError(psErrorCodeLast(), false, "Failed to save header terms");
     214            return false;
     215        }
     216    }
     217
    181218    if (fpa->chips->n == 1 && numGoodChips == 0) {
    182219        psError(PSASTRO_ERR_UNKNOWN, false, "Failed to fit single chip.");
Note: See TracChangeset for help on using the changeset viewer.