Changeset 19310
- Timestamp:
- Sep 2, 2008, 9:08:31 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicAstrom.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicAstrom.c
r16251 r19310 1 1 # include "psastroInternal.h" 2 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 3 4 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass); 3 5 4 6 // XXX require this fpa to have multiple chip extensions and a PHU? … … 34 36 # endif 35 37 36 // given the existing per-chip astrometry, determine matches between raw and ref stars 37 // is this needed? yes, if we didn't do SingleChip astrometry first 38 if (!psastroMosaicSetMatch (fpa, recipe, 0)) { 39 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic"); 40 return false; 41 } 42 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.0.dat"); } 43 44 // fitted chips will follow the local plate-scale, hiding the distortion 45 // modify the chip->toFPA scaling to match knowledge about pixel scale, 46 // then recalculate raw and ref positions 47 if (!psastroMosaicCommonScale (fpa, recipe)) { 48 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips"); 49 return false; 50 } 51 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.1.dat"); } 52 53 // fit the distortion by fitting its gradient 54 // apply the new distortion terms up and down 55 // refit the per-chip terms with linear fits only 56 if (!psastroMosaicGradients (fpa, recipe)) { 57 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients"); 58 return false; 59 } 60 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.2.dat"); } 61 62 // measure the astrometry for the chips under the distortion term 63 if (!psastroMosaicChipAstrom (fpa, recipe, 0)) { 64 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode"); 65 return false; 66 } 67 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.3.dat"); } 68 69 // do a second pass on the distortion with improved chip positions and rotations 70 // first, re-perform the match with a slightly tighter circle 71 if (!psastroMosaicSetMatch (fpa, recipe, 1)) { 72 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (2nd pass)"); 73 return false; 74 } 75 if (!psastroMosaicCommonScale (fpa, recipe)) { 76 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (2nd pass)"); 77 return false; 78 } 79 if (!psastroMosaicGradients (fpa, recipe)) { 80 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (2nd pass)"); 81 return false; 82 } 83 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.4.dat"); } 84 85 if (!psastroMosaicChipAstrom (fpa, recipe, 1)) { 86 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (2nd pass)"); 87 return false; 88 } 89 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.5.dat"); } 90 91 // do a third pass on the distortion with improved chip positions and rotations 92 // first, re-perform the match with a slightly tighter circle 93 if (!psastroMosaicSetMatch (fpa, recipe, 2)) { 94 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (3rd pass)"); 95 return false; 96 } 97 if (!psastroMosaicCommonScale (fpa, recipe)) { 98 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (3rd pass)"); 99 return false; 100 } 101 if (!psastroMosaicGradients (fpa, recipe)) { 102 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (3rd pass)"); 103 return false; 104 } 105 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.6.dat"); } 106 107 if (!psastroMosaicChipAstrom (fpa, recipe, 2)) { 108 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (3rd pass)"); 109 return false; 110 } 111 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.7.dat"); } 38 if (!psastroMosaicFit (fpa, recipe, 0)) return false; 39 if (!psastroMosaicFit (fpa, recipe, 1)) return false; 40 if (!psastroMosaicFit (fpa, recipe, 2)) return false; 41 if (!psastroMosaicFit (fpa, recipe, 3)) return false; 112 42 113 43 // now fit the chips under the common distortion with higher-order terms 114 44 // first, re-perform the match with a slightly tighter circle 115 if (!psastroMosaicSetMatch (fpa, recipe, 3)) {116 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic ( 3rdpass)");45 if (!psastroMosaicSetMatch (fpa, recipe, 4)) { 46 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (4th pass)"); 117 47 return false; 118 48 } 119 if (!psastroMosaicChipAstrom (fpa, recipe, 3)) {120 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode ( 3rdpass)");49 if (!psastroMosaicChipAstrom (fpa, recipe, 4)) { 50 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (4th pass)"); 121 51 return false; 122 52 } 123 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match. 8.dat"); }53 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.10.dat"); } 124 54 125 55 // save WCS and analysis metadata in update header. … … 150 80 * sky (ra, dec) 151 81 */ 82 83 // 1: match 4,5 84 // 2: match 6,7 85 // 3: match 8,9 86 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass) { 87 88 char filename[16]; 89 90 // given the existing per-chip astrometry, determine matches between raw and ref stars 91 // is this needed? yes, if we didn't do SingleChip astrometry first 92 if (!psastroMosaicSetMatch (fpa, recipe, pass)) { 93 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (pass %d)", pass); 94 return false; 95 } 96 97 if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.0.dat"); } 98 99 // fitted chips will follow the local plate-scale, hiding the distortion 100 // modify the chip->toFPA scaling to match knowledge about pixel scale, 101 // then recalculate raw and ref positions 102 if (!psastroMosaicCommonScale (fpa, recipe)) { 103 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (pass %d)", pass); 104 return false; 105 } 106 107 if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.1.dat"); } 108 109 // fit the distortion by fitting its gradient 110 // apply the new distortion terms up and down 111 // refit the per-chip terms with linear fits only 112 if (!psastroMosaicDistortion (fpa, recipe)) { 113 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (pass %d)", pass); 114 return false; 115 } 116 117 snprintf (filename, 16, "match.%d.dat", 2*pass + 2); 118 if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); } 119 120 // measure the astrometry for the chips under the distortion term 121 if (!psastroMosaicChipAstrom (fpa, recipe, pass)) { 122 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", pass); 123 return false; 124 } 125 126 snprintf (filename, 16, "match.%d.dat", 2*pass + 3); 127 if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); } 128 129 return true; 130 }
Note:
See TracChangeset
for help on using the changeset viewer.
