Changeset 20795
- Timestamp:
- Nov 18, 2008, 5:50:36 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroFixChips.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroFixChips.c
r20746 r20795 1 1 # include "psastroInternal.h" 2 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 3 # define DEBUG 0 3 4 4 5 // XXX I think the 'badAstrom' tests may need to be adjusted: see eg the nominal rotation of … … 7 8 8 9 bool status; 10 FILE *f; 11 char *chipName; 9 12 10 13 bool fixChips = psMetadataLookupBool (&status, config->arguments, "PSASTRO.FIX.CHIPS"); … … 60 63 int nPts = 0; 61 64 65 if (DEBUG) { 66 f = fopen ("corners.raw.dat", "w"); 67 chipName = NULL; 68 } 69 62 70 pmChip *obsChip = NULL; 63 71 while ((obsChip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 64 72 if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; } 73 74 // XXX we are currently inconsistent with marking the good vs the bad data 75 // psastroChipAstrom sets data_exists to false if the fit is bad. this is 76 // probably wrong since it implies there is no data! 77 78 // skip chips for which the astrometry failed (NASTRO == 0) 79 if (!obsChip->cells->n) continue; 80 pmCell *cell = obsChip->cells->data[0]; 81 if (!cell) continue; 82 83 if (!cell->readouts->n) continue; 84 pmReadout *readout = cell->readouts->data[0]; 85 if (!readout) continue; 86 87 psMetadata *updates = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"); 88 if (!updates) continue; 89 90 int nAstro = psMetadataLookupS32 (&status, updates, "NASTRO"); 91 if (!nAstro) continue; 65 92 66 93 // set the chip astrometry using the astrom file … … 77 104 xRef->data.F32[nPts] = ptFP.x; 78 105 yRef->data.F32[nPts] = ptFP.y; 106 107 if (DEBUG) { 108 chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME"); 109 fprintf (f, "%s %f %f %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]); 110 } 79 111 nPts ++; 80 112 … … 86 118 xRef->data.F32[nPts] = ptFP.x; 87 119 yRef->data.F32[nPts] = ptFP.y; 120 121 if (DEBUG) { 122 chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME"); 123 fprintf (f, "%s %f %f %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]); 124 } 88 125 nPts ++; 89 126 … … 95 132 xRef->data.F32[nPts] = ptFP.x; 96 133 yRef->data.F32[nPts] = ptFP.y; 134 135 if (DEBUG) { 136 chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME"); 137 fprintf (f, "%s %f %f %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]); 138 } 97 139 nPts ++; 98 140 … … 104 146 xRef->data.F32[nPts] = ptFP.x; 105 147 yRef->data.F32[nPts] = ptFP.y; 148 149 if (DEBUG) { 150 chipName = psMetadataLookupStr(NULL, obsChip->concepts, "CHIP.NAME"); 151 fprintf (f, "%s %f %f %f %f\n", chipName, xObs->data.F32[nPts], yObs->data.F32[nPts], xRef->data.F32[nPts], yRef->data.F32[nPts]); 152 } 106 153 nPts ++; 107 154 … … 109 156 } 110 157 xObs->n = yObs->n = xRef->n = yRef->n = nPts; 158 if (DEBUG) fclose (f); 111 159 112 160 psPlaneTransform *map = psPlaneTransformAlloc (1, 1); … … 129 177 // the measured transformation above must be applied to make the comparison, and also then applied to the 130 178 // model transformation 179 180 if (DEBUG) { 181 f = fopen ("corners.fit.dat", "w"); 182 for (int i = 0; i < xObs->n; i++) { 183 psPlane obsCoord, refCoord; 184 refCoord.x = xRef->data.F32[i]; 185 refCoord.y = yRef->data.F32[i]; 186 psPlaneTransformApply (&obsCoord, map, &refCoord); 187 fprintf (f, "%f %f %f %f %f %f\n", xObs->data.F32[i], yObs->data.F32[i], xRef->data.F32[i], yRef->data.F32[i], obsCoord.x, obsCoord.y); 188 } 189 fclose (f); 190 } 131 191 132 192 psFree (xObs); … … 198 258 // for successful chips, save the measured offsets in the header 199 259 if (!badAstrom) continue; 260 261 // XXX for now, let's just fail on the bad chips. In the future, let's try to recover, but we still need to 262 // catch the failures relative to the model 263 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 264 continue; 200 265 201 266 psLogMsg ("psastro", PS_LOG_INFO, "fixing chip %d, angle: %f, pixel: %f,%f\n",
Note:
See TracChangeset
for help on using the changeset viewer.
