Changeset 21025
- Timestamp:
- Dec 17, 2008, 9:12:34 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r20720 r21025 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2008-1 1-13 19:38:16$9 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2008-12-17 19:12:34 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 80 80 81 81 // convert toFPA / toSky components to traditional WCS 82 // we require the header to have NAXIS1,NAXIS2, the field of the FPA 82 // we require the header to have NAXIS1,NAXIS2, the field of the FPA 83 83 // the center of the TPA/Sky projection is 0.5*(NAXIS1,NAXIS2) 84 84 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header) … … 96 96 97 97 if (!status1 || !status2) { 98 Nx = psMetadataLookupS32 (&status1, header, "ZNAXIS1");99 Ny = psMetadataLookupS32 (&status2, header, "ZNAXIS2");98 Nx = psMetadataLookupS32 (&status1, header, "ZNAXIS1"); 99 Ny = psMetadataLookupS32 (&status2, header, "ZNAXIS2"); 100 100 } 101 101 102 102 if (!status1 || !status2) { 103 psFree (wcs);103 psFree (wcs); 104 104 psError(PS_ERR_UNKNOWN, false, "missing required FPA size in header"); 105 105 return false; … … 465 465 } 466 466 467 // apply the exiting fromTPA transformation to make the new toFPA consistent with the toTPA layter468 // XXX this only works if toTPA is at most a linear transformation467 // apply the exiting fromTPA transformation to make the new toFPA consistent with the toTPA layter 468 // XXX this only works if toTPA is at most a linear transformation 469 469 psPlaneTransform *toFPAnew = psPlaneTransformAlloc(toFPA->x->nX, toFPA->x->nY); 470 for (int i = 0; i <= toFPA->x->nX; i++) {471 for (int j = 0; j <= toFPA->x->nY; j++) {472 double f1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[1][0]*toFPA->x->coeff[i][j];473 double f2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[0][1]*toFPA->y->coeff[i][j];474 toFPAnew->x->coeff[i][j] = f1 + f2;475 476 double g1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[1][0]*toFPA->x->coeff[i][j];477 double g2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[0][1]*toFPA->y->coeff[i][j];478 toFPAnew->y->coeff[i][j] = g1 + g2;479 }480 }481 toFPAnew->x->coeff[0][0] += fpa->fromTPA->x->coeff[0][0];482 toFPAnew->y->coeff[0][0] += fpa->fromTPA->y->coeff[0][0];483 484 psFree (toFPA);485 toFPA = toFPAnew;470 for (int i = 0; i <= toFPA->x->nX; i++) { 471 for (int j = 0; j <= toFPA->x->nY; j++) { 472 double f1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[1][0]*toFPA->x->coeff[i][j]; 473 double f2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->x->coeff[0][1]*toFPA->y->coeff[i][j]; 474 toFPAnew->x->coeff[i][j] = f1 + f2; 475 476 double g1 = toFPA->x->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[1][0]*toFPA->x->coeff[i][j]; 477 double g2 = toFPA->y->coeffMask[i][j] ? 0.0 : fpa->fromTPA->y->coeff[0][1]*toFPA->y->coeff[i][j]; 478 toFPAnew->y->coeff[i][j] = g1 + g2; 479 } 480 } 481 toFPAnew->x->coeff[0][0] += fpa->fromTPA->x->coeff[0][0]; 482 toFPAnew->y->coeff[0][0] += fpa->fromTPA->y->coeff[0][0]; 483 484 psFree (toFPA); 485 toFPA = toFPAnew; 486 486 487 487 // adjust reference pixel for new toSky reference coordinate … … 492 492 psSphere *sky = psSphereAlloc(); 493 493 494 sky->r = toSky->R;495 sky->d = toSky->D;494 sky->r = toSky->R; 495 sky->d = toSky->D; 496 496 psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 497 497 psPlaneTransformApply (fpOld, fpa->fromTPA, tp); 498 498 499 sky->r = fpa->toSky->R;500 sky->d = fpa->toSky->D;499 sky->r = fpa->toSky->R; 500 sky->d = fpa->toSky->D; 501 501 psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 502 502 psPlaneTransformApply (fpNew, fpa->fromTPA, tp); … … 595 595 pmAstromWCS *pmAstromWCSfromFPA (const pmFPA *fpa, const pmChip *chip, double tol) 596 596 { 597 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 598 PS_ASSERT_PTR_NON_NULL(chip, NULL); 599 PS_ASSERT_PTR_NON_NULL(fpa->toFPA, NULL); 600 PS_ASSERT_PTR_NON_NULL(fpa->toTPA, NULL); 601 597 602 // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY 598 603 // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY … … 607 612 // create a temporary transform which combines toTPA and toFPA. allow toTPA to have 0th 608 613 // and 1st order terms 609 614 610 615 // XXX require fpa->toTPA->x->nX == fpa->toTPA->x->nY 611 616 // XXX require fpa->toTPA->y->nX == fpa->toTPA->y->nY … … 618 623 619 624 for (int i = 0; i <= toTPA->x->nX; i++) { 620 for (int j = 0; j <= toTPA->x->nY; j++) {621 double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j];622 double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j];623 toTPA->x->coeff[i][j] = f1 + f2;624 625 double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j];626 double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j];627 toTPA->y->coeff[i][j] = g1 + g2;628 }625 for (int j = 0; j <= toTPA->x->nY; j++) { 626 double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j]; 627 double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j]; 628 toTPA->x->coeff[i][j] = f1 + f2; 629 630 double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j]; 631 double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j]; 632 toTPA->y->coeff[i][j] = g1 + g2; 633 } 629 634 } 630 635 toTPA->x->coeff[0][0] += fpa->toTPA->x->coeff[0][0]; … … 641 646 psPlane *center = psPlaneTransformGetCenter (toTPA, tol); 642 647 if (!center) { 643 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");644 psFree (toTPA);645 psFree (wcs);646 return NULL;648 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center."); 649 psFree (toTPA); 650 psFree (wcs); 651 return NULL; 647 652 } 648 653 … … 703 708 psPlane *center = psPlaneTransformGetCenter (chip->toFPA, tol); 704 709 if (!center) { 705 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");706 psFree (wcs);707 return NULL;710 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center."); 711 psFree (wcs); 712 return NULL; 708 713 } 709 714 … … 744 749 psPlane *center = psPlaneTransformGetCenter (fpa->toTPA, tol); 745 750 if (!center) { 746 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center.");747 psFree (wcs);748 return NULL;751 psError(PS_ERR_UNKNOWN, false, "Unable to solve for TPA center."); 752 psFree (wcs); 753 return NULL; 749 754 } 750 755 … … 801 806 802 807 /***** 803 808 804 809 For mosaic astrometry, we need to have a starting set of projection terms in which the 805 810 chip-to-FPA terms result in a fixed physical unit on the focal plane (eg, pixels or … … 814 819 the chip-to-FPA scaling (eg, pc11) to match the variations in the effective plate scale for 815 820 each chip (eg, cdelt1). Thus, we need to carry around both the 816 821 817 822 *****/ 818 823 … … 821 826 L,M: coord on the focal plane (pixels) 822 827 P,Q: coord in the tangent plane (microns or mm?) 823 R,D: coord on the sky 824 828 R,D: coord on the sky 829 825 830 this function creates WCS terms which convert directly from chip to sky. 826 831 this function requires a linear, unrotated toTPA distortion term … … 830 835 831 836 /* at this point, we have extracted from the header the WCS terms in the form of a polynomial, 832 * wcs->trans, which will convert X,Y in pixels to L,M in degrees. we also have the following 837 * wcs->trans, which will convert X,Y in pixels to L,M in degrees. we also have the following 833 838 * elements defined: 834 839 * type (projection type) 835 840 * crval1,2 (in RA,DEC degrees) 836 * crpix1,2 841 * crpix1,2 837 842 * cdelt1,2 (in degrees / pixel) 838 843 * pixelScale (microns / pixel) 839 * 844 * 840 845 * now we convert wcs->trans to toFPA, which is different from wcs->trans in 3 important ways: 841 846 * 1) the output is in microns (not degrees): divide by cdelt1,2
Note:
See TracChangeset
for help on using the changeset viewer.
