Changeset 15896
- Timestamp:
- Dec 22, 2007, 7:52:57 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r15254 r15896 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-1 0-09 19:27:04$9 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-12-22 17:52:57 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 56 56 bool pmAstromWriteWCS (psMetadata *header, const pmFPA *fpa, const pmChip *chip, double tol) 57 57 { 58 // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY59 // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY60 // XXX require chip->toFPA->x->nX == chip->toFPA->y->nX61 // XXX require chip->toFPA->nX == 1,2,362 63 // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)64 if (!psPlaneTransformIsDiagonal (fpa->toTPA))65 psAbort("invalid TPA transformation");66 67 58 pmAstromWCS *wcs = pmAstromWCSfromFPA(fpa, chip, tol); 59 if (!wcs) return false; 60 68 61 pmAstromWCStoHeader (header, wcs); 69 62 … … 118 111 { 119 112 pmAstromWCS *wcs = pmAstromWCSBilevelChipFromFPA (chip, tol); 120 121 113 pmAstromWCStoHeader (header, wcs); 122 114 … … 337 329 char *type; 338 330 331 if (!wcs) return false; 332 339 333 type = psProjectTypeToString (wcs->toSky->type, "RA--"); 340 334 psMetadataAddStr (header, PS_LIST_TAIL, "CTYPE1", PS_META_REPLACE, "", type); … … 385 379 } 386 380 387 return (true);381 return true; 388 382 } 389 383 … … 550 544 pmAstromWCS *pmAstromWCSfromFPA (const pmFPA *fpa, const pmChip *chip, double tol) 551 545 { 552 553 // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)554 // XXX not really: toTPA needs to have unity scale for distortion fitting function555 if (!psPlaneTransformIsDiagonal (fpa->toTPA))556 psAbort("invalid TPA transformation");557 558 546 // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY 559 547 // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY … … 561 549 // XXX require chip->toFPA->nX == 1,2,3 562 550 563 pmAstromWCS *wcs = pmAstromWCSAlloc(chip->toFPA->x->nX, chip->toFPA->x->nY); 551 // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1) 552 // XXX not really: toTPA needs to have unity scale for distortion fitting function 553 // if (!psPlaneTransformIsDiagonal (fpa->toTPA)) 554 // psAbort("invalid TPA transformation"); 555 556 // create a temporary transform which combines toTPA and toFPA. allow toTPA to have 0th 557 // and 1st order terms 558 559 // XXX require fpa->toTPA->x->nX == fpa->toTPA->x->nY 560 // XXX require fpa->toTPA->y->nX == fpa->toTPA->y->nY 561 // XXX require fpa->toTPA->x->nX == fpa->toTPA->y->nX 562 // XXX require fpa->toTPA->x->coeffMask[1][1] 563 // XXX require fpa->toTPA->y->coeffMask[1][1] 564 // XXX require fpa->toTPA->nX == 1 565 566 psPlaneTransform *toTPA = psPlaneTransformAlloc(chip->toFPA->x->nX, chip->toFPA->x->nY); 567 568 for (int i = 0; i <= toTPA->x->nX; i++) { 569 for (int j = 0; j <= toTPA->x->nY; j++) { 570 double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j]; 571 double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j]; 572 toTPA->x->coeff[i][j] = f1 + f2; 573 574 double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j]; 575 double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j]; 576 toTPA->y->coeff[i][j] = g1 + g2; 577 } 578 } 579 toTPA->x->coeff[0][0] += fpa->toTPA->x->coeff[0][0]; 580 toTPA->y->coeff[0][0] += fpa->toTPA->y->coeff[0][0]; 581 582 pmAstromWCS *wcs = pmAstromWCSAlloc(toTPA->x->nX, toTPA->x->nY); 564 583 565 584 // convert projection from FPA to SKY into wcs projection (degrees to radians) … … 569 588 570 589 // given transformation, solve for coordinates which yields output coordinates of 0,0 571 psPlane *center = psPlaneTransformGetCenter ( chip->toFPA, tol);590 psPlane *center = psPlaneTransformGetCenter (toTPA, tol); 572 591 573 592 // create wcs transform from toFPA, resulting transformation has units of microns/pixel 574 593 // adjust wcs transform to use center as reference coordinate 575 psPlaneTransformSetCenter (wcs->trans, chip->toFPA, center->x, center->y);594 psPlaneTransformSetCenter (wcs->trans, toTPA, center->x, center->y); 576 595 577 596 // calculated center is crpix1,2 … … 595 614 wcs->cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]); 596 615 wcs->cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]); 616 617 psFree (toTPA); 597 618 598 619 return wcs;
Note:
See TracChangeset
for help on using the changeset viewer.
