Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 1980)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 1981)
@@ -1,53 +1,28 @@
 /** @file  psAstrometry.c
-*
-*  @brief This file defines the basic types for astronomical coordinate
-*  transformation
-*
-*  @ingroup AstroImage
-*
-*  @author George Gusciora, MHPCC
-*
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-06 00:44:16 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *
+ *  @brief This file defines the basic types for astronomical coordinate
+ *  transformation
+ *
+ *  @ingroup AstroImage
+ *
+ *  @author George Gusciora, MHPCC
+ *
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-06 21:30:14 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
 /******************************************************************************/
 /*  INCLUDE FILES                                                             */
 /******************************************************************************/
-#include "slalib.h"
-
-#include<math.h>
+#include <string.h>
+#include <math.h>
+
 #include "psFunctions.h"
 #include "psAstrometry.h"
 #include "psMemory.h"
 #include "psAbort.h"
-/******************************************************************************/
-/*  DEFINE STATEMENTS                                                         */
-/******************************************************************************/
-
-// None
-
-/******************************************************************************/
-/*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  GLOBAL VARIABLES                                                         */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  FILE STATIC VARIABLES                                                    */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
-/*****************************************************************************/
+#include "slalib.h"
 
 /*****************************************************************************
@@ -204,4 +179,27 @@
 }
 
+static void observatoryFree(psObservatory* obs)
+{
+    if (obs != NULL) {
+        psFree((void*)obs->name);
+    }
+}
+
+static void fixedPatternFree(psFixedPattern* fp)
+{
+    if (fp != NULL) {
+        for (int i = 0; i < fp->nX; i++) {
+            psFree(fp->x[i]);
+        }
+
+        for (int j = 0; j < fp->nY; j++) {
+            psFree(fp->y[j]);
+        }
+
+        psFree(fp->x);
+        psFree(fp->y);
+    }
+}
+
 /*****************************************************************************/
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
@@ -213,7 +211,6 @@
  * XXX: Verify that you interpreted the SDR correctly.
  *
- * XXX: Must add memory deallocater.
  */
-psFixedPattern *psFixedPatternAlloc(double x0,
+psFixedPattern* psFixedPatternAlloc(double x0,
                                     double y0,
                                     double xScale,
@@ -227,6 +224,6 @@
 
     tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));
-    tmp->nX = x->numRows * x->numCols;
-    tmp->nY = y->numRows * y->numCols;
+    tmp->nX = x->numCols;
+    tmp->nY = y->numRows;
     tmp->x0 = x0;
     tmp->y0 = y0;
@@ -252,4 +249,7 @@
         }
     }
+
+    p_psMemSetDeallocator(tmp,(psFreeFcn)fixedPatternFree);
+
     return(tmp);
 }
@@ -279,7 +279,29 @@
 }
 
-/*
- * psFPA constructor
- */
+psObservatory* psObservatoryAlloc(const char* name,
+                                  double latitude,
+                                  double longitude,
+                                  double height,
+                                  double tlr)
+{
+    psObservatory* obs = psAlloc(sizeof(obs));
+
+    if (obs->name == NULL) {
+        obs->name = NULL;
+    } else {
+        obs->name = psAlloc(strlen(name)+1);
+        strcpy((char*)obs->name, name);
+    }
+
+    *(double *)&obs->latitude = latitude;
+    *(double *)&obs->longitude = longitude;
+    *(double *)&obs->height = height;
+    *(double *)&obs->tlr = tlr;
+
+    p_psMemSetDeallocator(obs,(psFreeFcn)observatoryFree);
+
+    return obs;
+}
+
 psFPA* psFPAAlloc(int nChips,
                   const psExposure* exp)
Index: /trunk/psLib/src/astronomy/psAstrometry.h
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.h	(revision 1980)
+++ /trunk/psLib/src/astronomy/psAstrometry.h	(revision 1981)
@@ -8,6 +8,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-09-15 22:57:12 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-06 21:30:14 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -83,12 +83,4 @@
 psFixedPattern;
 
-psFixedPattern *psFixedPatternAlloc(double x0,           ///< X Position of 0,0 corner on focal plane
-                                    double y0,           ///< Y Position of 0,0 corner on focal plane
-                                    double xScale,       ///< Scale of the grid in x direction
-                                    double yScale,       ///< Scale of the grid in x direction
-                                    const psImage *x,    ///< The grid of offsets in x
-                                    const psImage *y     ///< The grid of offsets in y
-                                   );
-
 /** Readout data structure.
  *
@@ -123,5 +115,5 @@
  *
  */
-typedef struct psCell
+typedef struct
 {
     psArray* readouts;                 ///< readouts from the cell
@@ -225,4 +217,37 @@
 psExposure;
 
+/** Observatory Information
+ *
+ *  A container for the observatory data that doesn't change per exposure.
+ *
+ */
+typedef struct
+{
+    const char* name;                  ///< Name of observatory
+    const double latitude;             ///< Latitude of observatory, east positive
+    const double longitude;            ///< Longitude of observatory
+    const double height;               ///< Height of observatory
+    const double tlr;                  ///< Tropospheric Lapse Rate
+}
+psObservatory;
+
+
+/** Allocator for psFixedPattern struct
+ *
+ *  Allocates a new psFixedPattern struct with the attributes coorsponding
+ *  to the parameters set to the said input values.
+ *
+ *  @return psFixedPattern*     New psFixedPattern struct.
+ */
+psFixedPattern* psFixedPatternAlloc(
+    double x0,           ///< X Position of 0,0 corner on focal plane
+    double y0,           ///< Y Position of 0,0 corner on focal plane
+    double xScale,       ///< Scale of the grid in x direction
+    double yScale,       ///< Scale of the grid in x direction
+    const psImage *x,    ///< The grid of offsets in x
+    const psImage *y     ///< The grid of offsets in y
+);
+
+
 /** Allocator for psExposure
  *
@@ -231,5 +256,5 @@
  *  quantities can be derived and stored for later use.
  *
- *  @return     psExposure*    new psExposure struct
+ *  @return     psExposure*    New psExposure struct
  */
 psExposure* psExposureAlloc(
@@ -248,4 +273,19 @@
 );
 
+/** Allocator for psObservatory
+ *
+ *  This function shall construct a new psObservatory with attributes 
+ *  cooresponding to the function parameters.
+ *
+ *  @return psObservatory*    new psObservatory struct
+ */
+psObservatory* psObservatoryAlloc(
+    const char* name,                  ///< Name of observatory
+    double latitude,                   ///< Latitude of observatory, east positive
+    double longitude,                  ///< Longitude of observatory
+    double height,                     ///< Height of observatory
+    double tlr                         ///< Tropospheric Lapse Rate
+);
+
 /** Allocator for psFPA
  *
