Changeset 12519
- Timestamp:
- Mar 21, 2007, 12:00:49 PM (19 years ago)
- Location:
- trunk/psModules/src/astrom
- Files:
-
- 4 edited
-
Makefile.am (modified) (2 diffs)
-
pmAstrometryDistortion.c (modified) (3 diffs)
-
pmAstrometryWCS.c (modified) (8 diffs)
-
pmAstrometryWCS.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/Makefile.am
r10825 r12519 5 5 libpsmodulesastrom_la_SOURCES = \ 6 6 pmAstrometryObjects.c \ 7 pmAstrometryRegions.c \ 7 8 pmAstrometryDistortion.c \ 8 9 pmAstrometryUtils.c \ … … 11 12 pkginclude_HEADERS = \ 12 13 pmAstrometryObjects.h \ 14 pmAstrometryRegions.h \ 13 15 pmAstrometryDistortion.h \ 14 16 pmAstrometryUtils.h \ -
trunk/psModules/src/astrom/pmAstrometryDistortion.c
r12485 r12519 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-03- 18 22:06:58$9 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-03-21 22:00:49 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 29 29 #include "pmFPAExtent.h" 30 30 #include "pmAstrometryObjects.h" 31 #include "pmAstrometryRegions.h" 31 32 #include "pmAstrometryDistortion.h" 32 33 #include "pmKapaPlots.h" … … 317 318 // reset the fromTPA terms here. choose an appropriate region based on the dimensions of 318 319 // the complete FPA 319 psRegion *region = pmFPAExtent (fpa); 320 region->x0 *= pixelScale; 321 region->x1 *= pixelScale; 322 region->y0 *= pixelScale; 323 region->y1 *= pixelScale; 324 int xCenter = 0.5*(region->x0 + region->x1); 325 int yCenter = 0.5*(region->y0 + region->y1); 326 region->x0 -= xCenter; 327 region->x1 -= xCenter; 328 region->y0 -= yCenter; 329 region->y1 -= yCenter; 320 psRegion *region = pmAstromFPAExtent (fpa); 321 330 322 psFree (fpa->fromTPA); 331 323 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50); -
trunk/psModules/src/astrom/pmAstrometryWCS.c
r12483 r12519 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-03- 18 22:05:43$9 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-03-21 22:00:49 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 23 23 #include "pmAstrometryWCS.h" 24 24 #include "pmAstrometryUtils.h" 25 #include "pmAstrometryRegions.h" 25 26 26 27 // the following functions support coordinate transformations direcly related to the FITS WCS … … 83 84 84 85 // convert toFPA / toSky components to traditional WCS 85 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header, double pixelScale) 86 // we require the header to have NAXIS1,NAXIS2, the field of the FPA 87 // the center of the TPA/Sky projection is 0.5*(NAXIS1,NAXIS2) 88 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header) 86 89 { 87 90 pmAstromWCS *wcs = pmAstromWCSfromHeader (header); 88 91 if (!wcs) { 89 return false; 90 } 91 92 bool status = pmAstromWCSBileveltoFPA (fpa, wcs, pixelScale); 92 psError(PS_ERR_UNKNOWN, false, "failure to determine WCS terms from header"); 93 return false; 94 } 95 96 bool status1 = false; 97 bool status2 = false; 98 int Nx = psMetadataLookupS32 (&status1, header, "NAXIS1"); 99 int Ny = psMetadataLookupS32 (&status2, header, "NAXIS2"); 100 if (!status1 || !status2) { 101 psFree (wcs); 102 psError(PS_ERR_UNKNOWN, false, "missing required FPA size in header"); 103 return false; 104 } 105 106 psRegion region = psRegionSet (-0.5*Nx, +0.5*Nx, -0.5*Ny, +0.5*Ny); 107 bool status = pmAstromWCSBileveltoFPA (fpa, wcs, region); 93 108 94 109 psFree (wcs); … … 113 128 pmAstromWCS *wcs = pmAstromWCSBilevelMosaicFromFPA (fpa, tol); 114 129 130 // we need to specify the dimensions of the FPA 131 // if we have chips defined, we can do 132 psRegion *region = pmAstromFPAExtent (fpa); 133 int Nx = region->x1 - region->x0; 134 int Ny = region->y1 - region->y0; 135 psMetadataAddS32 (header, PS_LIST_TAIL, "NAXIS1", PS_META_REPLACE, "Mosaic Dimensions", Nx); 136 psMetadataAddS32 (header, PS_LIST_TAIL, "NAXIS2", PS_META_REPLACE, "Mosaic Dimensions", Ny); 137 115 138 pmAstromWCStoHeader (header, wcs); 116 139 140 psFree (region); 117 141 psFree (wcs); 118 142 return true; … … 442 466 443 467 // free an existing toFPA structure 468 psFree (chip->toFPA); 444 469 chip->toFPA = toFPA; 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; 470 471 // determine the inverse transformation: we need the chip pixels covered by this transform 472 psRegion *region = pmChipPixels (chip); 473 451 474 psFree (chip->fromFPA); 452 chip->fromFPA = psPlaneTransformInvert(NULL, toFPA, *region, 50);475 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 453 476 psFree (region); 454 477 … … 482 505 483 506 // create transformation with 0,0 reference pixel and units of microns/pixel 507 psFree (chip->toFPA); 484 508 chip->toFPA = psPlaneTransformSetCenter (NULL, wcs->trans, -wcs->crpix1, -wcs->crpix2); 485 psRegion *region = pmChipExtent (chip); 486 region->x1 -= region->x0; 487 region->y1 -= region->y0; 488 region->x0 = 0; 489 region->y0 = 0; 509 510 // determine the inverse transformation: we need the chip pixels covered by this transform 511 psRegion *region = pmChipPixels (chip); 512 490 513 psFree (chip->fromFPA); 491 514 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); … … 496 519 497 520 // convert a pmAstromWCS structure representing a bilevel mosaic into corresponding fpa elements 498 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs, double pixelScale)521 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs, psRegion region) 499 522 { 500 523 // projection from TPA (microns) to SKY (radians) … … 513 536 } 514 537 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; 538 // the transformation used the region to define the inversion grid 539 // the region defines the FPA pixels covered by the tranformation 531 540 psFree (fpa->fromTPA); 532 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50); 533 psFree (region); 534 541 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, region, 50); 535 542 return true; 536 543 } -
trunk/psModules/src/astrom/pmAstrometryWCS.h
r12484 r12519 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-03- 18 22:06:09 $6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-03-21 22:00:49 $ 8 8 * Copyright 2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 39 39 // convert from wcs terms to chip->toFPA, fpa->toSky,toTPA terms 40 40 bool pmAstromWCSBileveltoChip (pmChip *chip, const pmAstromWCS *wcs); 41 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs, double pixelScale);41 bool pmAstromWCSBileveltoFPA (pmFPA *fpa, const pmAstromWCS *wcs, psRegion region); 42 42 43 43 // convert from chip->toFPA, fpa->toSky,toTPA terms to wcs terms … … 57 57 58 58 bool pmAstromReadBilevelChip (pmChip *chip, const psMetadata *header); 59 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header , double pixelScale);59 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header); 60 60 61 61 bool pmAstromWriteBilevelChip (psMetadata *header, const pmChip *chip, double tol);
Note:
See TracChangeset
for help on using the changeset viewer.
