Changeset 10781
- Timestamp:
- Dec 16, 2006, 11:46:09 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r10775 r10781 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-12-1 6 05:34:54$9 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-12-17 09:46:09 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 312 312 // interpret header WCS (only handles traditional WCS for the moment) 313 313 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units) 314 bool pmAstrom ReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double plateScale, bool isMosaic)314 bool pmAstromWCStoFPA (pmFPA *fpa, pmChip *chip, const pmAstromWCS *wcs, double plateScale, bool isMosaic) 315 315 { 316 316 psPlaneTransform *toFPA; 317 318 pmAstromWCS *wcs = pmAstromWCSfromHeader (header);319 if (!wcs) {320 return false;321 }322 317 323 318 /* at this point, we have extracted from the header the WCS terms in the form of a polynomial, … … 479 474 chip->fromFPA->y->coeff[1][0], chip->fromFPA->y->coeff[0][1]); 480 475 481 psFree (wcs);482 483 476 return true; 484 477 } 485 478 486 // convert toFPA / toSky components to pmAstromWCS , then write to the headers487 // plateScale is nominal physical scale on tangent plane (microns / arcsecond)488 // this requires toTP to be the identity transformation 489 bool pmAstromWriteWCS (psMetadata *header, const pmFPA *fpa, const pmChip *chip) 490 { 491 // tech inically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)479 // convert toFPA / toSky components to pmAstromWCS 480 // tolerance is in pixels 481 pmAstromWCS *pmAstromWCSfromFPA (const pmFPA *fpa, const pmChip *chip, float tol) 482 { 483 484 // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1) 492 485 if (!psPlaneDistortIsDiagonal (fpa->toTPA)) 493 486 psAbort ("psastro", "invalid TPA transformation"); … … 508 501 // crpix1,2 = X,Y(crval1,2) 509 502 // start with linear solution for Xo,Yo: 510 double R = (chip->toFPA->x->coeff[1][0]*chip->toFPA->y->coeff[0][1] - chip->toFPA->x->coeff[0][1]*chip->toFPA->y->coeff[ 0][1]);503 double R = (chip->toFPA->x->coeff[1][0]*chip->toFPA->y->coeff[0][1] - chip->toFPA->x->coeff[0][1]*chip->toFPA->y->coeff[1][0]); 511 504 double Xo = (chip->toFPA->y->coeff[0][0]*chip->toFPA->x->coeff[0][1] - chip->toFPA->x->coeff[0][0]*chip->toFPA->y->coeff[0][1])/R; 512 505 double Yo = (chip->toFPA->x->coeff[0][0]*chip->toFPA->y->coeff[1][0] - chip->toFPA->y->coeff[0][0]*chip->toFPA->x->coeff[1][0])/R; … … 525 518 // XXX this loop is rather arbitrary in length... 526 519 // XXX measure the error and use as criterion 527 for (int i = 0; i < 10; i++) { 520 /* this is the Newton-Raphson method to solve for Xo,Yo - it needs the high order terms to be small */ 521 // Xo,Yo are in pixels; 522 float dPos = tol + 1; 523 for (int i = 0; (dPos > tol) && (i < 10); i++) { 528 524 // NOTE: order is: [y][x] 529 525 Alpha->data.F32[0][0] = psPolynomial2DEval (XdX, Xo, Yo); … … 537 533 psMatrixGJSolveF32 (Alpha, Beta); 538 534 539 Xo += Beta->data.F32[0]; 540 Yo += Beta->data.F32[1]; 535 Xo -= Beta->data.F32[0]; 536 Yo -= Beta->data.F32[1]; 537 dPos = hypot(Xo,Yo); 541 538 } 542 539 psFree (Alpha); … … 595 592 } 596 593 } 597 594 return wcs; 595 } 596 597 // interpret header WCS (only handles traditional WCS for the moment) 598 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units) 599 bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double plateScale, bool isMosaic) 600 { 601 pmAstromWCS *wcs = pmAstromWCSfromHeader (header); 602 if (!wcs) { 603 return false; 604 } 605 606 bool status = pmAstromWCStoFPA (fpa, chip, wcs, plateScale, isMosaic); 607 608 psFree (wcs); 609 return status; 610 } 611 612 // convert toFPA / toSky components to pmAstromWCS, then write to the headers 613 // tolerance is in pixels 614 bool pmAstromWriteWCS (psMetadata *header, const pmFPA *fpa, const pmChip *chip, float tol) 615 { 616 // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY 617 // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY 618 // XXX require chip->toFPA->x->nX == chip->toFPA->y->nX 619 // XXX require chip->toFPA->nX == 1,2,3 620 621 // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1) 622 if (!psPlaneDistortIsDiagonal (fpa->toTPA)) 623 psAbort ("psastro", "invalid TPA transformation"); 624 625 pmAstromWCS *wcs = pmAstromWCSfromFPA(fpa, chip, tol); 598 626 pmAstromWCStoHeader (header, wcs); 599 627
Note:
See TracChangeset
for help on using the changeset viewer.
