Changeset 12492 for trunk/psastro/src/psastroMosaicAstrom.c
- Timestamp:
- Mar 18, 2007, 12:28:16 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroMosaicAstrom.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroMosaicAstrom.c
r10922 r12492 5 5 bool psastroMosaicAstrom (pmConfig *config, psArray *refs) { 6 6 7 bool status; 8 7 9 // select the current recipe 8 10 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 9 11 if (!recipe) { 10 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!\n");12 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n"); 11 13 return false; 12 14 } 15 16 // physical pixel scale in microns per pixel 17 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 18 if (!status) { 19 psError(PS_ERR_IO, false, "Failed to lookup pixel scale"); 20 return false; 21 } 13 22 14 23 // select the input data sources 15 24 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 16 25 if (!input) { 17 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data!\n");26 psError(PSASTRO_ERR_CONFIG, false, "Can't find input data!\n"); 18 27 return false; 19 28 } … … 27 36 // given the existing per-chip astrometry, determine matches between raw and ref stars 28 37 // is this needed? yes, if we didn't do SingleChip astrometry first 29 psastroMosaicSetMatch (fpa, recipe, 0); 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 } 30 42 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.0.dat"); } 31 43 … … 33 45 // modify the chip->toFPA scaling to match knowledge about pixel scale, 34 46 // then recalculate raw and ref positions 35 psastroMosaicCommonScale (fpa, recipe); 47 if (!psastroMosaicCommonScale (fpa, recipe)) { 48 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips"); 49 return false; 50 } 36 51 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.1.dat"); } 37 52 … … 39 54 // apply the new distortion terms up and down 40 55 // refit the per-chip terms with linear fits only 41 psastroMosaicGradients (fpa, recipe); 56 if (!psastroMosaicGradients (fpa, recipe)) { 57 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients"); 58 return false; 59 } 42 60 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.2.dat"); } 43 61 44 psastroMosaicChipAstrom (fpa, recipe, false); 62 // measure the astrometry for the chips under the distortion term 63 if (!psastroMosaicChipAstrom (fpa, recipe, false)) { 64 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode"); 65 return false; 66 } 45 67 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.3.dat"); } 46 68 47 // re-perform the match with a slightly tighter circle 48 psastroMosaicSetMatch (fpa, recipe, 1); 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"); } 49 84 50 // do a second pass on the distortion with improved chip positions and rotations51 psastroMosaicCommonScale (fpa, recipe);52 psastroMosaicGradients (fpa, recipe);53 psastroMosaicChipAstrom (fpa, recipe, false);54 psastroMosaicSetMatch (fpa, recipe, 1);55 85 if (!psastroMosaicChipAstrom (fpa, recipe, false)) { 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 56 91 // now fit the chips under the common distortion with higher-order terms 57 92 // first, re-perform the match with a slightly tighter circle 58 psastroMosaicChipAstrom (fpa, recipe, true); 93 if (!psastroMosaicSetMatch (fpa, recipe, 1)) { 94 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (3rd pass)"); 95 return false; 96 } 97 if (!psastroMosaicChipAstrom (fpa, recipe, true)) { 98 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (3rd pass)"); 99 return false; 100 } 101 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.6.dat"); } 59 102 60 // save WCS and analysis metadata in update header 103 // save WCS and analysis metadata in update header XXX this is still wrong: the pmFPAExtent 104 // function returns the FP dimensions in pixel units relative to the 0,0 corner of chip 105 // 0,0. I need to have a function which loops over all cells, determines the pixel 106 // dimensions for each cell, converts them to chip pixels, then uses the fpa astrometry 107 // structures to get the total dimensions of the fpa in fpa units. equivalent to 108 // pmFPAExtent 109 psRegion *region = pmFPAExtent (fpa); 110 region->x0 *= pixelScale; 111 region->x1 *= pixelScale; 112 region->y0 *= pixelScale; 113 region->y1 *= pixelScale; 114 61 115 // XXX also need to add DATE/TIME info and NAXIS1, NAXIS2 62 116 psMetadata *updates = psMetadataAlloc(); 63 psMetadataAddS32 (updates, PS_LIST_TAIL, "NAXIS1", PS_META_REPLACE, "fpa dimensions (um)", 30000); 64 psMetadataAddS32 (updates, PS_LIST_TAIL, "NAXIS2", PS_META_REPLACE, "fpa dimensions (um)", 30000); 65 psMetadataAddStr (updates, PS_LIST_TAIL, "DATE-OBS", PS_META_REPLACE, "date", "2003-08-28"); 66 psMetadataAddStr (updates, PS_LIST_TAIL, "UTC-OBS", PS_META_REPLACE, "date", "7:15:46.47"); 117 psMetadataAddS32 (updates, PS_LIST_TAIL, "NAXIS1", PS_META_REPLACE, "fpa dimensions (mm)", region->x1 - region->x0); 118 psMetadataAddS32 (updates, PS_LIST_TAIL, "NAXIS2", PS_META_REPLACE, "fpa dimensions (mm)", region->y1 - region->y0); 119 psFree (region); 67 120 68 pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL); 121 if (!pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL)) { 122 psAbort ("failed to save header terms"); 123 } 124 69 125 psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", updates); 70 126 psFree (updates);
Note:
See TracChangeset
for help on using the changeset viewer.
