Changeset 12483 for trunk/psModules/src/astrom/pmAstrometryWCS.c
- Timestamp:
- Mar 18, 2007, 12:05:43 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r11687 r12483 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-0 2-07 23:58:17$9 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-03-18 22:05:43 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 20 20 #include <pslib.h> 21 21 #include "pmFPA.h" 22 #include "pmFPAExtent.h" 22 23 #include "pmAstrometryWCS.h" 23 24 #include "pmAstrometryUtils.h" … … 82 83 83 84 // convert toFPA / toSky components to traditional WCS 84 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header )85 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header, double pixelScale) 85 86 { 86 87 pmAstromWCS *wcs = pmAstromWCSfromHeader (header); … … 89 90 } 90 91 91 bool status = pmAstromWCSBileveltoFPA (fpa, wcs );92 bool status = pmAstromWCSBileveltoFPA (fpa, wcs, pixelScale); 92 93 93 94 psFree (wcs); … … 404 405 double rX = toSky->Xs / fpa->toSky->Xs; 405 406 double rY = toSky->Ys / fpa->toSky->Ys; 407 406 408 for (int i = 0; i <= fpa->toTPA->x->nX; i++) { 407 409 for (int j = 0; j <= fpa->toTPA->x->nY; j++) { … … 411 413 } 412 414 413 // adjust for common toSky, toTPA for mosaic:415 // adjust reference pixel for new toSky reference coordinate 414 416 // find the FPA coordinate of 0,0 for this chip. 415 psPlane * chip= psPlaneAlloc();416 psPlane *fp = psPlaneAlloc();417 psPlane *fpOld = psPlaneAlloc(); 418 psPlane *fpNew = psPlaneAlloc(); 417 419 psPlane *tp = psPlaneAlloc(); 418 420 psSphere *sky = psSphereAlloc(); 419 chip->x = chip->y = 0; 420 421 psPlaneTransformApply (fp, toFPA, chip); // find the focal-plane coordinate of this chip's 0,0 coordinate 422 psPlaneTransformApply (tp, fpa->toTPA, fp); 423 psDeproject (sky, tp, toSky); // find the RA,DEC coord of the focal-plane coordinate 421 422 sky->r = toSky->R; 423 sky->d = toSky->D; 424 424 psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 425 psPlaneTransformApply (fp, fpa->fromTPA, tp); 426 427 toFPA->x->coeff[0][0] = fp->x; 428 toFPA->y->coeff[0][0] = fp->y; 425 psPlaneTransformApply (fpOld, fpa->fromTPA, tp); 426 427 sky->r = fpa->toSky->R; 428 sky->d = fpa->toSky->D; 429 psProject (tp, sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 430 psPlaneTransformApply (fpNew, fpa->fromTPA, tp); 431 432 toFPA->x->coeff[0][0] -= fpNew->x - fpOld->x; 433 toFPA->y->coeff[0][0] -= fpNew->y - fpOld->y; 429 434 430 435 psFree (sky); 431 436 psFree (tp); 432 psFree (fp); 433 psFree (chip); 437 psFree (fpOld); 438 psFree (fpNew); 439 434 440 psFree (toSky); 435 441 } … … 437 443 // free an existing toFPA structure 438 444 chip->toFPA = toFPA; 439 // XXX this needs to perform the full (non-linear) inversion 440 // XXX we need to pull the region from the chip metadata 441 // is chip trimsec defined? do we need to ensure the 442 // XXX should this function be defined for the CELL, not the CHIP? 443 // psRegion region = psMetadataLookupXXX (chip->concepts, "CHIP.TRIMSEC"); 444 psRegion region = psRegionSet (0, 4000, 0, 4000); 445 chip->fromFPA = psPlaneTransformInvert(NULL, toFPA, region, 50); 445 // NOTE that region specifies the FP region in PIXELS covered by the chip 446 psRegion *region = pmChipExtent (chip); 447 region->x1 -= region->x0; 448 region->y1 -= region->y0; 449 region->x0 = 0; 450 region->y0 = 0; 451 psFree (chip->fromFPA); 452 chip->fromFPA = psPlaneTransformInvert(NULL, toFPA, *region, 50); 453 psFree (region); 446 454 447 455 // this can take a very long time... … … 475 483 // create transformation with 0,0 reference pixel and units of microns/pixel 476 484 chip->toFPA = psPlaneTransformSetCenter (NULL, wcs->trans, -wcs->crpix1, -wcs->crpix2); 477 478 // XXX this needs to perform the full (non-linear) inversion479 // XXX we need to pull the region from the chip metadata480 // is chip trimsec defined? do we need to ensure the481 // XXX should this function be defined for the CELL, not the CHIP?482 // psRegion region = psMetadataLookupXXX (chip->concepts, "CHIP.TRIMSEC");483 psRegion region = psRegionSet (0, 4000, 0, 4000);484 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, region, 50);485 psRegion *region = pmChipExtent (chip); 486 region->x1 -= region->x0; 487 region->y1 -= region->y0; 488 region->x0 = 0; 489 region->y0 = 0; 490 psFree (chip->fromFPA); 491 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 492 psFree (region); 485 493 486 494 return true; … … 488 496 489 497 // convert a pmAstromWCS structure representing a bilevel mosaic into corresponding fpa elements 490 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs )498 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs, double pixelScale) 491 499 { 492 500 // projection from TPA (microns) to SKY (radians) … … 505 513 } 506 514 507 // XXX this needs to perform the full (non-linear) inversion 508 // XXX we need to pull the region from the chip metadata 509 // is chip trimsec defined? do we need to ensure the 510 // XXX should this function be defined for the CELL, not the CHIP? 511 // psRegion region = psMetadataLookupXXX (chip->concepts, "CHIP.TRIMSEC"); 512 psRegion region = psRegionSet (0, 4000, 0, 4000); 513 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, region, 50); 515 // XXX this is still wrong: the pmFPAExtent function returns the FP dimensions in pixel units 516 // relative to the 0,0 corner of chip 0,0. for now, just recenter... 517 // XXX I need to have a function which loops over all cells, determines the pixel dimensions 518 // for each cell, converts them to chip pixels, then uses the fpa astrometry structures 519 // to get the total dimensions of the fpa in fpa units. equivalent to pmFPAExtent 520 psRegion *region = pmFPAExtent (fpa); 521 region->x0 *= pixelScale; 522 region->x1 *= pixelScale; 523 region->y0 *= pixelScale; 524 region->y1 *= pixelScale; 525 int xCenter = 0.5*(region->x0 + region->x1); 526 int yCenter = 0.5*(region->y0 + region->y1); 527 region->x0 -= xCenter; 528 region->x1 -= xCenter; 529 region->y0 -= yCenter; 530 region->y1 -= yCenter; 531 psFree (fpa->fromTPA); 532 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50); 533 psFree (region); 514 534 515 535 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
