IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2004, 11:30:14 AM (22 years ago)
Author:
desonia
Message:

added psObservatory.

File:
1 edited

Legend:

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

    r1967 r1981  
    11/** @file  psAstrometry.c
    2 *
    3 *  @brief This file defines the basic types for astronomical coordinate
    4 *  transformation
    5 *
    6 *  @ingroup AstroImage
    7 *
    8 *  @author George Gusciora, MHPCC
    9 *
    10 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2004-10-06 00:44:16 $
    12 *
    13 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    14 */
     2 *
     3 *  @brief This file defines the basic types for astronomical coordinate
     4 *  transformation
     5 *
     6 *  @ingroup AstroImage
     7 *
     8 *  @author George Gusciora, MHPCC
     9 *
     10 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-10-06 21:30:14 $
     12 *
     13 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     14 */
     15
    1516/******************************************************************************/
    1617/*  INCLUDE FILES                                                             */
    1718/******************************************************************************/
    18 #include "slalib.h"
    19 
    20 #include<math.h>
     19#include <string.h>
     20#include <math.h>
     21
    2122#include "psFunctions.h"
    2223#include "psAstrometry.h"
    2324#include "psMemory.h"
    2425#include "psAbort.h"
    25 /******************************************************************************/
    26 /*  DEFINE STATEMENTS                                                         */
    27 /******************************************************************************/
    28 
    29 // None
    30 
    31 /******************************************************************************/
    32 /*  TYPE DEFINITIONS                                                          */
    33 /******************************************************************************/
    34 
    35 // None
    36 
    37 /*****************************************************************************/
    38 /*  GLOBAL VARIABLES                                                         */
    39 /*****************************************************************************/
    40 
    41 // None
    42 
    43 /*****************************************************************************/
    44 /*  FILE STATIC VARIABLES                                                    */
    45 /*****************************************************************************/
    46 
    47 // None
    48 
    49 /*****************************************************************************/
    50 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    51 /*****************************************************************************/
     26#include "slalib.h"
    5227
    5328/*****************************************************************************
     
    204179}
    205180
     181static void observatoryFree(psObservatory* obs)
     182{
     183    if (obs != NULL) {
     184        psFree((void*)obs->name);
     185    }
     186}
     187
     188static void fixedPatternFree(psFixedPattern* fp)
     189{
     190    if (fp != NULL) {
     191        for (int i = 0; i < fp->nX; i++) {
     192            psFree(fp->x[i]);
     193        }
     194
     195        for (int j = 0; j < fp->nY; j++) {
     196            psFree(fp->y[j]);
     197        }
     198
     199        psFree(fp->x);
     200        psFree(fp->y);
     201    }
     202}
     203
    206204/*****************************************************************************/
    207205/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
     
    213211 * XXX: Verify that you interpreted the SDR correctly.
    214212 *
    215  * XXX: Must add memory deallocater.
    216213 */
    217 psFixedPattern *psFixedPatternAlloc(double x0,
     214psFixedPattern* psFixedPatternAlloc(double x0,
    218215                                    double y0,
    219216                                    double xScale,
     
    227224
    228225    tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));
    229     tmp->nX = x->numRows * x->numCols;
    230     tmp->nY = y->numRows * y->numCols;
     226    tmp->nX = x->numCols;
     227    tmp->nY = y->numRows;
    231228    tmp->x0 = x0;
    232229    tmp->y0 = y0;
     
    252249        }
    253250    }
     251
     252    p_psMemSetDeallocator(tmp,(psFreeFcn)fixedPatternFree);
     253
    254254    return(tmp);
    255255}
     
    279279}
    280280
    281 /*
    282  * psFPA constructor
    283  */
     281psObservatory* psObservatoryAlloc(const char* name,
     282                                  double latitude,
     283                                  double longitude,
     284                                  double height,
     285                                  double tlr)
     286{
     287    psObservatory* obs = psAlloc(sizeof(obs));
     288
     289    if (obs->name == NULL) {
     290        obs->name = NULL;
     291    } else {
     292        obs->name = psAlloc(strlen(name)+1);
     293        strcpy((char*)obs->name, name);
     294    }
     295
     296    *(double *)&obs->latitude = latitude;
     297    *(double *)&obs->longitude = longitude;
     298    *(double *)&obs->height = height;
     299    *(double *)&obs->tlr = tlr;
     300
     301    p_psMemSetDeallocator(obs,(psFreeFcn)observatoryFree);
     302
     303    return obs;
     304}
     305
    284306psFPA* psFPAAlloc(int nChips,
    285307                  const psExposure* exp)
Note: See TracChangeset for help on using the changeset viewer.