Changeset 10829 for trunk/psModules/src/astrom/pmAstrometryWCS.c
- Timestamp:
- Dec 24, 2006, 3:49:50 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryWCS.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryWCS.c
r10825 r10829 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-12-2 2 21:23:06$9 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-12-25 01:49:49 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 32 32 33 33 // interpret header WCS (only handles traditional WCS for the moment) 34 // p lateScale is nominal physical scale on tangent plane (radians / TPA physical units)35 bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double p lateScale)34 // pixelScale is microns per pixel 35 bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double pixelScale) 36 36 { 37 37 pmAstromWCS *wcs = pmAstromWCSfromHeader (header); … … 40 40 } 41 41 42 bool status = pmAstromWCStoFPA (fpa, chip, wcs, p lateScale);42 bool status = pmAstromWCStoFPA (fpa, chip, wcs, pixelScale); 43 43 44 44 psFree (wcs); … … 67 67 68 68 // interpret chip header WCS as bilevel chip components 69 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units)70 69 bool pmAstromReadBilevelChip (pmChip *chip, const psMetadata *header) 71 70 { … … 82 81 83 82 // convert toFPA / toSky components to traditional WCS 84 // plateScale is nominal physical scale on tangent plane (microns / arcsecond)85 83 bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header) 86 84 { … … 359 357 360 358 // interpret header WCS (only handles traditional WCS for the moment) 361 // p lateScale is nominal physical scale on tangent plane (radians / TPA physical units)362 bool pmAstromWCStoFPA (pmFPA *fpa, pmChip *chip, const pmAstromWCS *wcs, double p lateScale)359 // pixelScale is the pixel size in microns per pixel 360 bool pmAstromWCStoFPA (pmFPA *fpa, pmChip *chip, const pmAstromWCS *wcs, double pixelScale) 363 361 { 364 362 psPlaneTransform *toFPA; … … 367 365 * wcs->trans, which will convert X,Y in pixels to L,M in degrees. we also have the following 368 366 * elements defined: 369 * type ( CTYPE)367 * type (projection type) 370 368 * crval1,2 (in RA,DEC degrees) 371 369 * crpix1,2 372 370 * cdelt1,2 (in degrees / pixel) 373 * p lateScale (radians / physical TPA units)371 * pixelScale (microns / pixel) 374 372 * 375 373 * now we convert wcs->trans to toFPA, which is different from wcs->trans in 3 important ways: 376 * 1) the output is in pixels (not degrees): divide by cdelt1,2 raised to an appropriate power374 * 1) the output is in microns (not degrees): divide by cdelt1,2 377 375 * 2) X,Y are applied directly, without an applied Xo,Yo offset 378 376 * 3) there is an allowed Lo,Mo term ([0][0] coefficients) 379 377 */ 380 378 381 // convert wcs->trans to a matrix which yields L,M in pixels382 double cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);383 double cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]);384 for (int i = 0; i <= wcs->trans->x->nX; i++) {385 for (int j = 0; j <= wcs->trans->x->nX; j++) {386 wcs->trans->x->coeff[i][j] /= cdelt1;387 wcs->trans->y->coeff[i][j] /= cdelt2;388 }389 }390 391 379 // create transformation with 0,0 reference pixel 392 380 toFPA = psPlaneTransformSetCenter (NULL, wcs->trans, -wcs->crpix1, -wcs->crpix2); 393 381 394 // scale from FPA to TPA (microns / pixel) 395 double pdelt1 = cdelt1*PM_RAD_DEG / plateScale; 396 double pdelt2 = cdelt2*PM_RAD_DEG / plateScale; 382 // modify scale of toFPA to yield L,M in microns 383 double cdelt1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]); 384 double cdelt2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]); 385 for (int i = 0; i <= toFPA->x->nX; i++) { 386 for (int j = 0; j <= toFPA->x->nX; j++) { 387 toFPA->x->coeff[i][j] *= pixelScale/cdelt1; 388 toFPA->y->coeff[i][j] *= pixelScale/cdelt2; 389 } 390 } 391 392 // scale from FPA to TPA (degrees / micron) 393 double pdelt1 = cdelt1 / pixelScale; 394 double pdelt2 = cdelt2 / pixelScale; 397 395 float rX = 1.0; 398 396 float rY = 1.0; 399 397 400 // projection from TPA to SKY401 psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, plateScale, plateScale, wcs->toSky->type);398 // projection from TPA ("linear" degrees) to SKY (radians) 399 psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, PM_RAD_DEG, PM_RAD_DEG, wcs->toSky->type); 402 400 403 401 if (fpa->toSky == NULL) { … … 558 556 559 557 // cdelt1,2 convert from pixels->degrees 560 double cdelt1 = fpa->toTPA->x->coeff[1][0] *fpa->toSky->Xs*PM_DEG_RAD;561 double cdelt2 = fpa->toTPA->y->coeff[0][1] *fpa->toSky->Ys*PM_DEG_RAD;558 double cdelt1 = fpa->toTPA->x->coeff[1][0]; 559 double cdelt2 = fpa->toTPA->y->coeff[0][1]; 562 560 wcs->cdelt1 = cdelt1; 563 561 wcs->cdelt2 = cdelt2;
Note:
See TracChangeset
for help on using the changeset viewer.
