IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 18, 2005, 9:43:14 AM (20 years ago)
Author:
gusciora
Message:

Significant mods to the pmAstrometry files and the detrend modules.

Location:
trunk/psModules/src/astrom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometry.c

    r5435 r5543  
    88*  @author GLG, MHPCC
    99*
    10 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-10-20 23:06:24 $
     10*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-11-18 19:43:14 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "pmAstrometry.h"
    2424
     25void 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
     34void 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
    2543/*****************************************************************************
    2644checkValidImageCoords(): this is a private function which simply determines if
     
    2947XXX: What about col0 and row0
    3048XXX: This should return a psBool.
     49XXX: Macro this for speed.
    3150 *****************************************************************************/
    3251static psS32 checkValidImageCoords(double x,
     
    3655    PS_ASSERT_IMAGE_NON_NULL(tmpImage, 0);
    3756
    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)) {
    4058        return (0);
    4159    }
     
    4563
    4664/******************************************************************************
    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 I
    53 call the alloc functions with non-NULL pointers, there will be memory leaks.
    5465 *****************************************************************************/
     66static 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
     79static 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
     105static 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
    55130static void FPAFree(pmFPA *fpa)
    56131{
     
    69144            pmChip *tmpChip = (pmChip *) fpa->chips->data[i];
    70145            tmpChip->parent = NULL;
     146            if (BIG_BANG == 1) {
     147                psFree(tmpChip);
     148            }
    71149        }
    72150        psFree(fpa->chips);
    73151        psFree(fpa->private);
    74152        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);
    131153    }
    132154}
     
    154176}
    155177
     178// XXX: Verify these default values for row0, col0, rowBins, colBins
    156179pmCell *pmCellAlloc(
    157180    pmChip *chip,
    158181    psMetadata *cameradata,
    159     psString name
    160 )
     182    psString name)
    161183{
    162184    pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell));
     
    189211pmChip *pmChipAlloc(
    190212    pmFPA *fpa,
    191     psString name
    192 )
     213    psString name)
    193214{
    194215    pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip));
     
    295316
    296317
    297 // HEY
    298318/*****************************************************************************/
    299319/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    300320/*****************************************************************************/
    301321
    302 pmCell* pmCellInFPA(const psPlane* fpaCoord,
    303                     const pmFPA* FPA)
     322pmCell* pmCellInFPA(
     323    const psPlane* fpaCoord,
     324    const pmFPA* FPA)
    304325{
    305326    PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL);
     
    317338
    318339    // Convert to those chip coordinates.
    319     psCoordFPAToChip(&chipCoord, fpaCoord, tmpChip);
     340    pmCoordFPAToChip(&chipCoord, fpaCoord, tmpChip);
    320341
    321342    // Determine which cell contains those chip coordinates.
     
    325346}
    326347
    327 pmChip* pmChipInFPA(const psPlane* fpaCoord,
    328                     const pmFPA* FPA)
     348pmChip* pmChipInFPA(
     349    const psPlane* fpaCoord,
     350    const pmFPA* FPA)
    329351{
    330352    PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL);
     
    337359    pmCell *tmpCell = NULL;
    338360
     361    //
    339362    // Loop through every chip in this FPA.  Convert the original FPA
    340363    // coordinates to chip coordinates for that chip.  Then, determine if any
    341364    // 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    //
    343368    for (psS32 i = 0; i < nChips; i++) {
    344369        pmChip* tmpChip = chips->data[i];
     
    359384
    360385
    361 pmCell* pmCellInChip(const psPlane* chipCoord,
    362                      const pmChip* chip)
     386pmCell* pmCellInChip(
     387    const psPlane* chipCoord,
     388    const pmChip* chip)
    363389{
    364390    PS_ASSERT_PTR_NON_NULL(chipCoord, NULL);
     
    373399    }
    374400
     401    //
    375402    // We loop over each cell in the chip.  We transform the chipCoord into
    376403    // a cellCoord for that cell and determine if that cellCoord is valid.
    377404    // 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    //
    379408    for (psS32 i = 0; i < cells->n; i++) {
    380409        pmCell* tmpCell = (pmCell* ) cells->data[i];
     
    382411
    383412        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 {
    385416            // XXX: Generate warning message.
    386417            // XXX: Can we use the following function to derive a transform?
    387418            // chipToCell = psPlaneTransformInvert(NULL, tmpCell->toChip, NULL, -1);
    388         } else {
    389             chipToCell = p_psPlaneTransformLinearInvert(tmpCell->toChip);
    390419        }
    391420
     
    405434                                          cellCoord.y,
    406435                                          tmpReadout->image)) {
     436                    psFree(chipToCell);
    407437                    return (tmpCell);
    408438                }
     
    416446
    417447
    418 psPlane* psCoordCellToChip(psPlane* outCoord,
    419                            const psPlane* inCoord,
    420                            const pmCell* cell)
     448psPlane* pmCoordCellToChip(
     449    psPlane* outCoord,
     450    const psPlane* inCoord,
     451    const pmCell* cell)
    421452{
    422453    PS_ASSERT_PTR_NON_NULL(inCoord, NULL);
     
    427458
    428459
    429 psPlane* psCoordChipToFPA(psPlane* outCoord,
    430                           const psPlane* inCoord,
    431                           const pmChip* chip)
     460psPlane* pmCoordChipToFPA(
     461    psPlane* outCoord,
     462    const psPlane* inCoord,
     463    const pmChip* chip)
    432464{
    433465    PS_ASSERT_PTR_NON_NULL(inCoord, NULL);
     
    438470
    439471
    440 
    441 psPlane* psCoordFPAToTP(psPlane* outCoord,
    442                         const psPlane* inCoord,
    443                         double color,
    444                         double magnitude,
    445                         const pmFPA* fpa)
     472psPlane* pmCoordFPAToTP(
     473    psPlane* outCoord,
     474    const psPlane* inCoord,
     475    double color,
     476    double magnitude,
     477    const pmFPA* fpa)
    446478{
    447479    PS_ASSERT_PTR_NON_NULL(inCoord, NULL);
    448480    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    449481
    450     return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord,
    451                                color, magnitude));
     482    return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, color, magnitude));
    452483}
    453484
    454485/*****************************************************************************
    455486XXX: What about units for the (x,y) coords?
     487 
     488XXX: This has not been tested.
    456489 *****************************************************************************/
    457 psSphere* psCoordTPToSky(psSphere* outSphere,
    458                          const psPlane* tpCoord,
    459                          const psProjection *projection
    460                         )
     490psSphere* pmCoordTPToSky(
     491    psSphere* outSphere,
     492    const psPlane* tpCoord,
     493    const psProjection *projection)
    461494{
    462495    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
     502psPlane* pmCoordCellToFPA(
     503    psPlane* fpaCoord,
     504    const psPlane* cellCoord,
     505    const pmCell* cell)
    481506{
    482507    PS_ASSERT_PTR_NON_NULL(cellCoord, NULL);
     
    487512
    488513
    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.
     516psSphere* pmCoordCellToSky(
     517    psSphere* skyCoord,
     518    const psPlane* cellCoord,
     519    double color,
     520    double magnitude,
     521    const pmCell* cell)
    495522{
    496523    PS_ASSERT_PTR_NON_NULL(cellCoord, NULL);
     
    500527    PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL);
    501528    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;
    506532    pmFPA* parFPA = (cell->parent)->parent;
    507     //    psGrommit* tmpGrommit = NULL;
    508533
    509534    // Convert the input cell coordinates to FPA coordinates.
    510     fpaCoord = psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord);
     535    psPlaneTransformApply(&fpaCoord, cell->toFPA, cellCoord);
    511536
    512537    // 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);
    518539
    519540    // 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?
     547psSphere* pmCoordCellToSkyQuick(
     548    psSphere* outSphere,
     549    const psPlane* cellCoord,
     550    const pmCell* cell)
    533551{
    534552    PS_ASSERT_PTR_NON_NULL(cellCoord, NULL);
    535553    PS_ASSERT_PTR_NON_NULL(cell, NULL);
    536554    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));
    541557    psLogMsg(__func__, PS_LOG_WARN,
    542558             "WARNING: psCoordCellToSkyQuick(): This function is not fully specified in the SDRS.  Returning NULL.\n");
    543559    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     */
    577560}
    578561
     
    580563/*****************************************************************************
    581564XXX: What about units for the (x,y) coords?
     565 
     566XXX: This has not been tested.
    582567 *****************************************************************************/
    583 psPlane* psCoordSkyToTP(psPlane* tpCoord,
    584                         const psSphere* in,
    585                         const psProjection *projection)
     568psPlane* pmCoordSkyToTP(
     569    psPlane* tpCoord,
     570    const psSphere* in,
     571    const psProjection *projection)
    586572{
    587573    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
     580psPlane* pmCoordTPToFPA(
     581    psPlane* fpaCoord,
     582    const psPlane* tpCoord,
     583    double color,
     584    double magnitude,
     585    const pmFPA* fpa)
    609586{
    610587    PS_ASSERT_PTR_NON_NULL(tpCoord, NULL);
     
    612589    PS_ASSERT_PTR_NON_NULL(fpa->fromTangentPlane, NULL);
    613590
    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
     595psPlane* pmCoordFPAToChip(
     596    psPlane* chipCoord,
     597    const psPlane* fpaCoord,
     598    const pmChip* chip)
    622599{
    623600    PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL);
     
    629606}
    630607
    631 
    632 psPlane* psCoordChipToCell(psPlane* cellCoord,
    633                            const psPlane* chipCoord,
    634                            const pmCell* cell)
     608psPlane* pmCoordChipToCell(
     609    psPlane* cellCoord,
     610    const psPlane* chipCoord,
     611    const pmCell* cell)
    635612{
    636613    PS_ASSERT_PTR_NON_NULL(chipCoord, NULL);
     
    648625
    649626
    650 psPlane* psCoordSkyToCell(psPlane* cellCoord,
    651                           const psSphere* skyCoord,
    652                           float color,
    653                           float magnitude,
    654                           const pmCell* cell)
     627psPlane* pmCoordSkyToCell(
     628    psPlane* cellCoord,
     629    const psSphere* skyCoord,
     630    float color,
     631    float magnitude,
     632    const pmCell* cell)
    655633{
    656634    PS_ASSERT_PTR_NON_NULL(skyCoord, NULL);
     
    658636    PS_ASSERT_PTR_NON_NULL(cell->parent, NULL);
    659637    PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL);
    660     //    PS_ASSERT_PTR_NON_NULL(cell->parent->parent->grommit, NULL);
    661 
    662638    pmChip *parChip = cell->parent;
    663639    pmFPA *parFPA = parChip->parent;
    664640
    665641    // Convert the skyCoords to tangent plane coords.
    666     psPlane *tpCoord = psCoordSkyToTP(NULL, skyCoord, parFPA->projection);
     642    psPlane *tpCoord = pmCoordSkyToTP(NULL, skyCoord, parFPA->projection);
    667643
    668644    // Convert the tangent plane coords to FPA coords.
    669     psPlane *fpaCoord = psCoordTPToFPA(NULL, tpCoord, color, magnitude, parFPA);
     645    psPlane *fpaCoord = pmCoordTPToFPA(NULL, tpCoord, color, magnitude, parFPA);
    670646
    671647    // Convert the FPA coords to chip coords.
    672     psPlane *chipCoord = psCoordFPAToChip(NULL, fpaCoord, parChip);
     648    psPlane *chipCoord = pmCoordFPAToChip(NULL, fpaCoord, parChip);
    673649
    674650    // Convert the chip coords to cell coords.
    675     cellCoord = psCoordChipToCell(cellCoord, chipCoord, cell);
     651    cellCoord = pmCoordChipToCell(cellCoord, chipCoord, cell);
    676652
    677653    psFree(tpCoord);
     
    683659
    684660
    685 psPlane* psCoordSkyToCellQuick(psPlane* cellCoord,
    686                                const psSphere* skyCoord,
    687                                const pmCell* cell)
     661/*****************************************************************************
     662XXX: What about units for the (x,y) coords?
     663 
     664XXX: This has not been tested.
     665 
     666XXX: How do we get sphere coods from the cell->toSky plane transform?
     667 *****************************************************************************/
     668psPlane* pmCoordSkyToCellQuick(
     669    psPlane* cellCoord,
     670    const psSphere* skyCoord,
     671    const pmCell* cell)
    688672{
    689673    PS_ASSERT_PTR_NON_NULL(skyCoord, NULL);
    690674    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));
    696678    psLogMsg(__func__, PS_LOG_WARN,
    697              "WARNING: psCoordSkyToCellQuick(): 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");
    698680    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  
    88*  @author GLG, MHPCC
    99*
    10 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-10-20 23:06:24 $
     10*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-11-18 19:43:14 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    274274 *  @return psPlane*    the resulting chip coordinate
    275275 */
    276 psPlane* psCoordCellToChip(
     276psPlane* pmCoordCellToChip(
    277277    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    278278    const psPlane* in,                 ///< the coordinate within Cell
     
    285285 *  @return psPlane*    the resulting FPA coordinate
    286286 */
    287 psPlane* psCoordChipToFPA(
     287psPlane* pmCoordChipToFPA(
    288288    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    289289    const psPlane* in,                 ///< the coordinate within Chip
     
    296296 *  @return psPlane*    the resulting Tangent Plane coordinate
    297297 */
    298 psPlane* psCoordFPAToTP(
     298psPlane* pmCoordFPAToTP(
    299299    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    300300    const psPlane* in,                 ///< the coordinate within FPA
     
    309309 *  @return psSphere*    the resulting Sky coordinate
    310310 */
    311 psSphere* psCoordTPToSky(
     311psSphere* pmCoordTPToSky(
    312312    psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
    313313    const psPlane* in,                ///< the coordinate within Tangent Plane
     
    319319 *  @return psPlane*    the resulting FPA coordinate
    320320 */
    321 psPlane* psCoordCellToFPA(
     321psPlane* pmCoordCellToFPA(
    322322    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    323323    const psPlane* in,                 ///< the coordinate within cell
     
    330330 *  @return psSphere*    the resulting Sky coordinate
    331331 */
    332 psSphere* psCoordCellToSky(
     332psSphere* pmCoordCellToSky(
    333333    psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
    334334    const psPlane* in,                 ///< the coordinate within cell
     
    344344 *  @return psSphere*    the resulting Sky coordinate
    345345 */
    346 psSphere* psCoordCellToSkyQuick(
     346psSphere* pmCoordCellToSkyQuick(
    347347    psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
    348348    const psPlane* in,                 ///< the coordinate within cell
     
    355355 *  @return psPlane*    the resulting Tangent Plane coordinate
    356356 */
    357 psPlane* psCoordSkyToTP(
     357psPlane* pmCoordSkyToTP(
    358358    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    359359    const psSphere* in,                ///< the sky coordinate
     
    365365 *  @return psPlane*    the resulting FPA coordinate
    366366 */
    367 psPlane* psCoordTPToFPA(
     367psPlane* pmCoordTPToFPA(
    368368    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    369369    const psPlane* in,                 ///< the coordinate within tangent plane
     
    378378 *  @return psPlane*    the resulting chip coordinate
    379379 */
    380 psPlane* psCoordFPAToChip(
     380psPlane* pmCoordFPAToChip(
    381381    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    382382    const psPlane* in,                 ///< the FPA coordinate
     
    389389 *  @return psPlane*    the resulting cell coordinate
    390390 */
    391 psPlane* psCoordChipToCell(
     391psPlane* pmCoordChipToCell(
    392392    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    393393    const psPlane* in,                 ///< the Chip coordinate
     
    400400 *  @return psPlane*    the resulting cell coordinate
    401401 */
    402 psPlane* psCoordSkyToCell(
     402psPlane* pmCoordSkyToCell(
    403403    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    404404    const psSphere* in,                ///< the Sky coordinate
     
    414414 *  @return psPlane*    the resulting cell coordinate
    415415 */
    416 psPlane* psCoordSkyToCellQuick(
     416psPlane* pmCoordSkyToCellQuick(
    417417    psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
    418418    const psSphere* in,                ///< the Sky coordinate
     
    420420);
    421421
    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. These
    430  *  will generally be what the user utilises, so the goal is to provide a simple
    431  *  interface providing a single type back, so the user doesnt have to go to the
    432  *  trouble of checking types, etc. These functions should employ the above three
    433  *  general lookup functions and deal with the result appropriately.
    434  *
    435  */
    436 float pmFPAGetAirmass(pmFPA *fpa); // FPA.AIRMASS
    437 psString pmFPAGetFilter(pmFPA *fpa); // FPA.FILTER
    438 float pmFPAGetPosAngle(pmFPA *fpa); // FPA.POSANGLE
    439 double pmFPAGetRA(pmFPA *fpa); // FPA.RA
    440 double pmFPAGetDec(pmFPA *fpa); // FPA.DEC
    441 psString pmFPAGetRADecSys(pmFPA *fpa); // FPA.RADECSYS
    442 psString pmFPAGetName(pmFPA *fpa); // FPA.NAME
    443 psString pmChipGetName(pmChip *chip); // CHIP.NAME
    444 psString pmCellGetName(pmCell *cell); // CELL.NAME
    445 psTime *pmCellGetTime(pmCell *cell); // CELL.TIME
    446 psList *pmCellGetBiasSec(pmCell *cell); // CELL.BIASSEC
    447 psRegion pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC
    448 float pmCellGetGain(pmCell *cell); // CELL.GAIN
    449 float pmCellGetReadNoise(pmCell *cell); // CELL.READNOISE
    450 float pmCellGetSaturation(pmCell *cell); // CELL.SATURATION
    451 float pmCellGetBad(pmCell *cell); // CELL.BAD
    452 psPixelCoord pmCellGetBin(pmCell *cell); // CELL.BIN
    453 psPixelCoord pmCellGetParity(pmCell *cell); // CELL.PARITY
    454 float pmReadoutGetExposure(pmReadout *readout); // READOUT.EXPOSURE
    455 float pmReadoutGetDarkTime(pmReadout *readout); // READOUT.DARKTIME
    456 
    457 
    458 
    459422#endif // #ifndef PS_ASTROMETRY_H
Note: See TracChangeset for help on using the changeset viewer.