Changeset 41285 for trunk/psastro/src/psastroChipAstrom.c
- Timestamp:
- Feb 24, 2020, 4:01:13 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroChipAstrom.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.");
Note:
See TracChangeset
for help on using the changeset viewer.
