Index: /trunk/psLib/src/astro/psTime.c
===================================================================
--- /trunk/psLib/src/astro/psTime.c	(revision 2000)
+++ /trunk/psLib/src/astro/psTime.c	(revision 2001)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 18:31:49 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-07 19:16:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -67,5 +67,5 @@
                 }
 
-                /** Preprocessor macro to allocate psTime strict */
+                /** Preprocessor macro to allocate psTime struct */
                 #define ALLOC_TIME(TIME)                                                                                     \
                 TIME = (psTime*)psAlloc(sizeof(psTime));                                                                     \
@@ -469,5 +469,5 @@
     // Convert Universal Time (UTC) to  UT1
     ALLOC_TIME(ut1UtcDelta);
-    ALLOC_TIME(ut1Time);
+    // ALLOC_TIME(ut1Time);
     ut1UtcDelta->usec = psGetUT1Delta(utcTime)*1e6;
     ut1Time = psTimeAdd(utcTime, ut1UtcDelta);
@@ -479,5 +479,5 @@
 
     // Calculate Terrestial Dynamical Time (TDT)
-    ALLOC_TIME(tdtTime);
+    // ALLOC_TIME(tdtTime);
     ALLOC_TIME(tdtDelta);
     tdtDelta->sec = 32;
@@ -514,9 +514,15 @@
 double psGetUT1Delta(psTime *time)
 {
-    psImage *iersTable = NULL;
+    static psImage* iersTable = NULL;
     double ut1UtcDeltaUsec = 0.0;
 
 
-    iersTable = readSer7File("../../data/ser7.dat");
+    if (iersTable == NULL) {
+        iersTable = readSer7File("../../data/ser7.dat");
+        p_psMemSetPersistent(iersTable,true);
+        p_psMemSetPersistent(iersTable->data.V,true);
+        p_psMemSetPersistent(iersTable->rawDataBuffer,true);
+    }
+
     ut1UtcDeltaUsec = lookupSer7Table(iersTable, time, 6)*1.0e6;
 
@@ -527,8 +533,13 @@
 {
     double delta = 0.0;
-    psImage *taiUtcTable = NULL;
-
-
-    taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat");
+    static psImage* taiUtcTable = NULL;
+
+
+    if (taiUtcTable == NULL) {
+        taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat");
+        p_psMemSetPersistent(taiUtcTable,true);
+        p_psMemSetPersistent(taiUtcTable->data.V,true);
+        p_psMemSetPersistent(taiUtcTable->rawDataBuffer,true);
+    }
     delta = lookupTaiUtcTable(taiUtcTable, time);
 
Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2000)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2001)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-06 21:30:14 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-07 19:16:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -186,4 +186,14 @@
 }
 
+static void exposureFree(psExposure* exp)
+{
+    if (exp != NULL) {
+        psFree((void*)exp->time);
+        psFree((void*)exp->observatory);
+        psFree((void*)exp->cameraName);
+        psFree((void*)exp->telescopeName);
+    }
+}
+
 static void fixedPatternFree(psFixedPattern* fp)
 {
@@ -256,8 +266,17 @@
 
 
-psExposure* psExposureAlloc(double ra, double dec, double hourAngle,
-                            double zenith, double azimuth, double localTime, float date,
-                            float rotAngle, float temperature, float pressure, float humidity,
-                            float exposureTime)
+psExposure* psExposureAlloc(double ra,
+                            double dec,
+                            double hourAngle,
+                            double zenithDistance,
+                            double azimuth,
+                            const psTime* time,
+                            float rotAngle,
+                            float temperature,
+                            float pressure,
+                            float humidity,
+                            float exposureTime,
+                            float wavelength,
+                            const psObservatory* observatory)
 {
     psExposure* exp = psAlloc(sizeof(psExposure));
@@ -266,8 +285,6 @@
     *(double *)&exp->dec = dec;
     *(double *)&exp->hourAngle = hourAngle;
-    *(double *)&exp->zenith = zenith;
+    *(double *)&exp->zenithDistance = zenithDistance;
     *(double *)&exp->azimuth = azimuth;
-    *(double *)&exp->localTime = localTime;
-    *(float *)&exp->date = date;
     *(float *)&exp->rotAngle = rotAngle;
     *(float *)&exp->temperature = temperature;
@@ -275,4 +292,19 @@
     *(float *)&exp->humidity = humidity;
     *(float *)&exp->exposureTime = exposureTime;
+    *(float *)&exp->wavelength = wavelength;
+
+    exp->time = psMemIncrRefCounter((void*)time);
+    exp->observatory = psMemIncrRefCounter((void*)observatory);
+
+    // XXX: how is these value derived?
+    *(double *)&exp->lst = psTimeToLST((psTime*)time,observatory->longitude);
+    *(float *)&exp->positionAngle = 0.0f;
+    *(float *)&exp->parallacticAngle = 0.0f;
+    *(float *)&exp->airmass = 0.0f;
+    *(float *)&exp->parallacticFactor = 0.0f;
+    exp->cameraName = NULL;
+    exp->telescopeName = NULL;
+
+    p_psMemSetDeallocator(exp,(psFreeFcn)exposureFree);
 
     return exp;
@@ -285,7 +317,7 @@
                                   double tlr)
 {
-    psObservatory* obs = psAlloc(sizeof(obs));
-
-    if (obs->name == NULL) {
+    psObservatory* obs = psAlloc(sizeof(psObservatory));
+
+    if (name == NULL) {
         obs->name = NULL;
     } else {
Index: /trunk/psLib/src/astronomy/psAstrometry.h
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2000)
+++ /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2001)
@@ -8,6 +8,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-06 21:30:14 $
+*  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-10-07 19:16:46 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -184,4 +184,19 @@
 psFPA;
 
+/** 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;
+
 /** Exposure Information
  *
@@ -196,8 +211,7 @@
     const double dec;                  ///< Telescope boresight, declination
     const double hourAngle;            ///< Hour angle
-    const double zenith;               ///< Zenith distance
+    const double zenithDistance;       ///< Zenith distance
     const double azimuth;              ///< Azimuth
-    const double localTime;            ///< Local Sidereal Time
-    const float date;                  ///< Modified Jullian Date of observation
+    const psTime* time;                ///< Time of observation
     const float rotAngle;              ///< Rotator position angle
     const float temperature;           ///< Air temperature, for estimating refraction
@@ -205,31 +219,17 @@
     const float humidity;              ///< Relative humidity, for refraction
     const float exposureTime;          ///< Exposure time
-    const double wavelength;           ///< Wavelength
+    const float wavelength;            ///< Wavelength
+    const psObservatory* observatory;  ///< Observatory data
 
     /* Derived quantities */
+    const double lst;                  ///< Local Sidereal Time
     const float positionAngle;         ///< Position angle
     const float parallacticAngle;      ///< Parallactic angle
     const float airmass;               ///< Airmass, calculated from zenith distance
     const float parallacticFactor;     ///< Parallactic factor
-    const char *cameraName;            ///< name of camera which provided exposure
-    const char *telescopeName;         ///< name of telescope which provided exposure
+    const char* cameraName;            ///< name of camera which provided exposure
+    const char* telescopeName;         ///< name of telescope which provided exposure
 }
 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
@@ -262,13 +262,14 @@
     double dec,                        ///< Telescope boresight, declination
     double hourAngle,                  ///< Hour angle
-    double zenith,                     ///< Zenith distance
+    double zenithDistance,             ///< Zenith distance
     double azimuth,                    ///< Azimuth
-    double localTime,                  ///< Local Sidereal Time
-    float date,                        ///< MJD
+    const psTime* time,                ///< time of observation
     float rotAngle,                    ///< Rotator position angle
     float temperature,                 ///< Temperature
     float pressure,                    ///< Pressure
     float humidity,                    ///< Relative humidity
-    float exposureTime                 ///< Exposure time
+    float exposureTime,                ///< Exposure time
+    float wavelength,                  ///< wavelength
+    const psObservatory* observatory   ///< Observatory data
 );
 
Index: /trunk/psLib/src/astronomy/psTime.c
===================================================================
--- /trunk/psLib/src/astronomy/psTime.c	(revision 2000)
+++ /trunk/psLib/src/astronomy/psTime.c	(revision 2001)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-23 18:31:49 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-07 19:16:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -67,5 +67,5 @@
                 }
 
-                /** Preprocessor macro to allocate psTime strict */
+                /** Preprocessor macro to allocate psTime struct */
                 #define ALLOC_TIME(TIME)                                                                                     \
                 TIME = (psTime*)psAlloc(sizeof(psTime));                                                                     \
@@ -469,5 +469,5 @@
     // Convert Universal Time (UTC) to  UT1
     ALLOC_TIME(ut1UtcDelta);
-    ALLOC_TIME(ut1Time);
+    // ALLOC_TIME(ut1Time);
     ut1UtcDelta->usec = psGetUT1Delta(utcTime)*1e6;
     ut1Time = psTimeAdd(utcTime, ut1UtcDelta);
@@ -479,5 +479,5 @@
 
     // Calculate Terrestial Dynamical Time (TDT)
-    ALLOC_TIME(tdtTime);
+    // ALLOC_TIME(tdtTime);
     ALLOC_TIME(tdtDelta);
     tdtDelta->sec = 32;
@@ -514,9 +514,15 @@
 double psGetUT1Delta(psTime *time)
 {
-    psImage *iersTable = NULL;
+    static psImage* iersTable = NULL;
     double ut1UtcDeltaUsec = 0.0;
 
 
-    iersTable = readSer7File("../../data/ser7.dat");
+    if (iersTable == NULL) {
+        iersTable = readSer7File("../../data/ser7.dat");
+        p_psMemSetPersistent(iersTable,true);
+        p_psMemSetPersistent(iersTable->data.V,true);
+        p_psMemSetPersistent(iersTable->rawDataBuffer,true);
+    }
+
     ut1UtcDeltaUsec = lookupSer7Table(iersTable, time, 6)*1.0e6;
 
@@ -527,8 +533,13 @@
 {
     double delta = 0.0;
-    psImage *taiUtcTable = NULL;
-
-
-    taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat");
+    static psImage* taiUtcTable = NULL;
+
+
+    if (taiUtcTable == NULL) {
+        taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat");
+        p_psMemSetPersistent(taiUtcTable,true);
+        p_psMemSetPersistent(taiUtcTable->data.V,true);
+        p_psMemSetPersistent(taiUtcTable->rawDataBuffer,true);
+    }
     delta = lookupTaiUtcTable(taiUtcTable, time);
 
Index: /trunk/psLib/test/astronomy/Makefile
===================================================================
--- /trunk/psLib/test/astronomy/Makefile	(revision 2000)
+++ /trunk/psLib/test/astronomy/Makefile	(revision 2001)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/astronomy
 ##
-##  $Revision: 1.12 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-10-06 01:08:17 $
+##  $Revision: 1.13 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-10-07 19:16:49 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,5 +27,6 @@
          tst_psMetadata_04 \
          tst_psMetadata_05 \
-         tst_psMetadata_06
+         tst_psMetadata_06 \
+         tst_psAstrometry
 
 OBJS = $(addprefix builddir/,$(addsuffix .o,$(TARGET)))
