IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1514


Ignore:
Timestamp:
Aug 11, 2004, 7:36:53 PM (22 years ago)
Author:
gusciora
Message:

...

Location:
trunk/psLib/src/astronomy
Files:
2 edited

Legend:

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

    r1510 r1514  
    88*  @author George Gusciora, MHPCC
    99*
    10 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-08-12 03:11:45 $
     10*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-08-12 05:36:53 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444}
    4545
    46 /*
    47     XXX: Several members of the psGrommit data structure have no direct
    48     counterpart in the psExposure structure.  How are we to determine them?
    49 */
     46extern void sla_aoppa(double date, double dut, double elongm,
     47                          double phim, double him, double xp,
     48                          double yp, double tdk, double pmb,
     49                          double rh, double wl, double tlr,
     50                          double *AOPRMS);
     51#define TBD 0.0
     52/*****************************************************************************
     53XXX: Several of the input params to sla_aoppa() are currently undefined.
     54We are awaiting futher direction from IfA on this.
     55 *****************************************************************************/
    5056psGrommit* psGrommitAlloc(const psExposure* exp)
    5157{
     
    5460    }
    5561
     62    double date = TBD;  // "mjd" in psExposure will become a psTime
     63    // from which it will be possible to get UTC.
     64    double dut = 0.0;
     65    double elongm = TBD;
     66    double phim = TBD;
     67    double hm = TBD;
     68    double xp = 0.0;
     69    double yp = 0.0;
     70    double tdk = exp->temperature;
     71    double pmb = exp->pressure;
     72    double rh = exp->humidity;
     73    double wl = exp->wavelength;
     74    double tlr = TBD;
     75    double *AOPRMS = NULL;
     76
     77    sla_aoppa(date, dut, elongm, phim, hm, xp, yp,
     78              tdk, pmb, rh, wl, tlr, AOPRMS);
     79
    5680    psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit));
    57 
    58     /*
    59      * extern void sla_aoppa(double date, double dut, double elongm, double phim, double him, double xp,
    60      * double yp, double tdk, double pmb, double rh, double wl, double tlr, double *AOPRMS);
    61      *
    62      * sla_aoppa(date, deltaUT, meanLongitude, meanLatitude, height, xp, yp, exp->temperature, exp->pressure,
    63      * exp->humidity, wavelength, tlr); */
    64     *(double *)&grommit->latitude = exp->dec;   // XXX Is this correct?
    65     *(double *)&grommit->sinLat = sin(grommit->latitude);
    66     *(double *)&grommit->cosLat = cos(grommit->latitude);
    67     *(double *)&grommit->abberationMag = 0.0;
    68     *(double *)&grommit->height = 0.0;
    69     *(double *)&grommit->temperature = exp->temperature;
    70     *(double *)&grommit->pressure = exp->pressure;
    71     *(double *)&grommit->humidity = exp->humidity;
    72     *(double *)&grommit->wavelength = 0.0;
    73     *(double *)&grommit->lapseRate = 0.0;
    74     *(double *)&grommit->refractA = 0.0;
    75     *(double *)&grommit->refractB = 0.0;
    76     *(double *)&grommit->longitudeOffset = exp->ra;     // XXX Is this correct?
    77     *(double *)&grommit->siderealTime = 0.0;
     81    *(double *)&grommit->latitude = AOPRMS[0];
     82    *(double *)&grommit->sinLat = AOPRMS[1];
     83    *(double *)&grommit->cosLat = AOPRMS[2];
     84    *(double *)&grommit->height = AOPRMS[3];
     85    *(double *)&grommit->abberationMag = AOPRMS[4];
     86    *(double *)&grommit->temperature = AOPRMS[5];
     87    *(double *)&grommit->pressure = AOPRMS[6];
     88    *(double *)&grommit->humidity = AOPRMS[7];
     89    *(double *)&grommit->wavelength = AOPRMS[8];
     90    *(double *)&grommit->lapseRate = AOPRMS[9];
     91    *(double *)&grommit->refractA = AOPRMS[10];
     92    *(double *)&grommit->refractB = AOPRMS[11];
     93    *(double *)&grommit->longitudeOffset = AOPRMS[12];
     94    *(double *)&grommit->siderealTime = AOPRMS[13];
    7895
    7996    return (grommit);
     
    92109    psPlane* chipCoord = NULL;
    93110
     111    if (fpaCoord == NULL) {
     112        psAbort(__func__, "input parameter fpaCoord is NULL.");
     113    }
    94114    if (FPA == NULL) {
    95         return(NULL);
    96     }
    97     if (fpaCoord == NULL) {
    98         return(NULL);
     115        psAbort(__func__, "input parameter FPA is NULL.");
    99116    }
    100117
     
    133150
    134151/*****************************************************************************
    135     XXX: Return the answer in "out".
     152XXX: Should we return the result in "out"?
    136153 *****************************************************************************/
    137154psChip* psChipInFPA(psChip* out,
     
    143160    psPlane* chipCoord = NULL;
    144161    psCell *tmpCell = NULL;
     162
     163    if (fpaCoord == NULL) {
     164        psAbort(__func__, "input parameter fpaCoord is NULL.");
     165    }
     166    if (FPA == NULL) {
     167        psAbort(__func__, "input parameter FPA is NULL.");
     168    }
    145169
    146170    // Loop through every chip in this FPA.  Convert the original
     
    150174    for (int i = 0; i < nChips; i++) {
    151175        psChip* tmpChip = chips->data[i];
    152 
    153         chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA, fpaCoord);
     176        chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA,
     177                                          fpaCoord);
     178
    154179        tmpCell = psCellInChip(tmpCell, chipCoord, tmpChip);
    155180        if (tmpCell != NULL) {
     
    164189
    165190/*****************************************************************************
    166 XXX: if we find no cell with has this coordinate, we return NULL.
    167 XXX: must deallocate memory.
    168 XXX: must return the cell in the "outCell" parameter.
    169 XXX: verify the NULL parameter error handling.
     191XXX: Should we return the result in "out"?
    170192 *****************************************************************************/
    171193psCell* psCellInChip(psCell* outCell,
     
    175197    psPlane* cellCoord = NULL;
    176198    psArray* cells;
    177     psReadout *tmpReadout = NULL;
    178199
    179200    // We return NULL if either of the input parameters is NULL.
     201    if (chipCoord == NULL) {
     202        psAbort(__func__, "the 'chipCoord' parameter is NULL\n");
     203    }
    180204    if (chip == NULL) {
    181         return NULL;
    182     }
    183 
    184     if (chipCoord == NULL) {
    185         return NULL;
     205        psAbort(__func__, "the 'chip' parameter is NULL\n");
    186206    }
    187207
     
    196216    for (int i = 0; i < cells->n; i++) {
    197217        psCell* tmpCell = (psCell* ) cells->data[i];
    198         // XXX: figure this out
    199         //        psReadout *tmpReadout = tmpCell->readouts;
    200 
    201         while (tmpReadout != NULL) {
    202             cellCoord = psPlaneTransformApply(cellCoord,
    203                                               tmpCell->fromChip,
    204                                               chipCoord);
    205 
    206             if (p_psCheckValidImageCoords(cellCoord->x, cellCoord->y, tmpReadout->image)) {
    207                 psFree(cellCoord);
    208                 return (tmpCell);
     218        psArray* readouts = tmpCell->readouts;
     219
     220        if (readouts != NULL) {
     221            for (int j = 0; j < readouts->n; j++) {
     222                psReadout* tmpReadout = readouts->data[j];
     223
     224                cellCoord = psPlaneTransformApply(cellCoord,
     225                                                  tmpCell->fromChip,
     226                                                  chipCoord);
     227
     228                if (p_psCheckValidImageCoords(cellCoord->x,
     229                                              cellCoord->y,
     230                                              tmpReadout->image)) {
     231                    psFree(cellCoord);
     232                    return (tmpCell);
     233                }
    209234            }
    210             tmpReadout++;
    211235        }
    212236    }
     
    220244                           const psCell* cell)
    221245{
     246    if (inCoord == NULL) {
     247        psAbort(__func__, "input parameter inCoord is NULL.");
     248    }
     249    if (cell == NULL) {
     250        psAbort(__func__, "input parameter cell is NULL.");
     251    }
     252
    222253    return (psPlaneTransformApply(outCoord, cell->toChip, inCoord));
    223254}
     
    227258                          const psChip* chip)
    228259{
     260    if (inCoord == NULL) {
     261        psAbort(__func__, "input parameter inCoord is NULL.");
     262    }
     263    if (chip == NULL) {
     264        psAbort(__func__, "input parameter chip is NULL.");
     265    }
     266
    229267    return (psPlaneTransformApply(outCoord, chip->toFPA, inCoord));
    230268}
     
    236274                        const psFPA* fpa)
    237275{
     276    if (inCoord == NULL) {
     277        psAbort(__func__, "input parameter inCoord is NULL.");
     278    }
     279    if (fpa == NULL) {
     280        psAbort(__func__, "input parameter fpa is NULL.");
     281    }
     282
    238283    return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord,
    239284                               magnitude, color));
     
    245290                         const psGrommit* grommit)
    246291{
     292    if (tpCoord == NULL) {
     293        psAbort(__func__, "input parameter tpCoord is NULL.");
     294    }
     295    if (grommit == NULL) {
     296        psAbort(__func__, "input parameter grommit is NULL.");
     297    }
    247298    if (outSphere == NULL) {
    248299        outSphere = (psSphere* ) psAlloc(sizeof(psSphere));
     
    263314                          const psCell* cell)
    264315{
     316    if (cellCoord == NULL) {
     317        psAbort(__func__, "input parameter cellCoord is NULL.");
     318    }
     319    if (cell == NULL) {
     320        psAbort(__func__, "input parameter cell is NULL.");
     321    }
     322
    265323    return (psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord));
    266324}
    267325
    268 /*****************************************************************************
    269 XXX: determine the grommit from the FPA associated with this chip.
    270  *****************************************************************************/
    271326psSphere* psCoordCellToSky(psSphere* skyCoord,
    272327                           const psPlane* cellCoord,
     
    275330                           const psCell* cell)
    276331{
     332    if (cellCoord == NULL) {
     333        psAbort(__func__, "input parameter cellCoord is NULL.");
     334    }
     335    if (cell == NULL) {
     336        psAbort(__func__, "input parameter cell is NULL.");
     337    }
     338
    277339    psPlane* fpaCoord = NULL;
    278340    psPlane* tpCoord = NULL;
     
    284346
    285347    // Convert the FPA coordinates to tangent plane Coordinates.
    286     tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, fpaCoord, magnitude, color);
     348    tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane,
     349                                  fpaCoord, magnitude, color);
    287350
    288351    // Generate a grommit for this FPA.
     
    307370                                const psCell* cell)
    308371{
     372    if (cellCoord == NULL) {
     373        psAbort(__func__, "input parameter cellCoord is NULL.");
     374    }
     375    if (cell == NULL) {
     376        psAbort(__func__, "input parameter cell is NULL.");
     377    }
     378
    309379    psPlane *tpCoord = NULL;
    310380    psChip *chip = cell->parent;
     
    340410                        const psGrommit* grommit)
    341411{
     412    if (in == NULL) {
     413        psAbort(__func__, "input parameter in is NULL.");
     414    }
     415    if (grommit == NULL) {
     416        psAbort(__func__, "input parameter grommit is NULL.");
     417    }
     418
    342419    /*
    343420        extern void sla_AOPQK(RAP, DAP, AOPRMS, AOB, ZOB, HOB, DOB, ROB);
     
    367444                        const psFPA* fpa)
    368445{
     446    if (tpCoord == NULL) {
     447        psAbort(__func__, "input parameter tpCoord is NULL.");
     448    }
     449    if (fpa == NULL) {
     450        psAbort(__func__, "input parameter fpa is NULL.");
     451    }
     452
    369453    return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane,
    370454                                tpCoord, magnitude, color));
    371455}
    372456
    373 /*****************************************************************************
    374 XXX: must first determine which chip contains this chipcoord.
    375  *****************************************************************************/
    376457psPlane* psCoordFPAToChip(psPlane* chipCoord,
    377458                          const psPlane* fpaCoord,
    378459                          const psChip* chip)
    379460{
    380     return (psPlaneTransformApply(chipCoord, chip->fromFPA, fpaCoord));
    381 }
    382 
    383 /*****************************************************************************
    384 XXX: must first determine which cell contains this chipcoord.
    385  *****************************************************************************/
     461    if (fpaCoord == NULL) {
     462        psAbort(__func__, "input parameter fpaCoord is NULL.");
     463    }
     464    if (chip == NULL) {
     465        psAbort(__func__, "input parameter chip is NULL.");
     466    }
     467
     468    psFPA *FPA = chip->parent;
     469    if (FPA == NULL) {
     470        psAbort(__func__, "chip->parent is NULL");
     471    }
     472
     473    psChip *newChip = psChipInFPA(newChip, fpaCoord, FPA);
     474    if (newChip == NULL) {
     475        return(NULL);
     476    }
     477
     478    chipCoord = psPlaneTransformApply(chipCoord, newChip->fromFPA, fpaCoord);
     479    psFree(newChip);
     480    return(chipCoord);
     481}
     482
    386483psPlane* psCoordChipToCell(psPlane* cellCoord,
    387484                           const psPlane* chipCoord,
    388485                           const psCell* cell)
    389486{
    390     return (psPlaneTransformApply(cellCoord, cell->fromChip, chipCoord));
    391 }
    392 
    393 /*****************************************************************************
    394 XXX: once this works, get rid of the individual pointers for the various
    395      coords.
    396 XXX: must determine which cell contains this chipcoord.
    397  *****************************************************************************/
     487    if (chipCoord == NULL) {
     488        psAbort(__func__, "input parameter chipCoord is NULL.");
     489    }
     490    if (cell == NULL) {
     491        psAbort(__func__, "input parameter cell is NULL.");
     492    }
     493
     494    psChip *chip = cell->parent;
     495    if (chip == NULL) {
     496        psAbort(__func__, "cell->parent is NULL");
     497    }
     498
     499    psCell *newCell = psCellInChip(newCell, chipCoord, chip);
     500    if (newCell == NULL) {
     501        return(NULL);
     502    }
     503
     504    cellCoord = psPlaneTransformApply(cellCoord, newCell->fromChip, chipCoord);
     505    psFree(newCell);
     506    return(cellCoord);
     507}
     508
    398509psPlane* psCoordSkyToCell(psPlane* cellCoord,
    399510                          const psSphere* skyCoord,
     
    402513                          const psCell* cell)
    403514{
    404     psChip *whichChip = cell->parent;
    405     psFPA *whichFPA = whichChip->parent;
    406     psGrommit* grommit = whichFPA->grommit;
     515    if (skyCoord == NULL) {
     516        psAbort(__func__, "input parameter skyCoord is NULL.");
     517    }
     518    if (cell == NULL) {
     519        psAbort(__func__, "input parameter cell is NULL.");
     520    }
     521
     522    psChip *parChip = cell->parent;
     523    psFPA *parFPA = parChip->parent;
     524    psGrommit* grommit = parFPA->grommit;
    407525
    408526    // Convert the skyCoords to tangent plane coords.
     
    411529    // Convert the tangent plane coords to FPA coords.
    412530    psPlane *fpaCoord = psCoordTPToFPA(fpaCoord, tpCoord, color,
    413                                        magnitude, whichFPA);
     531                                       magnitude, parFPA);
    414532
    415533    // Convert the FPA coords to chip coords.
    416     psPlane *chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, whichChip);
     534    psPlane *chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, parChip);
    417535
    418536    // Convert the chip coords to cell coords.
     
    427545
    428546/*****************************************************************************
    429 XXX: hmmm: does this work?
     547p_psIsProjectionLinear(): this is a private function which simply determines
     548if the supplied psPlaneTransform transform is linear: if any of the
     549cooefficients of order 2 are higher are non-zero, then it is not linear.
    430550 *****************************************************************************/
     551int p_psIsProjectionLinear(psPlaneTransform *transform)
     552{
     553    int i = 0;
     554    if (transform == NULL) {
     555        psAbort(__func__, "input parameter transform is NULL.");
     556    }
     557
     558    for (i=2;i<(transform->x->nX);i++) {
     559        if (transform->x->coeff[i][0] != 0.0) {
     560            return(0);
     561        }
     562    }
     563    for (i=2;i<(transform->x->nY);i++) {
     564        if (transform->x->coeff[0][i] != 0.0) {
     565            return(0);
     566        }
     567    }
     568
     569    for (i=2;i<(transform->y->nX);i++) {
     570        if (transform->y->coeff[i][0] != 0.0) {
     571            return(0);
     572        }
     573    }
     574    for (i=2;i<(transform->y->nY);i++) {
     575        if (transform->y->coeff[0][i] != 0.0) {
     576            return(0);
     577        }
     578    }
     579
     580    return(1);
     581}
     582
     583/*****************************************************************************
     584p_psInvertPlaneTransform(transform): : this is a private function which
     585simply inverts the supplied psPlaneTransform transform.  It assumes that
     586"transform" is linear.
     587 *****************************************************************************/
     588psPlaneTransform *p_psInvertPlaneDistortTransform(psPlaneTransform *transform)
     589{
     590    if (transform == NULL) {
     591        psAbort(__func__, "input parameter transform is NULL.");
     592    }
     593    psPlaneTransform *out = psAlloc(sizeof(psPlaneTransform));
     594
     595    // XXX: figure it out
     596    return(out);
     597}
     598
    431599psPlane* psCoordSkyToCellQuick(psPlane* cellCoord,
    432600                               const psSphere* skyCoord,
    433601                               const psCell* cell)
    434602{
     603    if (skyCoord == NULL) {
     604        psAbort(__func__, "input parameter skyCoord is NULL.");
     605    }
     606    if (cell == NULL) {
     607        psAbort(__func__, "input parameter cell is NULL.");
     608    }
     609
    435610    psPlane *tpCoord = NULL;
    436611    psChip *whichChip = cell->parent;
     
    449624    tpCoord = psProject(skyCoord, whichFPA->projection);
    450625
    451     // XXX: generate an error if cell->toTP is not linear.
    452 
    453     // XXX: Invert cell->toTP, store in TPtoCell.
     626    // generate an error if cell->toTP is not linear.
     627    if (0 == p_psIsProjectionLinear(cell->toTP)) {
     628        psAbort(__func__, "the cell->toTP transfrom is not linear.\n");
     629    }
     630
     631    TPtoCell = p_psInvertPlaneDistortTransform(cell->toTP);
    454632    cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord);
    455633
  • trunk/psLib/src/astronomy/psAstrometry.h

    r1510 r1514  
    88*  @author George Gusciora, MHPCC
    99*
    10 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-08-12 03:11:45 $
     10*  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-08-12 05:36:53 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    204204    const float humidity;              ///< Relative humidity, for refraction
    205205    const float exposureTime;          ///< Exposure time
     206    const double wavelength;           ///< Wavelength
    206207
    207208    /* Derived quantities */
Note: See TracChangeset for help on using the changeset viewer.