IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41285


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

Location:
trunk/psastro/src
Files:
6 edited

Legend:

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

    r23810 r41285  
    5151    }
    5252
     53    psLogMsg("psastro", 3, "TIMEMARK: psastroDataLoad: %f sec\n", psTimerMark ("complete"));
     54
    5355    psMetadata *stats = psMetadataAlloc(); // Statistics, for output
    5456    psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0);
     
    6163        exit(PS_EXIT_SYS_ERROR);
    6264    }
     65
     66    psLogMsg("psastro", 3, "TIMEMARK: psastroAnalysis: %f sec\n", psTimerMark ("complete"));
    6367
    6468    // write out the results
  • trunk/psastro/src/psastroAnalysis.c

    r35715 r41285  
    135135        }
    136136    }
     137
     138    psLogMsg("psastro", 3, "TIMEMARK: psastroChipAstrom: %f sec\n", psTimerMark ("complete"));
     139
    137140    if (mosastro) {
    138141        if (!psastroMosaicAstrom (config)) {
     
    150153        }
    151154    }
     155
     156    psLogMsg("psastro", 3, "TIMEMARK: psastroMosaicAstrom: %f sec\n", psTimerMark ("complete"));
    152157
    153158    if (!skipastro) {
  • 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.");
  • trunk/psastro/src/psastroChooseRefstars.c

    r37573 r41285  
    4646
    4747    bool matchLumFunc = psMetadataLookupBool (&status, recipe, "PSASTRO.MATCH.LUMFUNC");
     48
     49    int nIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.REFSTAR.CLUMP.NITER");
     50    if (!status) nIter = 3;
     51
     52    psF32 clumpScale = psMetadataLookupS32 (&status, recipe, "PSASTRO.REFSTAR.CLUMP.SCALE");
     53    if (!status) clumpScale = 150;
    4854
    4955    pmFPAview *view = pmFPAviewAlloc (0);
     
    178184                // generate a reduced subset excluding the clumps
    179185                // XXX do we need both REFSTARS and SUBSET?
    180                 psArray *subset = psastroRemoveClumpsIterate(refstars, 150, 3);
     186                psArray *subset = psastroRemoveClumpsIterate(refstars, clumpScale, nIter);
    181187                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", subset);
    182188
  • trunk/psastro/src/psastroOneChipFit.c

    r39926 r41285  
    3636
    3737    // select the desired chip order
    38     REQUIRED_RECIPE_VALUE (int order, "PSASTRO.CHIP.ORDER", S32);
     38    REQUIRED_RECIPE_VALUE (int defaultOrder, "PSASTRO.CHIP.ORDER", S32);
    3939
    4040    // allowed limits for valid solutions
     
    5757        }
    5858
     59        sprintf (name, "PSASTRO.ONE.CHIP.ORDER.N%d", iter);
     60        int order = psMetadataLookupS32 (&status, recipe, name);
     61        if (!status) {
     62            order = defaultOrder;
     63        }
    5964
    6065        // use small radius to match stars
     
    7681            match = unique;
    7782        }
     83
     84        // XXX check if we correctly applied the new transformation:
     85        if (psTraceGetLevel("psastro.dump") > 0) {
     86          char *filename = NULL;
     87          char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
     88          psStringAppend (&filename, "match.pref.%s.%d.dat", chipname, iter);
     89          psastroDumpMatchedStars (filename, rawstars, refstars, match);
     90          psFree (filename);
     91          filename = NULL;
     92        }
     93
    7894
    7995        // modify the order to correspond to the actual number of matched stars:
     
    137153        psastroUpdateChipToFPA (fpa, chip); // updates PSASTRO.RAWSTARS and PSASTRO.REFSTARS
    138154
     155        // XXX check if we correctly applied the new transformation:
     156        if (psTraceGetLevel("psastro.dump") > 0) {
     157          char *filename = NULL;
     158          char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
     159          psStringAppend (&filename, "match.post.%s.%d.dat", chipname, iter);
     160          psastroDumpMatchedStars (filename, rawstars, refstars, match);
     161          psFree (filename);
     162          filename = NULL;
     163        }
     164
    139165        // toSky converts from FPA & TPA units (microns) to sky units (radians)
    140166        float plateScale = 0.5*(fpa->toSky->Xs + fpa->toSky->Ys)*3600.0*PM_DEG_RAD;
  • trunk/psastro/src/psastroRemoveClumps.c

    r31333 r41285  
    3535    }
    3636
     37    int nIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.REFSTAR.CLUMP.NITER");
     38    if (!status) nIter = 3;
     39
     40    psF32 clumpScale = psMetadataLookupS32 (&status, recipe, "PSASTRO.REFSTAR.CLUMP.SCALE");
     41    if (!status) clumpScale = 150;
     42
    3743    pmFPAview *view = pmFPAviewAlloc (0);
    3844    pmFPA *fpa = input->fpa;
     
    5864                // XXX do we need both RAWSTARS and SUBSET?
    5965                // XXX put these parameters in the recipe, please
    60                 psArray *subset = psastroRemoveClumpsIterate(rawstars, 150, 3);
     66                psArray *subset = psastroRemoveClumpsIterate(rawstars, clumpScale, nIter);
    6167                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", subset);
    6268                psFree (subset);
     
    6571                if ((gridstars == rawstars) || (gridstars == NULL)) { continue; }
    6672
    67                 psArray *gridstars_subset = psastroRemoveClumpsIterate(gridstars, 150, 3);
     73                psArray *gridstars_subset = psastroRemoveClumpsIterate(gridstars, clumpScale, nIter);
    6874                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.GRID.RAWSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", gridstars_subset);
    6975                psFree (gridstars_subset);
     
    7985    psArray *newset = psMemIncrRefCounter (input);
    8086    for (int i = 0; i < nIter; i++) {
    81         psArray *subset = psastroRemoveClumps (newset, 150);
     87        psArray *subset = psastroRemoveClumps (newset, scale);
    8288        psFree (newset);
    8389        newset = subset;
Note: See TracChangeset for help on using the changeset viewer.