- Timestamp:
- Oct 28, 2008, 1:20:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20081011/psastro/src/psastroFixChips.c
r16077 r20443 109 109 } 110 110 xObs->n = yObs->n = xRef->n = yRef->n = nPts; 111 111 112 112 psPlaneTransform *map = psPlaneTransformAlloc (1, 1); 113 113 114 114 psVector *mask = psVectorAlloc (nPts, PS_TYPE_U8); 115 115 psVectorInit (mask, 0); … … 127 127 128 128 // loop over all chips, select the outliers, and replace the measured astrometry with the model 129 // the measured transformation above must be applied to make the comparison, and also then applied to the 129 // the measured transformation above must be applied to make the comparison, and also then applied to the 130 130 // model transformation 131 131 132 psFree (xObs);133 psFree (yObs);134 132 psFree (xRef); 135 133 psFree (yRef); … … 159 157 psPlaneTransformApply (&tmpCoord, refChip->toFPA, &refPixel); 160 158 psPlaneTransformApply (&refCoord, map, &tmpCoord); 161 159 162 160 psPlane offPixel = {100.0, 0.0, 100.0, 0.0}; 163 161 psPlane obsOffPt, refOffPt; … … 169 167 psPlaneTransformApply (&tmpCoord, refChip->toFPA, &offPixel); 170 168 psPlaneTransformApply (&refOffPt, map, &tmpCoord); 171 169 172 170 double obsAngle = PM_DEG_RAD*atan2 (obsOffPt.y - obsCoord.y, obsOffPt.x - obsCoord.x); 173 171 double refAngle = PM_DEG_RAD*atan2 (refOffPt.y - refCoord.y, refOffPt.x - refCoord.x); … … 183 181 184 182 psLogMsg ("psastro", PS_LOG_INFO, "fixing chip %d, angle: %f, pixel: %f,%f\n", 185 view->chip, obsAngle - refAngle, obsCoord.x - refCoord.x, obsCoord.y - refCoord.y);183 view->chip, obsAngle - refAngle, obsCoord.x - refCoord.x, obsCoord.y - refCoord.y); 186 184 187 185 psFree (obsChip->toFPA); … … 192 190 psPlaneTransform *toFPA = psPlaneTransformAlloc(refChip->toFPA->x->nX, refChip->toFPA->x->nY); 193 191 for (int i = 0; i <= refChip->toFPA->x->nX; i++) { 194 for (int j = 0; j <= refChip->toFPA->x->nY; j++) {195 double f1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->x->coeff[1][0]*refChip->toFPA->x->coeff[i][j];196 double f2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->x->coeff[0][1]*refChip->toFPA->y->coeff[i][j];197 toFPA->x->coeff[i][j] = f1 + f2;198 199 double g1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->y->coeff[1][0]*refChip->toFPA->x->coeff[i][j];200 double g2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->y->coeff[0][1]*refChip->toFPA->y->coeff[i][j];201 toFPA->y->coeff[i][j] = g1 + g2;202 }192 for (int j = 0; j <= refChip->toFPA->x->nY; j++) { 193 double f1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->x->coeff[1][0]*refChip->toFPA->x->coeff[i][j]; 194 double f2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->x->coeff[0][1]*refChip->toFPA->y->coeff[i][j]; 195 toFPA->x->coeff[i][j] = f1 + f2; 196 197 double g1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->y->coeff[1][0]*refChip->toFPA->x->coeff[i][j]; 198 double g2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->y->coeff[0][1]*refChip->toFPA->y->coeff[i][j]; 199 toFPA->y->coeff[i][j] = g1 + g2; 200 } 203 201 } 204 202 toFPA->x->coeff[0][0] += map->x->coeff[0][0]; … … 209 207 obsChip->fromFPA = psPlaneTransformInvert(NULL, obsChip->toFPA, *region, 50); 210 208 psFree (region); 211 209 212 210 // XXX this stuff below should be applied to each readout... 213 211 // XXX for now, just use first readout … … 226 224 // the absolute minimum number of stars is 4 (for order = 1) 227 225 if ((rawstars->n < 4) || (refstars->n < 4)) { 228 readout->data_exists = false;229 psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 230 rawstars->n, refstars->n);231 continue;232 } 226 readout->data_exists = false; 227 psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 228 rawstars->n, refstars->n); 229 continue; 230 } 233 231 234 232 psastroUpdateChipToFPA (input->fpa, obsChip, rawstars, refstars); … … 237 235 psMetadata *updates = psMemIncrRefCounter (psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER")); 238 236 if (!updates) { 239 updates = psMetadataAlloc ();237 updates = psMetadataAlloc (); 240 238 } 241 239 242 240 // XXX update the header with info to reflect the failure 243 241 if (!psastroOneChipFit (input->fpa, obsChip, refstars, rawstars, recipe, updates)) { 244 readout->data_exists = false;245 psLogMsg ("psastro", 3, "failed to find a solution\n");246 psFree (updates);247 continue;242 readout->data_exists = false; 243 psLogMsg ("psastro", 3, "failed to find a solution\n"); 244 psFree (updates); 245 continue; 248 246 } 249 247 … … 253 251 } 254 252 253 psastroVisualPlotFixChips (input, xObs, yObs); 254 psFree (xObs); 255 psFree (yObs); 255 256 psFree (map); 256 257 psFree (view);
Note:
See TracChangeset
for help on using the changeset viewer.
