Changeset 5543
- Timestamp:
- Nov 18, 2005, 9:43:14 AM (21 years ago)
- Location:
- trunk/psModules
- Files:
-
- 7 edited
-
src/astrom/pmAstrometry.c (modified) (27 diffs)
-
src/astrom/pmAstrometry.h (modified) (15 diffs)
-
src/detrend/pmFlatField.c (modified) (2 diffs)
-
src/detrend/pmMaskBadPixels.c (modified) (3 diffs)
-
src/detrend/pmNonLinear.c (modified) (2 diffs)
-
test/astrom/Makefile.am (modified) (1 diff)
-
test/astrom/tst_pmAstrometry.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometry.c
r5435 r5543 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-1 0-20 23:06:24 $10 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-11-18 19:43:14 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "pmAstrometry.h" 24 24 25 void PS_PRINT_POLY2D(psPolynomial2D *poly) 26 { 27 for (psS32 x = 0 ; x < poly->nX+1 ; x++) { 28 for (psS32 y = 0 ; y < poly->nY+1 ; y++) { 29 printf(" (%.2f x^%d y^%d)\n", poly->coeff[x][y], x, y); 30 } 31 } 32 } 33 34 void PS_PRINT_PLANE_TRANSFORM(psPlaneTransform *pt) 35 { 36 printf("---------------------- Plane Transform ----------------------\n"); 37 printf("x:\n"); 38 PS_PRINT_POLY2D(pt->x); 39 printf("y:\n"); 40 PS_PRINT_POLY2D(pt->y); 41 } 42 25 43 /***************************************************************************** 26 44 checkValidImageCoords(): this is a private function which simply determines if … … 29 47 XXX: What about col0 and row0 30 48 XXX: This should return a psBool. 49 XXX: Macro this for speed. 31 50 *****************************************************************************/ 32 51 static psS32 checkValidImageCoords(double x, … … 36 55 PS_ASSERT_IMAGE_NON_NULL(tmpImage, 0); 37 56 38 if ((x < 0.0) || (x > (double)tmpImage->numCols) || 39 (y < 0.0) || (y > (double)tmpImage->numRows)) { 57 if ((x < 0.0) || (x > (double)tmpImage->numCols) || (y < 0.0) || (y > (double)tmpImage->numRows)) { 40 58 return (0); 41 59 } … … 45 63 46 64 /****************************************************************************** 47 XXX: Is this the correct way to free metadata?48 XXX: Is this the correct way to free database structs?49 50 51 52 XXX: The memory dereferencing is not quite right with these functions. If I53 call the alloc functions with non-NULL pointers, there will be memory leaks.54 65 *****************************************************************************/ 66 static void readoutFree(pmReadout *readout) 67 { 68 if (readout != NULL) { 69 psFree(readout->image); 70 psFree(readout->mask); 71 psFree(readout->weight); 72 psFree(readout->bias); 73 psFree(readout->analysis); 74 psFree(readout->parent); 75 } 76 } 77 78 #define BIG_BANG 1 79 static void cellFree(pmCell *cell) 80 { 81 if (cell != NULL) { 82 psFree(cell->toChip); 83 psFree(cell->toFPA); 84 psFree(cell->toSky); 85 psFree(cell->concepts); 86 psFree(cell->camera); 87 psFree(cell->analysis); 88 // 89 // Set the parent to NULL in all cell->readouts before psFree(cell->readouts) 90 // in order to avoid memory reference counter problems. 91 // 92 for (psS32 i = 0 ; i < cell->readouts->n ; i++) { 93 pmReadout *tmpReadout = (pmReadout *) cell->readouts->data[i]; 94 tmpReadout->parent = NULL; 95 if (BIG_BANG == 1) { 96 psFree(tmpReadout); 97 } 98 } 99 psFree(cell->readouts); 100 psFree(cell->parent); 101 psFree(cell->private); 102 } 103 } 104 105 static void chipFree(pmChip* chip) 106 { 107 if (chip != NULL) { 108 psFree(chip->toFPA); 109 psFree(chip->fromFPA); 110 psFree(chip->concepts); 111 psFree(chip->analysis); 112 // 113 // Set the parent to NULL in all chip->cells before psFree(chip->cells) 114 // in order to avoid memory reference counter problems. 115 // 116 for (psS32 i = 0 ; i < chip->cells->n ; i++) { 117 pmCell *tmpCell = (pmCell *) chip->cells->data[i]; 118 tmpCell->parent = NULL; 119 if (BIG_BANG == 1) { 120 psFree(tmpCell); 121 } 122 } 123 psFree(chip->cells); 124 psFree(chip->parent); 125 psFree(chip->private); 126 } 127 } 128 129 55 130 static void FPAFree(pmFPA *fpa) 56 131 { … … 69 144 pmChip *tmpChip = (pmChip *) fpa->chips->data[i]; 70 145 tmpChip->parent = NULL; 146 if (BIG_BANG == 1) { 147 psFree(tmpChip); 148 } 71 149 } 72 150 psFree(fpa->chips); 73 151 psFree(fpa->private); 74 152 psFree(fpa->phu); 75 }76 }77 78 static void chipFree(pmChip* chip)79 {80 if (chip != NULL) {81 psFree(chip->toFPA);82 psFree(chip->fromFPA);83 psFree(chip->concepts);84 psFree(chip->analysis);85 //86 // Set the parent to NULL in all chip->cells before psFree(chip->cells)87 // in order to avoid memory reference counter problems.88 //89 for (psS32 i = 0 ; i < chip->cells->n ; i++) {90 pmCell *tmpCell = (pmCell *) chip->cells->data[i];91 tmpCell->parent = NULL;92 }93 psFree(chip->cells);94 psFree(chip->parent);95 psFree(chip->private);96 }97 }98 99 static void cellFree(pmCell *cell)100 {101 if (cell != NULL) {102 psFree(cell->toChip);103 psFree(cell->toFPA);104 psFree(cell->toSky);105 psFree(cell->concepts);106 psFree(cell->camera);107 psFree(cell->analysis);108 //109 // Set the parent to NULL in all cell->readouts before psFree(cell->readouts)110 // in order to avoid memory reference counter problems.111 //112 for (psS32 i = 0 ; i < cell->readouts->n ; i++) {113 pmReadout *tmpReadout = (pmReadout *) cell->readouts->data[i];114 tmpReadout->parent = NULL;115 }116 psFree(cell->readouts);117 psFree(cell->parent);118 psFree(cell->private);119 }120 }121 122 static void readoutFree(pmReadout *readout)123 {124 if (readout != NULL) {125 psFree(readout->image);126 psFree(readout->mask);127 psFree(readout->weight);128 psFree(readout->bias);129 psFree(readout->analysis);130 psFree(readout->parent);131 153 } 132 154 } … … 154 176 } 155 177 178 // XXX: Verify these default values for row0, col0, rowBins, colBins 156 179 pmCell *pmCellAlloc( 157 180 pmChip *chip, 158 181 psMetadata *cameradata, 159 psString name 160 ) 182 psString name) 161 183 { 162 184 pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell)); … … 189 211 pmChip *pmChipAlloc( 190 212 pmFPA *fpa, 191 psString name 192 ) 213 psString name) 193 214 { 194 215 pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip)); … … 295 316 296 317 297 // HEY298 318 /*****************************************************************************/ 299 319 /* FUNCTION IMPLEMENTATION - PUBLIC */ 300 320 /*****************************************************************************/ 301 321 302 pmCell* pmCellInFPA(const psPlane* fpaCoord, 303 const pmFPA* FPA) 322 pmCell* pmCellInFPA( 323 const psPlane* fpaCoord, 324 const pmFPA* FPA) 304 325 { 305 326 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); … … 317 338 318 339 // Convert to those chip coordinates. 319 p sCoordFPAToChip(&chipCoord, fpaCoord, tmpChip);340 pmCoordFPAToChip(&chipCoord, fpaCoord, tmpChip); 320 341 321 342 // Determine which cell contains those chip coordinates. … … 325 346 } 326 347 327 pmChip* pmChipInFPA(const psPlane* fpaCoord, 328 const pmFPA* FPA) 348 pmChip* pmChipInFPA( 349 const psPlane* fpaCoord, 350 const pmFPA* FPA) 329 351 { 330 352 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); … … 337 359 pmCell *tmpCell = NULL; 338 360 361 // 339 362 // Loop through every chip in this FPA. Convert the original FPA 340 363 // coordinates to chip coordinates for that chip. Then, determine if any 341 364 // cells in that chip contain those chip coordinates. 342 365 // XXX: Depending on the number of chips, and their topology, there may be 366 // a much more efficient way of doing this. 367 // 343 368 for (psS32 i = 0; i < nChips; i++) { 344 369 pmChip* tmpChip = chips->data[i]; … … 359 384 360 385 361 pmCell* pmCellInChip(const psPlane* chipCoord, 362 const pmChip* chip) 386 pmCell* pmCellInChip( 387 const psPlane* chipCoord, 388 const pmChip* chip) 363 389 { 364 390 PS_ASSERT_PTR_NON_NULL(chipCoord, NULL); … … 373 399 } 374 400 401 // 375 402 // We loop over each cell in the chip. We transform the chipCoord into 376 403 // a cellCoord for that cell and determine if that cellCoord is valid. 377 404 // If so, then we return that cell. 378 405 // XXX: Depending on the number of cells, and their topology, there may be 406 // a much more efficient way of doing this. 407 // 379 408 for (psS32 i = 0; i < cells->n; i++) { 380 409 pmCell* tmpCell = (pmCell* ) cells->data[i]; … … 382 411 383 412 psPlaneTransform *chipToCell = NULL; 384 if (1 != p_psIsProjectionLinear(tmpCell->toChip)) { 413 if (true == p_psIsProjectionLinear(tmpCell->toChip)) { 414 chipToCell = p_psPlaneTransformLinearInvert(tmpCell->toChip); 415 } else { 385 416 // XXX: Generate warning message. 386 417 // XXX: Can we use the following function to derive a transform? 387 418 // chipToCell = psPlaneTransformInvert(NULL, tmpCell->toChip, NULL, -1); 388 } else {389 chipToCell = p_psPlaneTransformLinearInvert(tmpCell->toChip);390 419 } 391 420 … … 405 434 cellCoord.y, 406 435 tmpReadout->image)) { 436 psFree(chipToCell); 407 437 return (tmpCell); 408 438 } … … 416 446 417 447 418 psPlane* psCoordCellToChip(psPlane* outCoord, 419 const psPlane* inCoord, 420 const pmCell* cell) 448 psPlane* pmCoordCellToChip( 449 psPlane* outCoord, 450 const psPlane* inCoord, 451 const pmCell* cell) 421 452 { 422 453 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); … … 427 458 428 459 429 psPlane* psCoordChipToFPA(psPlane* outCoord, 430 const psPlane* inCoord, 431 const pmChip* chip) 460 psPlane* pmCoordChipToFPA( 461 psPlane* outCoord, 462 const psPlane* inCoord, 463 const pmChip* chip) 432 464 { 433 465 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); … … 438 470 439 471 440 441 psPlane* psCoordFPAToTP(psPlane* outCoord,442 const psPlane* inCoord,443 double color,444 double magnitude,445 const pmFPA* fpa)472 psPlane* pmCoordFPAToTP( 473 psPlane* outCoord, 474 const psPlane* inCoord, 475 double color, 476 double magnitude, 477 const pmFPA* fpa) 446 478 { 447 479 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 448 480 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 449 481 450 return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, 451 color, magnitude)); 482 return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, color, magnitude)); 452 483 } 453 484 454 485 /***************************************************************************** 455 486 XXX: What about units for the (x,y) coords? 487 488 XXX: This has not been tested. 456 489 *****************************************************************************/ 457 psSphere* p sCoordTPToSky(psSphere* outSphere,458 const psPlane* tpCoord,459 const psProjection *projection460 )490 psSphere* pmCoordTPToSky( 491 psSphere* outSphere, 492 const psPlane* tpCoord, 493 const psProjection *projection) 461 494 { 462 495 PS_ASSERT_PTR_NON_NULL(tpCoord, NULL); 463 464 if (outSphere == NULL) { 465 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 466 } 467 468 // XXX: this was done by a SLALIB call -- needs to be reimplemented 469 psWarning("Warning! psCoordTPToSky functionality is no longer implemented"); 470 // slaAopqk(tpCoord->x, tpCoord->y, (double*)grommit, 471 // &AOB, &ZOB, &HOB, &outSphere->r, &outSphere->d); 472 473 return (outSphere); 474 } 475 476 477 478 psPlane* psCoordCellToFPA(psPlane* fpaCoord, 479 const psPlane* cellCoord, 480 const pmCell* cell) 496 PS_ASSERT_PTR_NON_NULL(projection, NULL); 497 498 return(p_psDeproject(outSphere, tpCoord, projection)); 499 } 500 501 502 psPlane* pmCoordCellToFPA( 503 psPlane* fpaCoord, 504 const psPlane* cellCoord, 505 const pmCell* cell) 481 506 { 482 507 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); … … 487 512 488 513 489 490 psSphere* psCoordCellToSky(psSphere* skyCoord, 491 const psPlane* cellCoord, 492 double color, 493 double magnitude, 494 const pmCell* cell) 514 // XXX: Should we check return codes of intermediate transforms? 515 // XXX: This has not been tested. 516 psSphere* pmCoordCellToSky( 517 psSphere* skyCoord, 518 const psPlane* cellCoord, 519 double color, 520 double magnitude, 521 const pmCell* cell) 495 522 { 496 523 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); … … 500 527 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 501 528 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->toTangentPlane, NULL); 502 // PS_ASSERT_PTR_NON_NULL(cell->parent->parent->exposure, NULL); 503 504 psPlane* fpaCoord = NULL; 505 psPlane* tpCoord = NULL; 529 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->projection, NULL); 530 psPlane fpaCoord; 531 psPlane tpCoord; 506 532 pmFPA* parFPA = (cell->parent)->parent; 507 // psGrommit* tmpGrommit = NULL;508 533 509 534 // Convert the input cell coordinates to FPA coordinates. 510 fpaCoord = psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord);535 psPlaneTransformApply(&fpaCoord, cell->toFPA, cellCoord); 511 536 512 537 // Convert the FPA coordinates to tangent plane Coordinates. 513 tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, 514 fpaCoord, color, magnitude); 515 516 // Generate a grommit for this FPA. 517 // tmpGrommit = psGrommitAlloc(parFPA->exposure); 538 psPlaneDistortApply(&tpCoord, parFPA->toTangentPlane, &fpaCoord, color, magnitude); 518 539 519 540 // Convert the tangent plane Coordinates to sky coordinates. 520 // skyCoord = psCoordTPToSky(skyCoord, tpCoord, tmpGrommit); 521 522 psFree(fpaCoord); 523 psFree(tpCoord); 524 // psFree(tmpGrommit); 525 526 return(skyCoord); 527 } 528 529 530 psSphere* psCoordCellToSkyQuick(psSphere* outSphere, 531 const psPlane* cellCoord, 532 const pmCell* cell) 541 return(pmCoordTPToSky(NULL, &tpCoord, parFPA->projection)); 542 } 543 544 545 // XXX: This has not been tested. 546 // XXX: How do we get sphere coods from the cell->toSky plane transform? 547 psSphere* pmCoordCellToSkyQuick( 548 psSphere* outSphere, 549 const psPlane* cellCoord, 550 const pmCell* cell) 533 551 { 534 552 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); 535 553 PS_ASSERT_PTR_NON_NULL(cell, NULL); 536 554 PS_ASSERT_PTR_NON_NULL(cell->toSky, NULL); 537 PS_ASSERT_PTR_NON_NULL(cell->parent, NULL); 538 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 539 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->projection, NULL); 540 555 556 // return(psPlaneTransformApply(outSphere, cell->toSky, cellCoord)); 541 557 psLogMsg(__func__, PS_LOG_WARN, 542 558 "WARNING: psCoordCellToSkyQuick(): This function is not fully specified in the SDRS. Returning NULL.\n"); 543 559 return(NULL); 544 545 /*546 if (cell->toSky) {547 // XXX: Should we use toTP or toSky?548 psLogMsg(__func__, PS_LOG_WARN,549 "WARNING: psCoordCellToSkyQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used.");550 }551 552 psPlane *tpCoord = NULL;553 pmChip *chip = cell->parent;554 pmFPA *FPA = chip->parent;555 psProjectionType oldProjectionType;556 557 if (outSphere == NULL) {558 outSphere = (psSphere* ) psAlloc(sizeof(psSphere));559 }560 561 // Determine the tangent plane coordinates.562 tpCoord = psPlaneTransformApply(NULL, cell->toTP, cellCoord);563 564 // Save the old projection type and set the new projection type to TAN.565 oldProjectionType = FPA->projection->type;566 FPA->projection->type = PS_PROJ_TAN;567 568 // Deproject the tangent plane coordinates a sphere.569 outSphere = psDeproject(tpCoord, FPA->projection);570 571 // Restore old projection type. Free memory.572 FPA->projection->type = oldProjectionType;573 psFree(tpCoord);574 575 return (outSphere);576 */577 560 } 578 561 … … 580 563 /***************************************************************************** 581 564 XXX: What about units for the (x,y) coords? 565 566 XXX: This has not been tested. 582 567 *****************************************************************************/ 583 psPlane* psCoordSkyToTP(psPlane* tpCoord, 584 const psSphere* in, 585 const psProjection *projection) 568 psPlane* pmCoordSkyToTP( 569 psPlane* tpCoord, 570 const psSphere* in, 571 const psProjection *projection) 586 572 { 587 573 PS_ASSERT_PTR_NON_NULL(in, NULL); 588 // PS_ASSERT_PTR_NON_NULL(grommit, NULL); 589 590 // char* type = "RA"; 591 592 if (tpCoord == NULL) { 593 tpCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 594 } 595 596 // XXX: this was done by a SLALIB call -- needs to be reimplemented 597 psWarning("Warning! psCoordSkyToTP functionality is no longer implemented"); 598 // slaOapqk(type, in->r, in->d, (double*)grommit, &tpCoord->x, &tpCoord->y); 599 600 return(tpCoord); 601 } 602 603 604 psPlane* psCoordTPToFPA(psPlane* fpaCoord, 605 const psPlane* tpCoord, 606 double color, 607 double magnitude, 608 const pmFPA* fpa) 574 PS_ASSERT_PTR_NON_NULL(projection, NULL); 575 576 return(p_psProject(tpCoord, in, projection)); 577 } 578 579 580 psPlane* pmCoordTPToFPA( 581 psPlane* fpaCoord, 582 const psPlane* tpCoord, 583 double color, 584 double magnitude, 585 const pmFPA* fpa) 609 586 { 610 587 PS_ASSERT_PTR_NON_NULL(tpCoord, NULL); … … 612 589 PS_ASSERT_PTR_NON_NULL(fpa->fromTangentPlane, NULL); 613 590 614 return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane, 615 tpCoord, color, magnitude)); 616 } 617 618 619 psPlane* psCoordFPAToChip(psPlane* chipCoord,620 const psPlane* fpaCoord,621 const pmChip* chip)591 return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane, tpCoord, color, magnitude)); 592 } 593 594 595 psPlane* pmCoordFPAToChip( 596 psPlane* chipCoord, 597 const psPlane* fpaCoord, 598 const pmChip* chip) 622 599 { 623 600 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); … … 629 606 } 630 607 631 632 psPlane* psCoordChipToCell(psPlane* cellCoord,633 const psPlane* chipCoord,634 const pmCell* cell)608 psPlane* pmCoordChipToCell( 609 psPlane* cellCoord, 610 const psPlane* chipCoord, 611 const pmCell* cell) 635 612 { 636 613 PS_ASSERT_PTR_NON_NULL(chipCoord, NULL); … … 648 625 649 626 650 psPlane* psCoordSkyToCell(psPlane* cellCoord, 651 const psSphere* skyCoord, 652 float color, 653 float magnitude, 654 const pmCell* cell) 627 psPlane* pmCoordSkyToCell( 628 psPlane* cellCoord, 629 const psSphere* skyCoord, 630 float color, 631 float magnitude, 632 const pmCell* cell) 655 633 { 656 634 PS_ASSERT_PTR_NON_NULL(skyCoord, NULL); … … 658 636 PS_ASSERT_PTR_NON_NULL(cell->parent, NULL); 659 637 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 660 // PS_ASSERT_PTR_NON_NULL(cell->parent->parent->grommit, NULL);661 662 638 pmChip *parChip = cell->parent; 663 639 pmFPA *parFPA = parChip->parent; 664 640 665 641 // Convert the skyCoords to tangent plane coords. 666 psPlane *tpCoord = p sCoordSkyToTP(NULL, skyCoord, parFPA->projection);642 psPlane *tpCoord = pmCoordSkyToTP(NULL, skyCoord, parFPA->projection); 667 643 668 644 // Convert the tangent plane coords to FPA coords. 669 psPlane *fpaCoord = p sCoordTPToFPA(NULL, tpCoord, color, magnitude, parFPA);645 psPlane *fpaCoord = pmCoordTPToFPA(NULL, tpCoord, color, magnitude, parFPA); 670 646 671 647 // Convert the FPA coords to chip coords. 672 psPlane *chipCoord = p sCoordFPAToChip(NULL, fpaCoord, parChip);648 psPlane *chipCoord = pmCoordFPAToChip(NULL, fpaCoord, parChip); 673 649 674 650 // Convert the chip coords to cell coords. 675 cellCoord = p sCoordChipToCell(cellCoord, chipCoord, cell);651 cellCoord = pmCoordChipToCell(cellCoord, chipCoord, cell); 676 652 677 653 psFree(tpCoord); … … 683 659 684 660 685 psPlane* psCoordSkyToCellQuick(psPlane* cellCoord, 686 const psSphere* skyCoord, 687 const pmCell* cell) 661 /***************************************************************************** 662 XXX: What about units for the (x,y) coords? 663 664 XXX: This has not been tested. 665 666 XXX: How do we get sphere coods from the cell->toSky plane transform? 667 *****************************************************************************/ 668 psPlane* pmCoordSkyToCellQuick( 669 psPlane* cellCoord, 670 const psSphere* skyCoord, 671 const pmCell* cell) 688 672 { 689 673 PS_ASSERT_PTR_NON_NULL(skyCoord, NULL); 690 674 PS_ASSERT_PTR_NON_NULL(cell, NULL); 691 PS_ASSERT_PTR_NON_NULL(cell->parent, NULL); 692 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 693 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->projection, NULL); 694 695 675 PS_ASSERT_PTR_NON_NULL(cell->toSky, NULL); 676 677 // return(p_psProject(cellCoord, skyCoord, cell->toSky)); 696 678 psLogMsg(__func__, PS_LOG_WARN, 697 "WARNING: psCoord SkyToCellQuick(): This function is not fully specified in the SDRS. Returning NULL.\n");679 "WARNING: psCoordCellToSkyQuick(): This function is not fully specified in the SDRS. Returning NULL.\n"); 698 680 return(NULL); 699 /* 700 701 if (cell->toSky) { 702 // XXX: Should we use toTP or toSky? 703 psLogMsg(__func__, PS_LOG_WARN, 704 "WARNING: psCoordSkyToCellQuick: The cell->toSky transform is ignored. The cell->toTP transform is being used."); 705 } 706 707 psPlane *tpCoord = NULL; 708 pmChip *whichChip = cell->parent; 709 pmFPA *whichFPA = whichChip->parent; 710 psProjectionType oldProjectionType; 711 psPlaneTransform *TPtoCell = NULL; 712 713 // Save the old projection type and set the new projection type to TAN. 714 oldProjectionType = whichFPA->projection->type; 715 whichFPA->projection->type = PS_PROJ_TAN; 716 717 if (cellCoord == NULL) { 718 cellCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 719 } 720 721 tpCoord = psProject(skyCoord, whichFPA->projection); 722 723 // generate an error if cell->toTP is not linear. 724 if (0 == p_psIsProjectionLinear(cell->toTP)) { 725 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 726 PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM, 727 "cell to tangent plane"); 728 } 729 730 TPtoCell = p_psPlaneTransformLinearInvert(cell->toTP); 731 cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord); 732 733 // Restore old projection type. Free memory. 734 whichFPA->projection->type = oldProjectionType; 735 psFree(tpCoord); 736 return (cellCoord); 737 */ 738 } 739 740 /* 741 psMetadataItem* psMetadataLookup( 742 const psMetadata * md, ///< Metadata collection to lookup meta! 743 const char * key ///< Name of metadata key. 744 ); 745 */ 746 747 // XXX: How should we handle errors? What if psMetadataLookup() is NULL? 748 psMetadataItem *pmReadoutGetConcept(pmReadout *readout, const char *concept) 749 { 750 // return(psMetadataLookup(readout->concepts, concept)); 751 return(NULL); 752 } 753 754 psMetadataItem *pmCellGetConcept(pmCell *cell, const char *concept) 755 { 756 return(psMetadataLookup(cell->concepts, concept)); 757 } 758 759 psMetadataItem *pmChipGetConcept(pmChip *chip, const char *concept) 760 { 761 return(psMetadataLookup(chip->concepts, concept)); 762 } 763 764 psMetadataItem *pmFPAGetConcept(pmFPA *fpa, const char *concept) 765 { 766 return(psMetadataLookup(fpa->concepts, concept)); 767 } 768 769 770 float pmFPAGetAirmass(pmFPA *fpa) // FPA.AIRMASS 771 { 772 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.AIRMASS"); 773 return((float) tmp->data.F32); 774 } 775 776 psString pmFPAGetFilter(pmFPA *fpa) // FPA.FILTER 777 { 778 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.FILTER"); 779 return((psString) tmp->data.V); 780 } 781 782 float pmFPAGetPosAngle(pmFPA *fpa) // FPA.POSANGLE 783 { 784 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.POSANGLE"); 785 return((float) tmp->data.F32); 786 } 787 788 double pmFPAGetRA(pmFPA *fpa) // FPA.RA 789 { 790 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.RA"); 791 return((float) tmp->data.F32); 792 } 793 794 double pmFPAGetDec(pmFPA *fpa) // FPA.DEC 795 { 796 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.DEC"); 797 return((float) tmp->data.F32); 798 } 799 800 psString pmFPAGetRADecSys(pmFPA *fpa) // FPA.RADECSYS 801 { 802 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.RADECSYS"); 803 return((psString) tmp->data.V); 804 } 805 806 psString pmFPAGetName(pmFPA *fpa) // FPA.NAME 807 { 808 psMetadataItem *tmp = pmFPAGetConcept(fpa, "FPA.NAME"); 809 return((psString) tmp->data.V); 810 } 811 812 psString pmChipGetName(pmChip *chip) // CHIP.NAME 813 { 814 psMetadataItem *tmp = pmChipGetConcept(chip, "CHIP.NAME"); 815 return((psString) tmp->data.V); 816 } 817 818 psString pmCellGetName(pmCell *cell) // CELL.NAME 819 { 820 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.NAME"); 821 return((psString) tmp->data.V); 822 } 823 824 psTime *pmCellGetTime(pmCell *cell) // CELL.TIME 825 { 826 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.TIME"); 827 return((psTime *) tmp->data.V); 828 } 829 830 psList *pmCellGetBiasSec(pmCell *cell) // CELL.BIASSEC 831 { 832 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.BIASSEC"); 833 return((psList *) tmp->data.list); 834 } 835 836 psRegion pmCellGetTrimSec(pmCell *cell) // CELL.TRIMSEC 837 { 838 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.TRIMSEC"); 839 return((psRegion) *((psRegion *) (tmp->data.V))); 840 } 841 842 float pmCellGetGain(pmCell *cell) // CELL.GAIN 843 { 844 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.GAIN"); 845 return((float) tmp->data.F32); 846 } 847 848 float pmCellGetReadNoise(pmCell *cell) // CELL.READNOISE 849 { 850 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.READNOISE"); 851 return((float) tmp->data.F32); 852 } 853 854 float pmCellGetSaturation(pmCell *cell) // CELL.SATURATION 855 { 856 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.SATURATION"); 857 return((float) tmp->data.F32); 858 } 859 860 float pmCellGetBad(pmCell *cell) // CELL.BAD 861 { 862 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.BAD"); 863 return((float) tmp->data.F32); 864 } 865 866 867 psPixelCoord pmCellGetBin(pmCell *cell) // CELL.BIN 868 { 869 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.BIN"); 870 return((psPixelCoord) *((psPixelCoord *) (tmp->data.V))); 871 } 872 873 psPixelCoord pmCellGetParity(pmCell *cell) // CELL.PARITY 874 { 875 psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.PARITY"); 876 return((psPixelCoord) *((psPixelCoord *) (tmp->data.V))); 877 } 878 879 float pmReadoutGetExposure(pmReadout *readout) // READOUT.EXPOSURE 880 { 881 psMetadataItem *tmp = pmReadoutGetConcept(readout, "READOUT.EXPOSURE"); 882 return((float) tmp->data.F32); 883 } 884 885 float pmReadoutGetDarkTime(pmReadout *readout) // READOUT.DARKTIME 886 { 887 psMetadataItem *tmp = pmReadoutGetConcept(readout, "READOUT.DARKTIME"); 888 return((float) tmp->data.F32); 889 } 890 891 892 893 894 /* 895 typedef struct 896 { 897 float x0; 898 } 899 psJunk; 900 901 psJunk *pmCellTmp(pmCell *cell) // CELL.TRIMSEC 902 { 903 psMetadataItem *tmp; 904 return((psJunk *) tmp->data.V); 905 } 906 907 */ 681 } 682 //This code will -
trunk/psModules/src/astrom/pmAstrometry.h
r5435 r5543 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-1 0-20 23:06:24 $10 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-11-18 19:43:14 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 274 274 * @return psPlane* the resulting chip coordinate 275 275 */ 276 psPlane* p sCoordCellToChip(276 psPlane* pmCoordCellToChip( 277 277 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 278 278 const psPlane* in, ///< the coordinate within Cell … … 285 285 * @return psPlane* the resulting FPA coordinate 286 286 */ 287 psPlane* p sCoordChipToFPA(287 psPlane* pmCoordChipToFPA( 288 288 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 289 289 const psPlane* in, ///< the coordinate within Chip … … 296 296 * @return psPlane* the resulting Tangent Plane coordinate 297 297 */ 298 psPlane* p sCoordFPAToTP(298 psPlane* pmCoordFPAToTP( 299 299 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 300 300 const psPlane* in, ///< the coordinate within FPA … … 309 309 * @return psSphere* the resulting Sky coordinate 310 310 */ 311 psSphere* p sCoordTPToSky(311 psSphere* pmCoordTPToSky( 312 312 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 313 313 const psPlane* in, ///< the coordinate within Tangent Plane … … 319 319 * @return psPlane* the resulting FPA coordinate 320 320 */ 321 psPlane* p sCoordCellToFPA(321 psPlane* pmCoordCellToFPA( 322 322 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 323 323 const psPlane* in, ///< the coordinate within cell … … 330 330 * @return psSphere* the resulting Sky coordinate 331 331 */ 332 psSphere* p sCoordCellToSky(332 psSphere* pmCoordCellToSky( 333 333 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 334 334 const psPlane* in, ///< the coordinate within cell … … 344 344 * @return psSphere* the resulting Sky coordinate 345 345 */ 346 psSphere* p sCoordCellToSkyQuick(346 psSphere* pmCoordCellToSkyQuick( 347 347 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 348 348 const psPlane* in, ///< the coordinate within cell … … 355 355 * @return psPlane* the resulting Tangent Plane coordinate 356 356 */ 357 psPlane* p sCoordSkyToTP(357 psPlane* pmCoordSkyToTP( 358 358 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 359 359 const psSphere* in, ///< the sky coordinate … … 365 365 * @return psPlane* the resulting FPA coordinate 366 366 */ 367 psPlane* p sCoordTPToFPA(367 psPlane* pmCoordTPToFPA( 368 368 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 369 369 const psPlane* in, ///< the coordinate within tangent plane … … 378 378 * @return psPlane* the resulting chip coordinate 379 379 */ 380 psPlane* p sCoordFPAToChip(380 psPlane* pmCoordFPAToChip( 381 381 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 382 382 const psPlane* in, ///< the FPA coordinate … … 389 389 * @return psPlane* the resulting cell coordinate 390 390 */ 391 psPlane* p sCoordChipToCell(391 psPlane* pmCoordChipToCell( 392 392 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 393 393 const psPlane* in, ///< the Chip coordinate … … 400 400 * @return psPlane* the resulting cell coordinate 401 401 */ 402 psPlane* p sCoordSkyToCell(402 psPlane* pmCoordSkyToCell( 403 403 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 404 404 const psSphere* in, ///< the Sky coordinate … … 414 414 * @return psPlane* the resulting cell coordinate 415 415 */ 416 psPlane* p sCoordSkyToCellQuick(416 psPlane* pmCoordSkyToCellQuick( 417 417 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 418 418 const psSphere* in, ///< the Sky coordinate … … 420 420 ); 421 421 422 423 psMetadataItem *pmCellGetConcept(pmCell *cell, const char *concept);424 psMetadataItem *pmChipGetConcept(pmChip *chip, const char *concept);425 psMetadataItem *pmFPAGetConcept(pmFPA *fpa, const char *concept);426 427 /**428 *429 * We next specify a series of specific functions for concept lookups. These430 * will generally be what the user utilises, so the goal is to provide a simple431 * interface providing a single type back, so the user doesnt have to go to the432 * trouble of checking types, etc. These functions should employ the above three433 * general lookup functions and deal with the result appropriately.434 *435 */436 float pmFPAGetAirmass(pmFPA *fpa); // FPA.AIRMASS437 psString pmFPAGetFilter(pmFPA *fpa); // FPA.FILTER438 float pmFPAGetPosAngle(pmFPA *fpa); // FPA.POSANGLE439 double pmFPAGetRA(pmFPA *fpa); // FPA.RA440 double pmFPAGetDec(pmFPA *fpa); // FPA.DEC441 psString pmFPAGetRADecSys(pmFPA *fpa); // FPA.RADECSYS442 psString pmFPAGetName(pmFPA *fpa); // FPA.NAME443 psString pmChipGetName(pmChip *chip); // CHIP.NAME444 psString pmCellGetName(pmCell *cell); // CELL.NAME445 psTime *pmCellGetTime(pmCell *cell); // CELL.TIME446 psList *pmCellGetBiasSec(pmCell *cell); // CELL.BIASSEC447 psRegion pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC448 float pmCellGetGain(pmCell *cell); // CELL.GAIN449 float pmCellGetReadNoise(pmCell *cell); // CELL.READNOISE450 float pmCellGetSaturation(pmCell *cell); // CELL.SATURATION451 float pmCellGetBad(pmCell *cell); // CELL.BAD452 psPixelCoord pmCellGetBin(pmCell *cell); // CELL.BIN453 psPixelCoord pmCellGetParity(pmCell *cell); // CELL.PARITY454 float pmReadoutGetExposure(pmReadout *readout); // READOUT.EXPOSURE455 float pmReadoutGetDarkTime(pmReadout *readout); // READOUT.DARKTIME456 457 458 459 422 #endif // #ifndef PS_ASTROMETRY_H -
trunk/psModules/src/detrend/pmFlatField.c
r5516 r5543 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $21 * @date $Date: 2005-11-1 5 20:09:03$20 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-11-18 19:43:14 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 #include "pmSubtractBias.h" 39 39 40 // XXX: This should be removed when the autoconf stuff handles psConstants.h correctly. 41 #define PS_WARN_PTR_NON_NULL(NAME) \ 42 if ((NAME) == NULL) { \ 43 psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \ 44 } \ 40 45 41 46 bool pmFlatField( -
trunk/psModules/src/detrend/pmMaskBadPixels.c
r5516 r5543 19 19 * @author Ross Harman, MHPCC 20 20 * 21 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-11-1 5 20:09:03$21 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-11-18 19:43:14 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 #include "pmMaskBadPixelsErrors.h" 37 37 #include "pmSubtractBias.h" 38 39 //XXX: REmove, autoconf is broken. 40 #define PS_WARN_PTR_NON_NULL(NAME) \ 41 if ((NAME) == NULL) { \ 42 psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \ 43 } \ 44 38 45 39 46 /****************************************************************************** … … 41 48 input image mask and a pixel location, then sets (logical or) all pixels with 42 49 parameter radius if that pixel to maskVal parameter. 43 *****************************************************************************/50 *****************************************************************************/ 44 51 psBool GrowPixel( 45 52 psImage *inMask, -
trunk/psModules/src/detrend/pmNonLinear.c
r5516 r5543 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-11-1 5 20:09:03$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-11-18 19:43:14 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "pmSubtractBias.h" 25 25 26 // XXX: Remove, autoconf must be 27 #define PS_WARN_PTR_NON_NULL(NAME) \ 28 if ((NAME) == NULL) { \ 29 psLogMsg(__func__, PS_LOG_WARN, "WARNING: %s is NULL.", #NAME); \ 30 } \ 26 31 /****************************************************************************** 27 32 pmNonLinearityLookup(): This routine will take an pmReadout image as input 28 33 and a 1-D polynomial. For each pixel in the input image, the polynomial will 29 be evaluated at that pixels value, and the image pixel will then be set to 34 be evaluated at that pixels value, and the image pixel will then be set 35 to 30 36 that value. 31 *****************************************************************************/37 *****************************************************************************/ 32 38 33 39 pmReadout *pmNonLinearityPolynomial(pmReadout *inputReadout, -
trunk/psModules/test/astrom/Makefile.am
r5169 r5543 6 6 7 7 TESTS = \ 8 tst_pmAstrometry 8 tst_pmAstrometry \ 9 tst_pmAstrometry01 9 10 10 11 tst_pmAstrometry_SOURCES = tst_pmAstrometry.c 12 tst_pmAstrometry01_SOURCES = tst_pmAstrometry01.c 11 13 12 14 check_PROGRAMS = $(TESTS) -
trunk/psModules/test/astrom/tst_pmAstrometry.c
r5435 r5543 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-20 23:06:24 $ 8 * XXX: Significant work needed: must test the variout coordinate transformation function. 9 * 10 * 11 * 12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-11-18 19:43:14 $ 10 14 * 11 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 172 176 173 177 psFree(fpa); 174 psFree(chip);178 // psFree(chip); 175 179 psFree(camera); 176 180 … … 267 271 268 272 psFree(fpa); 269 psFree(chip);270 psFree(cell);273 // psFree(chip); 274 // psFree(cell); 271 275 psFree(camera); 272 276 … … 353 357 354 358 psFree(fpa); 355 psFree(chip);356 psFree(cell);357 psFree(readout);359 // psFree(chip); 360 // psFree(cell); 361 // psFree(readout); 358 362 psFree(camera); 359 363 360 364 return 0; 361 365 } 362
Note:
See TracChangeset
for help on using the changeset viewer.
