Changeset 27838 for branches/tap_branches/pstamp/src/ppstampMakeStamp.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamp/src/ppstampMakeStamp.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/pstamp/src/ppstampMakeStamp.c
r25817 r27838 17 17 18 18 static void skyToChip(pmAstromObj *pt, pmFPA *fpa, pmChip *chip); 19 static void chipToSky(pmAstromObj *pt, pmFPA *fpa, pmChip *chip); 19 20 static bool setMaskedToNAN(pmConfig *config, psImage *image, psImage *mask, psImage *variance); 20 21 21 22 // convert the input chip's transforms to the output 22 static bool convertWCS(pmHDU *outHDU, pmFPA *outFPA, pmChip *outChip, pmChip *inChip, psRegion *roi) 23 { 24 pmHDU *hdu = pmHDUFromChip(inChip); 25 PS_ASSERT_PTR_NON_NULL(hdu, 1) 26 PS_ASSERT_PTR_NON_NULL(hdu->header, 1) 27 28 // Change the reference pixel to account for the change in origin between the stamp and 29 // the original image 30 // XXX: shouldn't we be using the center of the stamp instead of the corner? 31 outChip->toFPA = psPlaneTransformSetCenter(NULL, inChip->toFPA, (int) roi->x0, (int) roi->y0); 32 33 outChip->fromFPA = psPlaneTransformInvert(NULL, outChip->toFPA, *roi, 50); 23 static bool convertWCS(pmHDU *outHDU, pmFPA *inFPA, pmChip *inChip, pmFPA *outFPA, pmChip *outChip, psRegion *roi) 24 { 25 PS_ASSERT_PTR_NON_NULL(outHDU, 1); 26 PS_ASSERT_PTR_NON_NULL(outHDU->header, 1); 27 28 // Center of stamp in chip coordinates 29 double center_x = (roi->x0 + roi->x1) / 2; 30 double center_y = (roi->y0 + roi->y1) / 2; 31 pmAstromObj *check = pmAstromObjAlloc(); 32 check->chip->x = center_x; 33 check->chip->y = center_y; 34 chipToSky(check, inFPA, inChip); 35 double r_before = check->sky->r; 36 double d_before = check->sky->d; 37 psLogMsg("ppstampMakeStamp", 2, "Before fit Center Pixel RA: %f DEC: %f (degrees)\n", 38 r_before * PS_DEG_RAD, d_before * PS_DEG_RAD); 34 39 35 40 if (outFPA->toSky->type != PS_PROJ_TAN) { 36 if (!pmAstromLinearizeTransforms(outFPA, outChip)) { 41 // we need to make astrometry terms for the output which are centered on the output chip center, 42 // but we keep the original plate scale 43 psFree(outFPA->toSky); 44 outFPA->toSky = psProjectionAlloc (r_before, d_before, inFPA->toSky->Xs, inFPA->toSky->Ys, PS_PROJ_TAN); 45 46 if (!pmAstromLinearizeToSky(inFPA, inChip, outFPA, outChip, roi)) { 47 psFree(check); 37 48 psError(PS_ERR_UNKNOWN, false, "Failed to linearize astrometry\n"); 38 49 return false; 39 50 } 40 } 51 check->chip->x = (roi->x1 - roi->x0) / 2; 52 check->chip->y = (roi->y1 - roi->y0) / 2; 53 chipToSky(check, outFPA, outChip); 54 double r_after = check->sky->r; 55 double d_after = check->sky->d; 56 57 psLogMsg("ppstampMakeStamp", 2, "After fit: Center Pixel RA: %f DEC: %f (degrees)\n", 58 r_after * PS_DEG_RAD, d_after * PS_DEG_RAD); 59 psLogMsg("ppstampMakeStamp", 2, "Error in fit to astrometry %.2f %.2f (arcseconds)\n", 60 (r_after - r_before) * PS_DEG_RAD * 3600, (d_after - d_before) * PS_DEG_RAD * 3600); 61 62 // XXX: should we fail if the fit is bad ?? 63 64 } else { 65 outChip->toFPA = psPlaneTransformSetCenter(NULL, inChip->toFPA, (int) roi->x0, (int) roi->y0); 66 outChip->fromFPA = psPlaneTransformInvert(NULL, outChip->toFPA, *roi, 50); 67 if (!outChip->fromFPA) { 68 psError(PS_ERR_UNKNOWN, false, "inversion of toFPA transform failed"); 69 return false; 70 } 71 } 72 psFree(check); 41 73 42 74 if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_NONLIN_TOL)) { … … 92 124 // If input had WCS convert it for stamp 93 125 if (input->fpa->toSky) { 94 // steal the input fpa's transforms 95 output->fpa->toTPA = input->fpa->toTPA; 96 output->fpa->fromTPA = input->fpa->fromTPA; 97 output->fpa->toSky = input->fpa->toSky; 98 99 // drop the references 100 input->fpa->toTPA = 0; 101 input->fpa->fromTPA = 0; 102 input->fpa->toSky = 0; 103 104 if (!convertWCS(outHDU, output->fpa, outChip, inChip, &options->roi)) { 126 // copy the input fpa's transforms 127 // XXX: if we change to making multiple stamps per process we'll need to copy 128 // the transformations 129 output->fpa->toTPA = psMemIncrRefCounter(input->fpa->toTPA); 130 output->fpa->fromTPA = psMemIncrRefCounter(input->fpa->fromTPA); 131 output->fpa->toSky = psMemIncrRefCounter(input->fpa->toSky); 132 133 if (!convertWCS(outHDU, input->fpa, inChip, output->fpa, outChip, &options->roi)) { 105 134 return false; 106 135 } … … 393 422 double dx = 0.5 * options->roip.dRA / fpa->toSky->Xs; 394 423 double dy = 0.5 * options->roip.dDEC / fpa->toSky->Ys; 424 425 if (dx > 5000) { 426 fprintf(stderr, "requested width %f too large reducing to 5000\n", dx); 427 dx = 5000; 428 } 429 if (dy > 5000) { 430 fprintf(stderr, "requested height %f too large reducing to 5000\n", dy); 431 dy = 5000; 432 } 395 433 396 434 pt->TP->xErr = 0; … … 497 535 int width = options->roip.dX; 498 536 int height = options->roip.dY; 537 if (width > 5000) { 538 fprintf(stderr, "requested width %d too large reducing to 5000\n", width); 539 width = 5000; 540 } 541 if (height > 5000) { 542 fprintf(stderr, "requested height %d too large reducing to 5000\n", height); 543 height = 5000; 544 } 499 545 500 546 // calculate the ROI in chip coordinates
Note:
See TracChangeset
for help on using the changeset viewer.
