Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2096)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2097)
@@ -8,6 +8,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-13 19:40:42 $
+ *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-14 00:06:17 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -504,27 +504,25 @@
                     const psFPA* FPA)
 {
+    //printf("Entering psCellInFPA()\n");
     psChip* tmpChip = NULL;
-    psPlane* chipCoord = NULL;
+    psPlane chipCoord;
     psCell* outCell = NULL;
 
-    if (fpaCoord == NULL) {
-        psAbort(__func__, "input parameter fpaCoord is NULL.");
-    }
-    if (FPA == NULL) {
-        psAbort(__func__, "input parameter FPA is NULL.");
-    }
+    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
+    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
 
     // Determine which chip contains the fpaCoords.
     tmpChip = psChipInFPA(fpaCoord, FPA);
+    if (tmpChip == NULL) {
+        return(NULL);
+    }
 
     // Convert to those chip coordinates.
-    chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, tmpChip);
+    psCoordFPAToChip(&chipCoord, fpaCoord, tmpChip);
 
     // Determine which cell contains those chip coordinates.
-    outCell = psCellInChip(chipCoord, tmpChip);
-
-    psFree(tmpChip);
-    psFree(chipCoord);
-
+    outCell = psCellInChip(&chipCoord, tmpChip);
+
+    //printf("Exiting psCellInFPA()\n");
     return (outCell);
 }
@@ -533,15 +531,12 @@
                     const psFPA* FPA)
 {
+    //printf("Entering psChipInFPA()\n");
+    PS_CHECK_NULL_PTR_RETURN_NULL(fpaCoord);
+    PS_CHECK_NULL_PTR_RETURN_NULL(FPA);
+    PS_CHECK_NULL_PTR_RETURN_NULL(FPA->chips);
     psArray* chips = FPA->chips;
     int nChips = chips->n;
-    psPlane* chipCoord = NULL;
+    psPlane chipCoord;
     psCell *tmpCell = NULL;
-
-    if (fpaCoord == NULL) {
-        psAbort(__func__, "input parameter fpaCoord is NULL.");
-    }
-    if (FPA == NULL) {
-        psAbort(__func__, "input parameter FPA is NULL.");
-    }
 
     // Loop through every chip in this FPA.  Convert the original
@@ -550,16 +545,16 @@
     // coordinates.
     for (int i = 0; i < nChips; i++) {
+        //printf("HERE 01 (checking chip %d)\n", i);
         psChip* tmpChip = chips->data[i];
-        chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA,
-                                          fpaCoord);
-
-        tmpCell = psCellInChip(chipCoord, tmpChip);
+        psPlaneTransformApply(&chipCoord, tmpChip->fromFPA, fpaCoord);
+
+        tmpCell = psCellInChip(&chipCoord, tmpChip);
         if (tmpCell != NULL) {
-            psFree(chipCoord);
+            //printf("Exiting psChipInFPA()\n");
             return(tmpChip);
         }
-        psFree(chipCoord);
-    }
-
+    }
+
+    //printf("Exiting psChipInFPA()\n");
     return (NULL);
 }
@@ -568,17 +563,14 @@
                      const psChip* chip)
 {
-    psPlane* cellCoord = NULL;
+    //printf("Entering psCellInChip(%f, %f, %d)\n", chipCoord->x, chipCoord->y, chip);
+    PS_CHECK_NULL_PTR_RETURN_NULL(chipCoord);
+    PS_CHECK_NULL_PTR_RETURN_NULL(chip);
+
+    psPlane cellCoord;
     psArray* cells;
-
-    // We return NULL if either of the input parameters is NULL.
-    if (chipCoord == NULL) {
-        psAbort(__func__, "the 'chipCoord' parameter is NULL\n");
-    }
-    if (chip == NULL) {
-        psAbort(__func__, "the 'chip' parameter is NULL\n");
-    }
 
     cells = chip->cells;
     if (cells == NULL) {
+        //printf("Exiting psCellInChip()\n");
         return NULL;
     }
@@ -587,4 +579,5 @@
     // a cellCoord for that cell and determine if that cellCoord is valid.
     // If so, then we return that cell.
+
     for (int i = 0; i < cells->n; i++) {
         psCell* tmpCell = (psCell* ) cells->data[i];
@@ -595,12 +588,12 @@
                 psReadout* tmpReadout = readouts->data[j];
 
-                cellCoord = psPlaneTransformApply(cellCoord,
-                                                  tmpCell->fromChip,
-                                                  chipCoord);
-
-                if (checkValidImageCoords(cellCoord->x,
-                                          cellCoord->y,
+                psPlaneTransformApply(&cellCoord,
+                                      tmpCell->fromChip,
+                                      chipCoord);
+
+                if (checkValidImageCoords(cellCoord.x,
+                                          cellCoord.y,
                                           tmpReadout->image)) {
-                    psFree(cellCoord);
+                    //printf("Exiting psCellInChip()\n");
                     return (tmpCell);
                 }
@@ -609,5 +602,5 @@
     }
 
-    psFree(cellCoord);
+    //printf("Exiting psCellInChip()\n");
     return (NULL);
 }
