- Timestamp:
- Feb 24, 2020, 4:01:13 PM (6 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 6 edited
-
psastro.c (modified) (2 diffs)
-
psastroAnalysis.c (modified) (2 diffs)
-
psastroChipAstrom.c (modified) (4 diffs)
-
psastroChooseRefstars.c (modified) (2 diffs)
-
psastroOneChipFit.c (modified) (4 diffs)
-
psastroRemoveClumps.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.c
r23810 r41285 51 51 } 52 52 53 psLogMsg("psastro", 3, "TIMEMARK: psastroDataLoad: %f sec\n", psTimerMark ("complete")); 54 53 55 psMetadata *stats = psMetadataAlloc(); // Statistics, for output 54 56 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0); … … 61 63 exit(PS_EXIT_SYS_ERROR); 62 64 } 65 66 psLogMsg("psastro", 3, "TIMEMARK: psastroAnalysis: %f sec\n", psTimerMark ("complete")); 63 67 64 68 // write out the results -
trunk/psastro/src/psastroAnalysis.c
r35715 r41285 135 135 } 136 136 } 137 138 psLogMsg("psastro", 3, "TIMEMARK: psastroChipAstrom: %f sec\n", psTimerMark ("complete")); 139 137 140 if (mosastro) { 138 141 if (!psastroMosaicAstrom (config)) { … … 150 153 } 151 154 } 155 156 psLogMsg("psastro", 3, "TIMEMARK: psastroMosaicAstrom: %f sec\n", psTimerMark ("complete")); 152 157 153 158 if (!skipastro) { -
trunk/psastro/src/psastroChipAstrom.c
r39926 r41285 28 28 } 29 29 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 30 39 // select the input data sources 31 40 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT"); … … 39 48 40 49 int numGoodChips = 0; // Number of chips for which astrometry succeeds 50 51 bool useBilevelWCS = (fpa->toTPA->x->nX > 1) || (fpa->toTPA->x->nY > 1); 41 52 42 53 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { … … 145 156 psU64 astrom_chip_val = 1; 146 157 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); 149 159 150 160 // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called 151 161 psMetadataAddF32 (updates, PS_LIST_TAIL, "DT_ASTR", PS_META_REPLACE, "elapsed psastro time", psTimerMark ("psastroAnalysis")); 152 162 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 } 155 177 156 178 if (psTraceGetLevel("psastro.dump") > 0) { … … 179 201 } 180 202 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 181 218 if (fpa->chips->n == 1 && numGoodChips == 0) { 182 219 psError(PSASTRO_ERR_UNKNOWN, false, "Failed to fit single chip."); -
trunk/psastro/src/psastroChooseRefstars.c
r37573 r41285 46 46 47 47 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; 48 54 49 55 pmFPAview *view = pmFPAviewAlloc (0); … … 178 184 // generate a reduced subset excluding the clumps 179 185 // XXX do we need both REFSTARS and SUBSET? 180 psArray *subset = psastroRemoveClumpsIterate(refstars, 150, 3);186 psArray *subset = psastroRemoveClumpsIterate(refstars, clumpScale, nIter); 181 187 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", subset); 182 188 -
trunk/psastro/src/psastroOneChipFit.c
r39926 r41285 36 36 37 37 // 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); 39 39 40 40 // allowed limits for valid solutions … … 57 57 } 58 58 59 sprintf (name, "PSASTRO.ONE.CHIP.ORDER.N%d", iter); 60 int order = psMetadataLookupS32 (&status, recipe, name); 61 if (!status) { 62 order = defaultOrder; 63 } 59 64 60 65 // use small radius to match stars … … 76 81 match = unique; 77 82 } 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 78 94 79 95 // modify the order to correspond to the actual number of matched stars: … … 137 153 psastroUpdateChipToFPA (fpa, chip); // updates PSASTRO.RAWSTARS and PSASTRO.REFSTARS 138 154 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 139 165 // toSky converts from FPA & TPA units (microns) to sky units (radians) 140 166 float plateScale = 0.5*(fpa->toSky->Xs + fpa->toSky->Ys)*3600.0*PM_DEG_RAD; -
trunk/psastro/src/psastroRemoveClumps.c
r31333 r41285 35 35 } 36 36 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 37 43 pmFPAview *view = pmFPAviewAlloc (0); 38 44 pmFPA *fpa = input->fpa; … … 58 64 // XXX do we need both RAWSTARS and SUBSET? 59 65 // XXX put these parameters in the recipe, please 60 psArray *subset = psastroRemoveClumpsIterate(rawstars, 150, 3);66 psArray *subset = psastroRemoveClumpsIterate(rawstars, clumpScale, nIter); 61 67 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", subset); 62 68 psFree (subset); … … 65 71 if ((gridstars == rawstars) || (gridstars == NULL)) { continue; } 66 72 67 psArray *gridstars_subset = psastroRemoveClumpsIterate(gridstars, 150, 3);73 psArray *gridstars_subset = psastroRemoveClumpsIterate(gridstars, clumpScale, nIter); 68 74 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.GRID.RAWSTARS.SUBSET", PS_DATA_ARRAY, "astrometry objects", gridstars_subset); 69 75 psFree (gridstars_subset); … … 79 85 psArray *newset = psMemIncrRefCounter (input); 80 86 for (int i = 0; i < nIter; i++) { 81 psArray *subset = psastroRemoveClumps (newset, 150);87 psArray *subset = psastroRemoveClumps (newset, scale); 82 88 psFree (newset); 83 89 newset = subset;
Note:
See TracChangeset
for help on using the changeset viewer.
