IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2052


Ignore:
Timestamp:
Oct 12, 2004, 9:10:00 AM (22 years ago)
Author:
desonia
Message:

fixed psGrommitAlloc, SLALIB calls, added tests for psFPAAlloc and psChipAlloc.

Location:
trunk/psLib
Files:
3 edited

Legend:

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

    r2048 r2052  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-12 01:34:09 $
     10 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-10-12 19:10:00 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    352352    newFPA->toTangentPlane = NULL;
    353353    newFPA->pattern = NULL;
    354     newFPA->exposure = psMemIncrRefCounter((psExposure*)exp);
    355     newFPA->grommit = psGrommitAlloc(exp);
     354
     355    if (exp != NULL) {
     356        newFPA->exposure = psMemIncrRefCounter((psExposure*)exp);
     357        newFPA->grommit = psGrommitAlloc(exp);
     358    } else {
     359        newFPA->exposure = NULL;
     360        newFPA->grommit = NULL;
     361    }
    356362
    357363    newFPA->colorPlus = NULL;
     
    455461psGrommit* psGrommitAlloc(const psExposure* exp)
    456462{
    457     double* AOPRMS = psAlloc(sizeof(double)*14);
    458 
    459463    if (exp == NULL) {
    460464        psAbort(__func__, "the 'exp' parameter is NULL\n");
     
    478482    double tlr = exp->observatory->tlr;
    479483
     484    psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit));
     485
    480486    slaAoppa(date, dut, elongm, phim, hm, xp, yp,
    481              tdk, pmb, rh, wl, tlr, AOPRMS);
    482 
    483     psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit));
    484     *(double *)&grommit->latitude = AOPRMS[0];
    485     *(double *)&grommit->sinLat = AOPRMS[1];
    486     *(double *)&grommit->cosLat = AOPRMS[2];
    487     *(double *)&grommit->height = AOPRMS[3];
    488     *(double *)&grommit->abberationMag = AOPRMS[4];
    489     *(double *)&grommit->temperature = AOPRMS[5];
    490     *(double *)&grommit->pressure = AOPRMS[6];
    491     *(double *)&grommit->humidity = AOPRMS[7];
    492     *(double *)&grommit->wavelength = AOPRMS[8];
    493     *(double *)&grommit->lapseRate = AOPRMS[9];
    494     *(double *)&grommit->refractA = AOPRMS[10];
    495     *(double *)&grommit->refractB = AOPRMS[11];
    496     *(double *)&grommit->longitudeOffset = AOPRMS[12];
    497     *(double *)&grommit->siderealTime = AOPRMS[13];
    498 
    499     psFree(AOPRMS);
     487             tdk, pmb, rh, wl, tlr, (double*)grommit);
    500488
    501489    return (grommit);
     
    680668    }
    681669
    682     slaAopqk(tpCoord->x, tpCoord->y, (double *) grommit,
     670    slaAopqk(tpCoord->x, tpCoord->y, (double*)grommit,
    683671             &AOB, &ZOB, &HOB, &outSphere->r, &outSphere->d);
    684672
     
    782770                        const psGrommit* grommit)
    783771{
     772    char* type = "RA";
     773
    784774    if (in == NULL) {
    785775        psAbort(__func__, "input parameter in is NULL.");
     
    792782    }
    793783
    794     slaOapqk("RA", in->r, in->d, (double *) grommit, &tpCoord->x, &tpCoord->y);
     784    slaOapqk(type, in->r, in->d, (double*)grommit, &tpCoord->x, &tpCoord->y);
    795785
    796786    return(tpCoord);
  • trunk/psLib/src/astronomy/slalib.h

    r1630 r2052  
    77*  @author Robert DeSonia, MHPCC
    88*
    9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2004-08-26 21:11:55 $
     9*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2004-10-12 19:10:00 $
    1111*
    1212*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#ifdef FORTRAN_DOUBLE_UNDERSCORE_SUFFIX
    2020#ifdef FORTRAN_UPPERCASE
    21 #define slaAoppa _SLA_AOPPA__
    22 #define slaAopqk _SLA_AOPQK__
    23 #define slaOapqk _SLA_OAPQK__
     21#define fslaAoppa _SLA_AOPPA__
     22#define fslaAopqk _SLA_AOPQK__
     23#define fslaOapqk _SLA_OAPQK__
    2424#else
    25 #define slaAoppa _sla_aoppa__
    26 #define slaAopqk _sla_aopqk__
    27 #define slaOapqk _sla_oapqk__
     25#define fslaAoppa _sla_aoppa__
     26#define fslaAopqk _sla_aopqk__
     27#define fslaOapqk _sla_oapqk__
    2828#endif
    2929#elif FORTRAN_NO_UNDERSCORE_SUFFIX
    3030#ifdef FORTRAN_UPPERCASE
    31 #define slaAoppa _SLA_AOPPA
    32 #define slaAopqk _SLA_AOPQK
    33 #define slaOapqk _SLA_OAPQK
     31#define fslaAoppa _SLA_AOPPA
     32#define fslaAopqk _SLA_AOPQK
     33#define fslaOapqk _SLA_OAPQK
    3434#else
    35 #define slaAoppa _sla_aoppa
    36 #define slaAopqk _sla_aopqk
    37 #define slaOapqk _sla_oapqk
     35#define fslaAoppa _sla_aoppa
     36#define fslaAopqk _sla_aopqk
     37#define fslaOapqk _sla_oapqk
    3838#endif
    3939#else
    4040#ifdef FORTRAN_UPPERCASE
    41 #define slaAoppa _SLA_AOPPA_
    42 #define slaAopqk _SLA_AOPQK_
    43 #define slaOapqk _SLA_OAPQK_
     41#define fslaAoppa _SLA_AOPPA_
     42#define fslaAopqk _SLA_AOPQK_
     43#define fslaOapqk _SLA_OAPQK_
    4444#else
    45 #define slaAoppa _sla_aoppa_
    46 #define slaAopqk _sla_aopqk_
    47 #define slaOapqk _sla_oapqk_
     45#define fslaAoppa _sla_aoppa_
     46#define fslaAopqk _sla_aopqk_
     47#define fslaOapqk _sla_oapqk_
    4848#endif
    4949#endif
     
    5151#ifdef FORTRAN_DOUBLE_UNDERSCORE_SUFFIX
    5252#ifdef FORTRAN_UPPERCASE
    53 #define slaAoppa SLA_AOPPA__
    54 #define slaAopqk SLA_AOPQK__
    55 #define slaOapqk SLA_OAPQK__
     53#define fslaAoppa SLA_AOPPA__
     54#define fslaAopqk SLA_AOPQK__
     55#define fslaOapqk SLA_OAPQK__
    5656#else
    57 #define slaAoppa sla_aoppa__
    58 #define slaAopqk sla_aopqk__
    59 #define slaOapqk sla_oapqk__
     57#define fslaAoppa sla_aoppa__
     58#define fslaAopqk sla_aopqk__
     59#define fslaOapqk sla_oapqk__
    6060#endif
    6161#elif FORTRAN_NO_UNDERSCORE_SUFFIX
    6262#ifdef FORTRAN_UPPERCASE
    63 #define slaAoppa SLA_AOPPA
    64 #define slaAopqk SLA_AOPQK
    65 #define slaOapqk SLA_OAPQK
     63#define fslaAoppa SLA_AOPPA
     64#define fslaAopqk SLA_AOPQK
     65#define fslaOapqk SLA_OAPQK
    6666#else
    67 #define slaAoppa sla_aoppa
    68 #define slaAopqk sla_aopqk
    69 #define slaOapqk sla_oapqk
     67#define fslaAoppa sla_aoppa
     68#define fslaAopqk sla_aopqk
     69#define fslaOapqk sla_oapqk
    7070#endif
    7171#else
    7272#ifdef FORTRAN_UPPERCASE
    73 #define slaAoppa SLA_AOPPA_
    74 #define slaAopqk SLA_AOPQK_
    75 #define slaOapqk SLA_OAPQK_
     73#define fslaAoppa SLA_AOPPA_
     74#define fslaAopqk SLA_AOPQK_
     75#define fslaOapqk SLA_OAPQK_
    7676#else
    77 #define slaAoppa sla_aoppa_
    78 #define slaAopqk sla_aopqk_
    79 #define slaOapqk sla_oapqk_
     77#define fslaAoppa sla_aoppa_
     78#define fslaAopqk sla_aopqk_
     79#define fslaOapqk sla_oapqk_
    8080#endif
    8181#endif
    8282#endif
    8383
    84 extern void slaAoppa (
    85         double date,
    86         double dut,
    87         double elongm,
    88         double phim,
    89         double him,
    90         double xp,
    91         double yp,
    92         double tdk,
    93         double pmb,
    94         double rh,
    95         double wl,
    96         double tlr,
    97         double *AOPRMS
     84extern void fslaAoppa(
     85        const double* date,
     86        const double* dut,
     87        const double* elongm,
     88        const double* phim,
     89        const double* him,
     90        const double* xp,
     91        const double* yp,
     92        const double* tdk,
     93        const double* pmb,
     94        const double* rh,
     95        const double* wl,
     96        const double* tlr,
     97        double* AOPRMS
    9898    );
    9999
    100 extern void slaAopqk (
    101         double RAP,
    102         double DAP,
    103         double *AOPRMS,
    104         double *AOB,
    105         double *ZOB,
    106         double *HOB,
    107         double *DOB,
    108         double *ROB
     100extern void fslaAopqk(
     101        const double* RAP,
     102        const double* DAP,
     103        double* AOPRMS,
     104        double* AOB,
     105        double* ZOB,
     106        double* HOB,
     107        double* DOB,
     108        double* ROB
    109109    );
    110110
    111 extern void slaOapqk (
    112         char *TYPE,
    113         double OB1,
    114         double OB2,
    115         double *AOPRMS,
    116         double *RAP,
    117         double *DAP
     111extern void fslaOapqk(
     112        char* TYPE,
     113        const double* OB1,
     114        const double* OB2,
     115        double* AOPRMS,
     116        double* RAP,
     117        double* DAP
    118118    );
    119119
     120/*
     121    void slaAoppa(date, dut, elongm, phim, hm, xp, yp, tdk, pmb, rh, wl, tlr, aoprms)
     122   
     123    PARAMETERS
     124   
     125    double date
     126    double dut
     127    double elongm
     128    double phim
     129    double hm
     130    double xp
     131    double yp
     132    double tdk
     133    double pmb
     134    double rh
     135    double wl
     136    double tlr
     137    double *aoprms
     138*/
     139#define slaAoppa(date,dut,elongm,phim,him,xp,yp,tdk,pmb,rh,wl,tlr,AOPRMS) \
     140fslaAoppa(&date,&dut,&elongm,&phim,&him,&xp,&yp,&tdk,&pmb,&rh,&wl,&tlr,AOPRMS)
     141
     142/*
     143    void slaAopqk(rap, dap, aoprms, aob, zob, hob, dob, rob)
     144   
     145    PARAMETERS
     146   
     147    double rap
     148    double dap
     149    double *aoprms
     150    double *aob
     151    double *zob
     152    double *hob
     153    double *dob
     154    double *rob
     155*/
     156
     157#define slaAopqk(RAP,DAP,AOPRMS,AOB,ZOB,HOB,DOB,ROB) \
     158fslaAopqk(&RAP,&DAP,AOPRMS,AOB,ZOB,HOB,DOB,ROB)
     159
     160/*
     161    void slaOapqk(type, ob1, ob2, aoprms, rap, dap)
     162   
     163    PARAMETERS
     164   
     165    char *type
     166    double ob1
     167    double ob2
     168    double *aoprms
     169    double *rap
     170    double *dap
     171*/
     172
     173#define slaOapqk(TYPE, OB1, OB2, AOPRMS, RAP, DAP) \
     174fslaOapqk(TYPE, &OB1, &OB2, AOPRMS, RAP, DAP)
     175
    120176#endif
  • trunk/psLib/test/astronomy/tst_psAstrometry.c

    r2048 r2052  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-12 01:34:09 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-12 19:10:00 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020static int testObservatoryAlloc(void);
    2121static int testFPAAlloc(void);
    22 // static int testGrommitAlloc(void);
     22static int testChipAlloc(void);
    2323
    2424testDescription tests[] = {
     
    2626                              {testObservatoryAlloc,736,"psObservatoryAlloc",0,false},
    2727                              {testFPAAlloc,739,"psFPAAlloc",0,false},
     28                              {testChipAlloc,740,"psChipAlloc",0,false},
    2829                              {NULL}
    2930                          };
     
    319320    psFree(exp);
    320321    psFree(obs);
     322    psFree(now);
    321323
    322324    return 0;
    323325}
     326
     327static int testChipAlloc(void)
     328{
     329    char* name = "The Kaiser Royal Observatory";
     330
     331    psTime* now = psTimeGetTime(PS_TIME_UTC);
     332
     333    psObservatory* obs = psObservatoryAlloc(name,
     334                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f);
     335
     336    psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0,
     337                                      now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs);
     338
     339    psFPA* fpa = psFPAAlloc(8, exp);
     340
     341    // N.B. psFPAAlloc made made a reference to any of these that it is
     342    // referencing, so these don't necessary are actually freed here.  Just
     343    // these references to the buffers are freed.
     344    psFree(exp);
     345    psFree(obs);
     346    psFree(now);
     347
     348    /*
     349        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify
     350           that:
     351        a. the cells array is of the size nCells and all elements are NULL.
     352        b. parent attribute is set to parentFPA parameter and the ref. count
     353           was incremented.
     354        c. all other attributes are initialized to NULL or 0.
     355    */
     356
     357    psChip* chip = psChipAlloc(8, fpa);
     358
     359    if (chip == NULL) {
     360        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     361        return 1;
     362    }
     363
     364    if (chip->cells->n != 8) {
     365        psLogMsg(__func__,PS_LOG_ERROR,
     366                 "psChipAlloc did not set the number of cells properly.");
     367        return 2;
     368    }
     369
     370    for (int lcv=0; lcv < 8; lcv++) {
     371        if (chip->cells->data[lcv] != NULL) {
     372            psLogMsg(__func__,PS_LOG_ERROR,
     373                     "psChipAlloc did not set cell %d to NULL.", lcv);
     374            return 3;
     375        }
     376    }
     377
     378    if (chip->parent != fpa) {
     379        psLogMsg(__func__,PS_LOG_ERROR,
     380                 "psChipAlloc did not set the parent properly.");
     381        return 4;
     382    }
     383
     384    if (psMemGetRefCounter(fpa) != 2) {
     385        psLogMsg(__func__,PS_LOG_ERROR,
     386                 "psChipAlloc did not increment reference counter for parent FPA.");
     387        return 5;
     388    }
     389
     390    if (chip->metadata != NULL) {
     391        psLogMsg(__func__,PS_LOG_ERROR,
     392                 "psChipAlloc did not set metadata to NULL.");
     393        return 6;
     394    }
     395
     396    if (chip->toFPA != NULL) {
     397        psLogMsg(__func__,PS_LOG_ERROR,
     398                 "psChipAlloc did not set toFPA to NULL.");
     399        return 7;
     400    }
     401
     402    if (chip->fromFPA != NULL) {
     403        psLogMsg(__func__,PS_LOG_ERROR,
     404                 "psChipAlloc did not set fromFPA to NULL.");
     405        return 8;
     406    }
     407
     408    /*
     409        2. invoke psChipAlloc with nCells = 0. Verify that:
     410        a. execution does not halt
     411        b. the cells array is of the size of zero.   
     412    */
     413
     414    psChip* chip2 = psChipAlloc(0,fpa);
     415
     416    if (chip2 == NULL) {
     417        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     418        return 11;
     419    }
     420
     421    if (chip2->cells->n != 0) {
     422        psLogMsg(__func__,PS_LOG_ERROR,
     423                 "psChipAlloc did not set the number of cells properly.");
     424        return 12;
     425    }
     426
     427    if (chip2->parent != fpa) {
     428        psLogMsg(__func__,PS_LOG_ERROR,
     429                 "psChipAlloc did not set the parent properly.");
     430        return 14;
     431    }
     432
     433    if (psMemGetRefCounter(fpa) != 3) {
     434        psLogMsg(__func__,PS_LOG_ERROR,
     435                 "psChipAlloc did not increment reference counter for parent FPA.");
     436        return 15;
     437    }
     438
     439    /*
     440        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
     441           attribute is NULL and no error is generated.
     442    */
     443
     444    psChip* chip3 = psChipAlloc(8,NULL);
     445
     446    if (chip3 == NULL) {
     447        psLogMsg(__func__,PS_LOG_ERROR,"psChipAlloc returned NULL.");
     448        return 21;
     449    }
     450
     451    if (chip3->cells->n != 8) {
     452        psLogMsg(__func__,PS_LOG_ERROR,
     453                 "psChipAlloc did not set the number of cells properly.");
     454        return 22;
     455    }
     456
     457    if (chip3->parent != NULL) {
     458        psLogMsg(__func__,PS_LOG_ERROR,
     459                 "psChipAlloc did not set the parent to NULL.");
     460        return 24;
     461    }
     462
     463    psFree(chip);
     464    psFree(chip2);
     465    psFree(chip3);
     466    psFree(fpa);
     467
     468    return 0;
     469}
Note: See TracChangeset for help on using the changeset viewer.