Changeset 41499 for trunk/psastro/src/psastroMosaicAstrom.c
- Timestamp:
- Feb 18, 2021, 4:08:42 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicAstrom.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicAstrom.c
r39928 r41499 14 14 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 15 15 16 bool psastroMosaicFit (pmFPA *fpa, psMetadata * recipe, const char *rootname, int pass);16 bool psastroMosaicFit (pmFPA *fpa, psMetadata *stats, psMetadata *recipe, const char *rootname, int pass); 17 17 bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe); 18 18 19 19 // 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 21 bool psastroMosaicAstrom (pmConfig *config, psMetadata *stats) { 21 22 22 23 bool status; … … 25 26 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 26 27 if (!recipe) { 28 // recipe or programming error 27 29 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n"); 28 30 return false; … … 32 34 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 33 35 if (!input) { 36 // recipe or programming error 34 37 psError(PSASTRO_ERR_CONFIG, false, "Can't find input data!\n"); 35 38 return false; … … 53 56 // this should be in a loop with nIter = 54 57 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; 56 60 } 57 61 … … 59 63 // first, re-perform the match with a slightly tighter circle 60 64 if (!psastroMosaicSetMatch (fpa, recipe, nIter)) { 65 // recipe or alloc error 61 66 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (pass %d)", nIter); 62 67 return false; 63 68 } 64 if (!psastroMosaicChipAstrom (fpa, recipe, nIter)) { 69 if (!psastroMosaicChipAstrom (fpa, stats, recipe, nIter)) { 70 // this cannot actually return false 65 71 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", nIter); 66 72 return false; … … 83 89 } 84 90 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; 87 97 } 88 98 … … 109 119 // 2: match 6,7 110 120 // 3: match 8,9 111 bool psastroMosaicFit (pmFPA *fpa, psMetadata * recipe, const char *rootname, int pass) {121 bool psastroMosaicFit (pmFPA *fpa, psMetadata *stats, psMetadata *recipe, const char *rootname, int pass) { 112 122 113 123 char filename[256]; … … 117 127 if (!psastroMosaicSetMatch (fpa, recipe, pass)) { 118 128 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 119 130 return false; 120 131 } … … 129 140 // then recalculate raw and ref positions 130 141 if (!psastroMosaicCommonScale (fpa, recipe)) { 142 // this can only return false if the recipe value is not set 131 143 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (pass %d)", pass); 132 144 return false; … … 141 153 // apply the new distortion terms up and down 142 154 // refit the per-chip terms with linear fits only 155 // NOTE: failure here is a data quality problem 143 156 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 } 145 161 return false; 146 162 } … … 150 166 151 167 // 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 153 170 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", pass); 154 171 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
