IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2097


Ignore:
Timestamp:
Oct 13, 2004, 2:06:17 PM (22 years ago)
Author:
gusciora
Message:

Added a few macros and such.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astronomy/psAstrometry.c

    r2077 r2097  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-13 19:40:42 $
     10 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-10-14 00:06:17 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    504504                    const psFPA* FPA)
    505505{
     506    //printf("Entering psCellInFPA()\n");
    506507    psChip* tmpChip = NULL;
    507     psPlane* chipCoord = NULL;
     508    psPlane chipCoord;
    508509    psCell* outCell = NULL;
    509510
    510     if (fpaCoord == NULL) {
    511         psAbort(__func__, "input parameter fpaCoord is NULL.");
    512     }
    513     if (FPA == NULL) {
    514         psAbort(__func__, "input parameter FPA is NULL.");
    515     }
     511    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
     512    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
    516513
    517514    // Determine which chip contains the fpaCoords.
    518515    tmpChip = psChipInFPA(fpaCoord, FPA);
     516    if (tmpChip == NULL) {
     517        return(NULL);
     518    }
    519519
    520520    // Convert to those chip coordinates.
    521     chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, tmpChip);
     521    psCoordFPAToChip(&chipCoord, fpaCoord, tmpChip);
    522522
    523523    // Determine which cell contains those chip coordinates.
    524     outCell = psCellInChip(chipCoord, tmpChip);
    525 
    526     psFree(tmpChip);
    527     psFree(chipCoord);
    528 
     524    outCell = psCellInChip(&chipCoord, tmpChip);
     525
     526    //printf("Exiting psCellInFPA()\n");
    529527    return (outCell);
    530528}
     
    533531                    const psFPA* FPA)
    534532{
     533    //printf("Entering psChipInFPA()\n");
     534    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
     535    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
     536    PS_CHECK_NULL_PTR_RETURN_NULL(FPA->chips);
    535537    psArray* chips = FPA->chips;
    536538    int nChips = chips->n;
    537     psPlane* chipCoord = NULL;
     539    psPlane chipCoord;
    538540    psCell *tmpCell = NULL;
    539 
    540     if (fpaCoord == NULL) {
    541         psAbort(__func__, "input parameter fpaCoord is NULL.");
    542     }
    543     if (FPA == NULL) {
    544         psAbort(__func__, "input parameter FPA is NULL.");
    545     }
    546541
    547542    // Loop through every chip in this FPA.  Convert the original
     
    550545    // coordinates.
    551546    for (int i = 0; i < nChips; i++) {
     547        //printf("HERE 01 (checking chip %d)\n", i);
    552548        psChip* tmpChip = chips->data[i];
    553         chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA,
    554                                           fpaCoord);
    555 
    556         tmpCell = psCellInChip(chipCoord, tmpChip);
     549        psPlaneTransformApply(&chipCoord, tmpChip->fromFPA, fpaCoord);
     550
     551        tmpCell = psCellInChip(&chipCoord, tmpChip);
    557552        if (tmpCell != NULL) {
    558             psFree(chipCoord);
     553            //printf("Exiting psChipInFPA()\n");
    559554            return(tmpChip);
    560555        }
    561         psFree(chipCoord);
    562     }
    563 
     556    }
     557
     558    //printf("Exiting psChipInFPA()\n");
    564559    return (NULL);
    565560}
     
    568563                     const psChip* chip)
    569564{
    570     psPlane* cellCoord = NULL;
     565    //printf("Entering psCellInChip(%f, %f, %d)\n", chipCoord->x, chipCoord->y, chip);
     566    PS_CHECK_NULL_PTR_RETURN_NULL(chipCoord);
     567    PS_CHECK_NULL_PTR_RETURN_NULL(chip);
     568
     569    psPlane cellCoord;
    571570    psArray* cells;
    572 
    573     // We return NULL if either of the input parameters is NULL.
    574     if (chipCoord == NULL) {
    575         psAbort(__func__, "the 'chipCoord' parameter is NULL\n");
    576     }
    577     if (chip == NULL) {
    578         psAbort(__func__, "the 'chip' parameter is NULL\n");
    579     }
    580571
    581572    cells = chip->cells;
    582573    if (cells == NULL) {
     574        //printf("Exiting psCellInChip()\n");
    583575        return NULL;
    584576    }
     
    587579    // a cellCoord for that cell and determine if that cellCoord is valid.
    588580    // If so, then we return that cell.
     581
    589582    for (int i = 0; i < cells->n; i++) {
    590583        psCell* tmpCell = (psCell* ) cells->data[i];
     
    595588                psReadout* tmpReadout = readouts->data[j];
    596589
    597                 cellCoord = psPlaneTransformApply(cellCoord,
    598                                                   tmpCell->fromChip,
    599                                                   chipCoord);
    600 
    601                 if (checkValidImageCoords(cellCoord->x,
    602                                           cellCoord->y,
     590                psPlaneTransformApply(&cellCoord,
     591                                      tmpCell->fromChip,
     592                                      chipCoord);
     593
     594                if (checkValidImageCoords(cellCoord.x,
     595                                          cellCoord.y,
    603596                                          tmpReadout->image)) {
    604                     psFree(cellCoord);
     597                    //printf("Exiting psCellInChip()\n");
    605598                    return (tmpCell);
    606599                }
     
    609602    }
    610603
    611     psFree(cellCoord);
     604    //printf("Exiting psCellInChip()\n");
    612605    return (NULL);
    613606}
Note: See TracChangeset for help on using the changeset viewer.