IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1665


Ignore:
Timestamp:
Aug 31, 2004, 2:57:48 PM (22 years ago)
Author:
desonia
Message:

added constructors for the astronomical imagery structs.

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

Legend:

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

    r1543 r1665  
    88*  @author George Gusciora, MHPCC
    99*
    10 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-08-14 01:51:11 $
     10*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-09-01 00:57:48 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050/*****************************************************************************/
    5151
    52 void p_psGrommitFree(psGrommit* grommit)
    53 {
    54     psFree(grommit);
    55 }
    56 
    5752/*****************************************************************************
    58 p_psCheckValidImageCoords(): this is a private function which simply
     53checkValidImageCoords(): this is a private function which simply
    5954determines if the supplied x,y coordinates are in the range for the supplied
    6055psImage.
    6156 *****************************************************************************/
    62 int p_psCheckValidImageCoords(double x,
    63                               double y,
    64                               psImage* tmpImage)
     57static int checkValidImageCoords(double x,
     58                                 double y,
     59                                 psImage* tmpImage)
    6560{
    6661    if (tmpImage == NULL) {
     
    7974
    8075/*****************************************************************************
    81 p_psIsProjectionLinear(): this is a private function which simply determines
     76isProjectionLinear(): this is a private function which simply determines
    8277if the supplied psPlaneTransform transform is linear: if any of the
    8378cooefficients of order 2 are higher are non-zero, then it is not linear.
    8479 *****************************************************************************/
    85 int p_psIsProjectionLinear(psPlaneTransform *transform)
     80static int isProjectionLinear(psPlaneTransform *transform)
    8681{
    8782    int i = 0;
     
    116111
    117112/*****************************************************************************
    118 p_psInvertPlaneTransform(transform): : this is a private function which
     113invertPlaneTransform(transform): : this is a private function which
    119114simply inverts the supplied psPlaneTransform transform.  It assumes that
    120115"transform" is linear.
     
    134129             (Y2 * (1.0 / (F - ((C*E)/B))));
    135130 *****************************************************************************/
    136 psPlaneTransform *p_psInvertPlaneTransform(psPlaneTransform *transform)
     131static psPlaneTransform *invertPlaneTransform(psPlaneTransform *transform)
    137132{
    138133    double A = transform->x->coeff[0][0];
     
    158153}
    159154
     155static void FPAFree(psFPA* fpa)
     156{
     157    if (fpa != NULL) {
     158        psFree(fpa->chips);
     159        psFree(fpa->grommit);
     160        psFree((psExposure*)fpa->exposure);
     161        psFree(fpa->metadata);
     162        psFree(fpa->fromTangentPlane);
     163        psFree(fpa->toTangentPlane);
     164        psFree(fpa->pattern);
     165        psFree(fpa->colorPlus);
     166        psFree(fpa->colorMinus);
     167        psFree(fpa->projection);
     168    }
     169}
     170
     171static void chipFree(psChip* chip)
     172{
     173    if (chip != NULL) {
     174        psFree(chip->cells);
     175        psFree(chip->parent);
     176        psFree(chip->metadata);
     177        psFree(chip->toFPA);
     178        psFree(chip->fromFPA);
     179    }
     180}
     181
     182static void cellFree(psCell* cell)
     183{
     184    if (cell != NULL) {
     185        psFree(cell->readouts);
     186        psFree(cell->metadata);
     187        psFree(cell->toChip);
     188        psFree(cell->fromChip);
     189        psFree(cell->toFPA);
     190        psFree(cell->toTP);
     191        psFree(cell->parent);
     192    }
     193}
     194
     195static void readoutFree(psReadout* readout)
     196{
     197    if (readout != NULL) {
     198        psFree(readout->image);
     199        psFree(readout->objects);
     200        psFree(readout->metadata);
     201    }
     202}
     203
    160204/*****************************************************************************/
    161205/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
    162206/*****************************************************************************/
     207
    163208psExposure* psExposureAlloc(double ra, double dec, double hourAngle,
    164209                            double zenith, double azimuth, double localTime, float date,
     
    183228    return exp;
    184229}
     230
     231/*
     232 * psFPA constructor
     233 */
     234psFPA* psFPAAlloc(int nChips,
     235                  const psExposure* exp)
     236{
     237    psFPA* newFPA = psAlloc(sizeof(psFPA));
     238
     239    // create array of NULL chips of the size nChips
     240    newFPA->chips = psArrayAlloc(nChips);
     241    void** chips = newFPA->chips->data;
     242    for (int i=0;i<nChips;i++) {
     243        chips[i] = NULL;
     244    }
     245
     246    newFPA->metadata = NULL;
     247    newFPA->fromTangentPlane = NULL;
     248    newFPA->toTangentPlane = NULL;
     249    newFPA->pattern = NULL;
     250    newFPA->exposure = psMemIncrRefCounter((psExposure*)exp);
     251    newFPA->grommit = psGrommitAlloc(exp);
     252
     253    newFPA->colorPlus = NULL;
     254    newFPA->colorMinus = NULL;
     255    newFPA->projection = NULL;
     256
     257    newFPA->rmsX = 0.0f;
     258    newFPA->rmsY = 0.0f;
     259    newFPA->chi2 = 0.0f;
     260
     261    p_psMemSetDeallocator(newFPA,(psFreeFcn)FPAFree);
     262
     263    return newFPA;
     264}
     265
     266/*
     267 * psChip constructor
     268 */
     269psChip* psChipAlloc(int nCells,
     270                    psFPA *parentFPA)
     271{
     272    psChip* chip = psAlloc(sizeof(psChip));
     273
     274    // create array of NULL psCells
     275    chip->cells = psArrayAlloc(nCells);
     276    void** cells = chip->cells->data;
     277    for (int i=0;i<nCells;i++) {
     278        cells[i] = NULL;
     279    }
     280
     281    chip->metadata = NULL;
     282
     283    chip->toFPA = NULL;
     284    chip->fromFPA = NULL;
     285
     286    chip->parent = psMemIncrRefCounter(parentFPA);
     287
     288    p_psMemSetDeallocator(chip,(psFreeFcn)chipFree);
     289
     290    return chip;
     291
     292}
     293
     294/*
     295 * psCell constructor
     296 */
     297psCell* psCellAlloc(int nReadouts,
     298                    psChip* parentChip)
     299{
     300    psCell* cell = psAlloc(sizeof(psCell));
     301
     302    // create array of NULL psReadouts
     303    cell->readouts = psArrayAlloc(nReadouts);
     304    void** readouts = cell->readouts->data;
     305    for (int i=0;i<nReadouts;i++) {
     306        readouts[i] = NULL;
     307    }
     308
     309    cell->metadata = NULL;
     310
     311    cell->toChip = NULL;
     312    cell->fromChip = NULL;
     313    cell->toFPA = NULL;
     314    cell->toTP = NULL;
     315
     316    cell->parent = psMemIncrRefCounter(parentChip);
     317
     318    p_psMemSetDeallocator(cell,(psFreeFcn)cellFree);
     319
     320    return cell;
     321
     322
     323}
     324
     325psReadout* psReadoutAlloc(int col0,
     326                          int row0,
     327                          const psImage* image)
     328{
     329    psReadout* readout = psAlloc(sizeof(psReadout));
     330
     331    *(unsigned int*)&readout->colBins = 1;
     332    *(unsigned int*)&readout->rowBins = 1;
     333    *(int*)&readout->col0 = col0;
     334    *(int*)&readout->row0 = row0;
     335
     336    readout->image = psMemIncrRefCounter((psImage*)image);
     337    readout->objects = NULL;
     338    readout->metadata = NULL;
     339
     340    p_psMemSetDeallocator(readout,(psFreeFcn)readoutFree);
     341
     342    return readout;
     343}
     344
    185345#define TBD 0.0
    186346/*****************************************************************************
     
    194354    }
    195355
    196     double date = TBD;  // "mjd" in psExposure will become a psTime
     356    double date = TBD;  // XXX: "mjd" in psExposure will become a psTime
    197357    // from which it will be possible to get UTC.
    198358    double dut = 0.0;
    199     double elongm = TBD;
    200     double phim = TBD;
    201     double hm = TBD;
     359    double elongm = TBD; // XXX
     360    double phim = TBD;   // XXX
     361    double hm = TBD;     // XXX
    202362    double xp = 0.0;
    203363    double yp = 0.0;
     
    206366    double rh = exp->humidity;
    207367    double wl = exp->wavelength;
    208     double tlr = TBD;
     368    double tlr = TBD;    // XXX
    209369    double *AOPRMS = NULL;
    210370
     
    329489                                                  chipCoord);
    330490
    331                 if (p_psCheckValidImageCoords(cellCoord->x,
    332                                               cellCoord->y,
    333                                               tmpReadout->image)) {
     491                if (checkValidImageCoords(cellCoord->x,
     492                                          cellCoord->y,
     493                                          tmpReadout->image)) {
    334494                    psFree(cellCoord);
    335495                    return (tmpCell);
     
    651811
    652812    // generate an error if cell->toTP is not linear.
    653     if (0 == p_psIsProjectionLinear(cell->toTP)) {
     813    if (0 == isProjectionLinear(cell->toTP)) {
    654814        psAbort(__func__, "the cell->toTP transfrom is not linear.\n");
    655815    }
    656816
    657     TPtoCell = p_psInvertPlaneTransform(cell->toTP);
     817    TPtoCell = invertPlaneTransform(cell->toTP);
    658818    cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord);
    659819
  • trunk/psLib/src/astronomy/psAstrometry.h

    r1530 r1665  
    88*  @author George Gusciora, MHPCC
    99*
    10 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-08-13 22:41:24 $
     10*  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2004-09-01 00:57:48 $
    1212*
    1313*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    239239);
    240240
     241/** Allocator for psFPA
     242 *
     243 *  This function shall make an empty psFPA, with the nChips allocated
     244 *  pointers to psChips being set to NULL; all other pointers in the structure
     245 *  shall be initialized to NULL, apart from the grommit, which shall be
     246 *  constructed on the basis of the exp parameter.
     247 *
     248 *  @return psFPA*    a newly allocated psFPA
     249 */
     250psFPA* psFPAAlloc(
     251    int nChips,                        ///< number of chips in the FPA
     252    const psExposure* exp              ///< the exposure information
     253);
     254
     255/** Allocates a psChip
     256 *
     257 *  This allocator shall make an empty psChip, with the nCells allocated
     258 *  pointers to psCells being set to NULL; all other pointers in the structure
     259 *  shall be initialized to NULL.
     260 *
     261 *  @return psChip*    newly allocated psChip
     262 */
     263psChip* psChipAlloc(
     264    int nCells,                        ///< number of cells in Chip
     265    psFPA* parentFPA                   ///< parent FPA
     266);
     267
     268/** Allocates a psCell
     269 *
     270 *  The constructor shall make an empty psCell, with the nReadouts allocated
     271 *  pointers to psReadouts being set to NULL; all other pointers in the
     272 *  structure shall be initialized to NULL.
     273 *
     274 *  @return psCell*    newly allocated psCell
     275 */
     276psCell* psCellAlloc(
     277    int nReadouts,                     ///< number of readouts in cell
     278    psChip* parentChip                 ///< parent Chip
     279);
     280
     281/** Allocates a psReadout
     282 *
     283 *  All pointers in the structure other than the image shall be initialized
     284 *  to NULL.
     285 *
     286 *  @return psReadout*    newly allocated psReadout
     287 */
     288psReadout* psReadoutAlloc(
     289    int col0,                          ///< offset from the left of the cell
     290    int row0,                          ///< offset from the bottom of the cell
     291    const psImage* image               ///< image of the readout
     292);
     293
    241294/** Allocates a Wallace's Grommit structure.
    242295 *
     
    246299 *  @return psGrommit* New grommit structure.
    247300 */
    248 psGrommit* psGrommitAlloc(const psExposure* exp        ///< the cooresponding exposure structure.
    249                          );
    250 void p_psGrommitFree(psGrommit *grommit);
    251301psGrommit* psGrommitAlloc(
    252302    const psExposure* exp              ///< the cooresponding exposure structure.
Note: See TracChangeset for help on using the changeset viewer.