Changeset 5510
- Timestamp:
- Nov 13, 2005, 1:16:22 PM (21 years ago)
- Location:
- trunk/psastro
- Files:
-
- 2 added
- 6 edited
-
doc (added)
-
doc/notes.txt (added)
-
src/pmAstrom.c (modified) (4 diffs)
-
src/pmAstrom.h (modified) (2 diffs)
-
src/pmAstromGrid.c (modified) (4 diffs)
-
src/psastro.c (modified) (1 diff)
-
src/psastroBuildFPA.c (modified) (1 diff)
-
src/psastroUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/pmAstrom.c
r5495 r5510 54 54 } 55 55 56 pmAstromMatchedListFit (pmFPA *fpa, psArray *st1, psArray *st2, psArray *match, psMetadata *config) { 56 // take two matched star lists and fit a psPlaneTransform between them 57 // 58 psPlaneTransform *pmAstromMatchedListFit (psPlaneTransform *map, psArray *st1, psArray *st2, psArray *match, psMetadata *config) { 59 60 if (map == NULL) { 61 // int nX = psMetadataLookupS32 (&status, myHeader, "CHIP.NX"); 62 // int nY = psMetadataLookupS32 (&status, myHeader, "CHIP.NY"); 63 map = psPlaneTransform (2, 2); 64 } 65 66 psStats *stats = psStatsAlloc (CLIPPED_MEAN); 67 stats->nSigma = psMetadataLookupS32 (&status, myHeader, "CHIP.NITER"); 68 stats->nSigma = psMetadataLookupS32 (&status, myHeader, "CHIP.NSIGMA"); 57 69 58 70 psVector *X = psVectorAlloc (match->n); … … 62 74 63 75 // take the matched stars, first fit 64 for (i = 0; i < match->n; i++) {76 for (int i = 0; i < match->n; i++) { 65 77 66 78 pair = match->data[i]; … … 68 80 ob2 = st2->data[pair->i2]; 69 81 70 X->data.F64[i] = ob1-> P;71 Y->data.F64[i] = ob1-> Q;82 X->data.F64[i] = ob1->chip.x; 83 Y->data.F64[i] = ob1->chip.y; 72 84 73 x->data.F64[i] = ob2->P; 74 y->data.F64[i] = ob2->Q; 75 76 // use one or the other... 77 psPolynomial2D *xt = psVectorFitPolynomial2D (NULL, stats, NULL, 0, X, NULL, x, y); 78 psPolynomial2D *xt = psVectorClipFitPolynomial2D (NULL, stats, NULL, 0, X, NULL, x, y); 79 80 psPolynomial2D *yt = psVectorFitPolynomial2D (NULL, stats, NULL, 0, Y, NULL, x, y); 81 psPolynomial2D *yt = psVectorClipFitPolynomial2D (NULL, stats, NULL, 0, Y, NULL, x, y); 85 x->data.F64[i] = ob2->FP.x; 86 y->data.F64[i] = ob2->FP.y; 82 87 } 83 88 84 // apply fitted polynomials to fpa 89 // no masking, no errors 90 psVectorClipFitPolynomial2D (map->x, stats, NULL, 0, X, NULL, x, y); 91 psVectorClipFitPolynomial2D (map->y, stats, NULL, 0, Y, NULL, x, y); 92 psFree (x); 93 psFree (y); 94 psFree (X); 95 psFree (Y); 96 psFree (stats); 97 98 return (map); 85 99 } 86 100 … … 103 117 newObj = pmAstromObjCopy (oldObj); 104 118 105 P= oldObj->FP.x - xCenter;106 Q= oldObj->FP.y - yCenter;119 X = oldObj->FP.x - xCenter; 120 Y = oldObj->FP.y - yCenter; 107 121 108 newObj->FP.x = P*cs + Q*sn;109 newObj->FP.y = Q*cs - P*sn;122 newObj->FP.x = X*cs + Y*sn; 123 newObj->FP.y = Y*cs - X*sn; 110 124 111 125 new->data[i] = newObj; -
trunk/psastro/src/pmAstrom.h
r5360 r5510 7 7 8 8 typedef struct { 9 double X, Y; 10 double P, Q; 11 double L, M; 12 double R, D; 9 psPlane pix; 10 psPlane cell; 11 psPlane chip; 12 psPlane FP; 13 psPlane TP; 14 psSphere sky; 13 15 double Mag, dMag; 14 16 } pmAstromObj; … … 26 28 27 29 typedef struct { 30 psPlane center; 31 psPlane offset; 28 32 double angle; 29 double dP;30 double dQ;31 33 double minMetric; 32 34 double minVar; -
trunk/psastro/src/pmAstromGrid.c
r5495 r5510 47 47 st2r = pmAstromRotateObj (st2, center, angle); 48 48 newStat = pmAstromGridMatchAngle (st1, st2r, config); 49 newStat.angle = angle; 49 newStat.angle = angle; 50 newStat.center = center; 50 51 if (newStat.minMetric < minStat.minMetric) { 51 52 minStat = newStat; … … 147 148 minMetric = metric; 148 149 minVar = var; 149 min P= i;150 min Q= j;150 minX = i; 151 minY = j; 151 152 } 152 153 } … … 154 155 155 156 // convert the bin to delta-delta 156 matchStats. dX= DP[minY][minX] / NP[minY][minX];157 matchStats. dY= DQ[minY][minX] / NP[minY][minX];157 matchStats.offset.x = DP[minY][minX] / NP[minY][minX]; 158 matchStats.offset.y = DQ[minY][minX] / NP[minY][minX]; 158 159 matchStats.minMetric = minMetric; 159 160 matchStats.minVar = minVar; … … 164 165 165 166 // apply the measured FPA offset and rotation (stat) to the fpa astrom structures 166 psFPA *pmAstrom ApplyGridMatch (psFPA *fpa, pmAstromGridMatchStat stat) {167 psFPA *pmAstromGridApply (psPlaneTransform *map, pmAstromGridMatchStat stat) { 167 168 168 // stat.angle modifies fpa.toTangentPlane (effective angle)169 // stat.dP, stat.dQ modifies fpa.projection (Ro, Do)169 // stat.angle, stat.center, stat.offse 170 // I think i need to know the center reference.... 170 171 171 172 return (fpa); -
trunk/psastro/src/psastro.c
r5509 r5510 22 22 psastroProjectRawstars (subset); 23 23 24 // load the corresponding reference data (DVO command)25 psArray *refstars = psastroLoadReference (argv[3]);26 27 // use the header & config info to project refstars on the focal plane28 psastroProjectRefstars (refstars, subset);29 30 24 // fpa and subset point to the same astrometry terms 31 psastroChipAstrom ( refstars, subset);25 psastroChipAstrom (subset, config); 32 26 33 27 // write out data (cmp file) -
trunk/psastro/src/psastroBuildFPA.c
r5509 r5510 136 136 // set toChip to identity as default 137 137 // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581) 138 // XXX EAM : define these in the config? 139 // int nX = psMetadataLookupS32 (&status, myHeader, "CHIP.NX"); 140 // int nY = psMetadataLookupS32 (&status, myHeader, "CHIP.NY"); 138 141 cell->toChip = psPlaneTransformAlloc (2, 2); 139 142 cell->toChip->x->coeff[1][0] = 1; -
trunk/psastro/src/psastroUtils.c
r5509 r5510 197 197 } 198 198 199 bool psastroProject Rawstars (pmFPA *fpa) {199 bool psastroProjectFPA (pmFPA *fpa, bool toSky) { 200 200 201 201 for (int i = 0; i < fpa->chips->n; i++) { … … 205 205 for (int k = 0; k < cell->readouts->n; k++) { 206 206 pmReadout *readout = cell->readouts->data[k]; 207 for (int m = 0; m < readout->stars->n; m++) { 208 pmAstromObj *star = readout->data[m]; 209 // apply readout offsets 210 // apply cell PlaneTransform 211 // apply chip PlaneTransform 212 psPlaneTransformApply (star-> 213 214 } 215 chip->cells->data[j] = cell; 216 } 217 fpa->chips->data[i] = chip; 218 } 219 return (fpa); 207 if (toSky) { 208 psastroProjectRawstars (readout->stars, readout); 209 } else { 210 psastroProjectRefstars (readout->stars, readout); 211 } 212 } 213 } 214 } 215 return true; 220 216 } 221 217 222 bool psastroChipAstrom (psArray *refstars, pmFPA *subset) { 223 224 // do this loop over the readouts 225 226 // find initial offset / rotation 227 stat = pmAstromGridMatch (subset, refstars, config); 228 229 pmAstromModifyFPA (fpa, stat); 230 231 // use fit result to re-project rawstars 232 psastroProjectRawstars (fpa, subset); 233 psastroProjectRefstars (fpa, refstars); 218 bool psastroProjectRawstars (psArray *stars, pmReadout *readout) { 219 220 pmCell *cell = readout->cell; 221 pmChip *chip = cell->chip; 222 pmFPA *fpa = chip->cell; 223 224 for (int i = 0; i < readout->stars->n; i++) { 225 pmAstromObj *star = readout->stars->data[i]; 226 psCoordReadoutToCell (&star->cell, &star->pix, readout); 227 psCoordCellToChip (&star->chip, &star->cell, cell); 228 psCoordChipToFP (&star->FP, &star->chip, chip); 229 psCoordFPtoTP (&star->TP, &star->FP, fpa); 230 psCoordTPtoSky (&star->sky, &star->TP, fpa); 231 } 232 return true; 233 } 234 235 bool psastroProjectRefstars (psArray *stars, pmReadout *readout) { 236 237 pmCell *cell = readout->cell; 238 pmChip *chip = cell->chip; 239 pmFPA *fpa = chip->cell; 240 241 for (int i = 0; i < stars->n; i++) { 242 pmAstromObj *star = stars->data[i]; 243 244 psCoordSkytoTP (&star->TP, &star->sky, fpa); 245 psCoordTPtoFP (&star->FP, &star->TP, fpa); 246 psCoordFPtoChip (&star->chip, &star->FP, chip); 247 psCoordChipToCell (&star->cell, &star->chip, cell); 248 psCoordReadoutToCell (&star->pix, &star->cell, readout); 249 } 250 return true; 251 } 252 253 // measure per-chip astrometry terms 254 bool psastroChipAstrom (pmFPA *fpa, psMetadata *config) { 255 256 pmFPA *raw = pmFPACopy (fpa); 257 258 // first pass: measure the per-chip solutions, modify the chip.toFPA terms 259 for (int i = 0; i < fpa->chips->n; i++) { 260 pmChip *chip = fpa->chips->data[i]; 261 262 // cells->n > 1 is not yet well-defined 263 if (chip->cells->n > 1) { 264 psLogMsg ("pmSourcesReadCMP", 3, "undefined behavior for nCells > 1"); 265 return false; 266 } 267 268 for (int j = 0; j < chip->cells->n; j++) { 269 pmCell *cell = chip->cells->data[j]; 270 271 // readouts->n > 1 is not yet well-defined 272 if (cell->readouts->n > 1) { 273 psLogMsg ("pmSourcesReadCMP", 3, "undefined behavior for nReadouts > 1"); 274 return false; 275 } 276 277 // load the corresponding reference data (DVO command) 278 psArray *refstars = psastroLoadReference (cell->header, config); 279 280 for (int k = 0; k < cell->readouts->n; k++) { 281 282 pmReadout *readout = cell->readouts->data[k]; 283 284 // use the header & config info to project refstars on the focal plane 285 psastroProjectRefstars (refstars, readout); 286 287 // find initial offset / rotation 288 stat = pmAstromGridMatch (readout->stars, refstars, config); 289 290 // adjust the chip.toFPA terms only 291 pmAstromGridApply (chip->toFPA, stat); 292 293 // use fit result to re-project rawstars 294 psastroProjectRawstars (readout->stars, readout); 295 psastroProjectRefstars (refstars, readout); 234 296 235 // use small radius to match stars 236 match = pmAstromRadiusMatch (rawstars, refstars, options); 237 238 // fit astrometric terms 239 output = pmAstromMatchedListFit (fpa, subset, refstars, match, options); 240 } 241 297 // use small radius to match stars 298 match = pmAstromRadiusMatch (rawstars, refstars, options); 299 300 // fit astrometric terms 301 pmAstromMatchedListFit (chip->toFPA, readout->stars, refstars, match, options); 302 } 303 } 304 } 305 306 // second stage: re-normalize the chip terms, passing the 307 // average rotation and offset values to the fpa.toSky 308 309 # if (0) 310 // code disabled for now 311 // this is not as trivial as it seems at first: 312 // applying a new rotation to the FPA implies changes to the 313 // (x,y) reference coordinates for the chips as well as a rotation 314 // I need to calculate both the x,y offset effect and the rotation 315 // in one step. what about the effect of higher order terms in either 316 // the chip.toFPA or the fpa.toTPA? 317 // this calculation also needs to account for scale effects between the 318 // fpa and the chips. 319 320 // calculate the average rotation and boresite offset relative to raw 321 for (int i = 0; i < fpa->chips->n; i++) { 322 pmChip *iChip = raw->chips->data[i]; 323 pmChip *oChip = fpa->chips->data[i]; 324 325 T1 = psPlaneTransformGetRotation (iChip->toFPA); 326 T2 = psPlaneTransformGetRotation (oChip->toFPA); 327 dT += T1 - T2; 328 dN ++; 329 330 331 } 332 333 dT /= dN; 334 335 psPlaneTransformSetRotation (fpa->toTPA, dT); 336 337 // apply the new modifcations in rotation and boresite 338 for (int i = 0; i < fpa->chips->n; i++) { 339 pmChip *iChip = raw->chips->data[i]; 340 pmChip *oChip = fpa->chips->data[i]; 341 342 psPlaneTransformSetRotation (oChip->toFPA, -dT); 343 } 344 # endif 345 }
Note:
See TracChangeset
for help on using the changeset viewer.
