Changeset 5510 for trunk/psastro/src/psastroUtils.c
- Timestamp:
- Nov 13, 2005, 1:16:22 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
