Index: /trunk/psLib/psLib.kdevelop.filelist
===================================================================
--- /trunk/psLib/psLib.kdevelop.filelist	(revision 2854)
+++ /trunk/psLib/psLib.kdevelop.filelist	(revision 2855)
@@ -1,4 +1,1 @@
 # KDevelop Custom Project File List
-tags
-test/collections/psArray_02.c
-
Index: /trunk/psLib/psLib.kdevses
===================================================================
--- /trunk/psLib/psLib.kdevses	(revision 2854)
+++ /trunk/psLib/psLib.kdevses	(revision 2855)
@@ -2,5 +2,15 @@
 <!DOCTYPE KDevPrjSession>
 <KDevPrjSession>
- <DocsAndViews NumberOfDocuments="0" />
+ <DocsAndViews NumberOfDocuments="3" >
+  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/astronomy/psAstrometry.c" >
+   <View0 Type="Source" />
+  </Doc0>
+  <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/test/astronomy/tst_psAstrometry.c" >
+   <View0 Type="Source" />
+  </Doc1>
+  <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psArray.c" >
+   <View0 line="91" Type="Source" />
+  </Doc2>
+ </DocsAndViews>
  <pluginList>
   <kdevbookmarks>
@@ -11,4 +21,7 @@
    </bookmarks>
   </kdevbookmarks>
+  <kdevsubversion>
+   <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />
+  </kdevsubversion>
   <kdevvalgrind>
    <executable path="" params="" />
Index: /trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2854)
+++ /trunk/psLib/src/astronomy/psAstrometry.c	(revision 2855)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-02 21:12:51 $
+ *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -399,9 +399,14 @@
 
     // create array of NULL psCells
-    chip->cells = psArrayAlloc(nCells);
+    int n = (nCells > 0) ? nCells : 1;
+    chip->cells = psArrayAlloc(n);
     psPtr* cells = chip->cells->data;
-    for (psS32 i=0;i<nCells;i++) {
+    for (psS32 i=0;i<n;i++) {
         cells[i] = NULL;
     }
+    chip->cells->n = 0; // per requirement
+
+    *(int*)&chip->row0 = 0;
+    *(int*)&chip->col0 = 0;
 
     chip->metadata = NULL;
@@ -429,9 +434,14 @@
 
     // create array of NULL psReadouts
-    cell->readouts = psArrayAlloc(nReadouts);
+    int n = (nReadouts > 0) ? nReadouts : 1;
+    cell->readouts = psArrayAlloc(n);
     psPtr* readouts = cell->readouts->data;
-    for (psS32 i=0;i<nReadouts;i++) {
+    for (psS32 i=0;i<n;i++) {
         readouts[i] = NULL;
     }
+    cell->readouts->n = 0; // per requirement
+
+    *(int*)&cell->row0 = 0;
+    *(int*)&cell->col0 = 0;
 
     cell->metadata = NULL;
@@ -452,19 +462,16 @@
 }
 
-psReadout* psReadoutAlloc(psS32 col0,
-                          psS32 row0,
-                          const psImage* image)
-{
-    PS_INT_CHECK_NON_NEGATIVE(col0, NULL);
-    PS_INT_CHECK_NON_NEGATIVE(row0, NULL);
-
+psReadout* psReadoutAlloc()
+{
     psReadout* readout = psAlloc(sizeof(psReadout));
 
-    *(psU32*)&readout->colBins = 1;
-    *(psU32*)&readout->rowBins = 1;
-    *(psS32*)&readout->col0 = col0;
-    *(psS32*)&readout->row0 = row0;
-
-    readout->image = (psImage*)image;
+    *(psU32*)&readout->colBins = 0;
+    *(psU32*)&readout->rowBins = 0;
+    *(psU32*)&readout->rowParity = 0;
+    *(psU32*)&readout->colParity = 0;
+    *(psS32*)&readout->col0 = 0;
+    *(psS32*)&readout->row0 = 0;
+
+    readout->image = NULL;
     readout->mask = NULL;
     readout->objects = NULL;
@@ -718,5 +725,5 @@
     PS_PTR_CHECK_NULL(cellCoord, NULL);
     PS_PTR_CHECK_NULL(cell, NULL);
-    PS_PTR_CHECK_NULL(cell->toTP, NULL);
+    PS_PTR_CHECK_NULL(cell->toSky, NULL);
     PS_PTR_CHECK_NULL(cell->parent, NULL);
     PS_PTR_CHECK_NULL(cell->parent->parent, NULL);
Index: /trunk/psLib/src/astronomy/psAstrometry.h
===================================================================
--- /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2854)
+++ /trunk/psLib/src/astronomy/psAstrometry.h	(revision 2855)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-12-02 21:12:51 $
+*  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-12-30 20:18:36 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -99,8 +99,12 @@
 typedef struct
 {
-    const psU32 colBins;        ///< Amount of binning in x-dimension
-    const psU32 rowBins;        ///< Amount of binning in y-dimension
-    const psS32 col0;                    ///< Offset from the left of chip.
-    const psS32 row0;                    ///< Offset from the bottom of chip.
+    const psS32 col0;                  ///< Offset from the left of chip.
+    const psS32 row0;                  ///< Offset from the bottom of chip.
+
+    const int colParity;               ///< Column Readout Direction
+    const int rowParity;               ///< Row Readout Direction
+
+    const psU32 colBins;               ///< Amount of binning in x-dimension
+    const psU32 rowBins;               ///< Amount of binning in y-dimension
 
     psImage* image;                    ///< Imaging area of readout
@@ -122,12 +126,16 @@
 typedef struct
 {
+    const psS32 col0;                  ///< Offset from the left of chip
+    const psS32 row0;                  ///< Offset from the bottom of chip
+
     psArray* readouts;                 ///< readouts from the cell
+
     psMetadata* metadata;              ///< cell-level metadata
 
     psPlaneTransform* toChip;          ///< transformations from cell to chip coordinates
-    psPlaneTransform* fromChip;        ///< transformations from chip to cell coordinates
+    psPlaneTransform* fromChip;        ///< transformations from cell to chip coordinates
     psPlaneTransform* toFPA;           ///< transformations from cell to FPA coordinates
-    psPlaneTransform* toTP;            ///< transformations from cell to tangent plane coordinates
-    psPlaneTransform* toSky;            ///< transformations from cell to tangent plane coordinates
+    psPlaneTransform* toTP;            ///< transformations from cell to FPA coordinates
+    psPlaneTransform* toSky;           ///< transformations from cell to tangent plane coordinates
 
     struct psChip* parent;             ///< chip in which contains this cell
@@ -145,5 +153,9 @@
 typedef struct psChip
 {
+    const psS32 col0;                  ///< Offset from the left of FPA
+    const psS32 row0;                  ///< Offset from the bottom of FPA
+
     psArray* cells;                    ///< cells in the chip
+
     psMetadata* metadata;              ///< chip-level metadata
 
@@ -282,5 +294,5 @@
 /** Allocator for psObservatory
  *
- *  This function shall construct a new psObservatory with attributes 
+ *  This function shall construct a new psObservatory with attributes
  *  cooresponding to the function parameters.
  *
@@ -340,11 +352,7 @@
  *  to NULL.
  *
- *  @return psReadout*    newly allocated psReadout
- */
-psReadout* psReadoutAlloc(
-    psS32 col0,                          ///< offset from the left of the cell
-    psS32 row0,                          ///< offset from the bottom of the cell
-    const psImage* image               ///< image of the readout
-);
+ *  @return psReadout*    newly allocated psReadout with all internal pointers set to NULL
+ */
+psReadout* psReadoutAlloc();
 
 /** Allocates a Wallace's Grommit structure.
Index: /trunk/psLib/src/collections/psArray.c
===================================================================
--- /trunk/psLib/src/collections/psArray.c	(revision 2854)
+++ /trunk/psLib/src/collections/psArray.c	(revision 2855)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-28 01:48:05 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -114,4 +114,9 @@
     psBool success = false;
 
+    if (psArr == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psArray_ARRAY_NULL);
+        return false;
+    }
 
     psS32 n = psArr->n;
Index: /trunk/psLib/src/collections/psCollectionsErrors.dat
===================================================================
--- /trunk/psLib/src/collections/psCollectionsErrors.dat	(revision 2854)
+++ /trunk/psLib/src/collections/psCollectionsErrors.dat	(revision 2855)
@@ -9,4 +9,5 @@
 #
 psArray_REALLOC_NULL                   psArrayRealloc must be given a non-NULL psArray to resize.
+psArray_ARRAY_NULL                     Specified psArray can not be NULL.
 #
 psVector_REALLOC_NULL                  psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown.
@@ -36,5 +37,5 @@
 psList_ITERATOR_INVALID                Specified iterator is not valid.
 psList_ITERATOR_NULL                   Specified iterator is NULL.
-psList_LIST_NULL                       Specified psList reference is NULL. 
+psList_LIST_NULL                       Specified psList reference is NULL.
 psList_DATA_NULL                       Specified data item is NULL.
 psList_DATA_NOT_FOUND                  Specified data item is not found in the psList.
Index: /trunk/psLib/src/collections/psCollectionsErrors.h
===================================================================
--- /trunk/psLib/src/collections/psCollectionsErrors.h	(revision 2854)
+++ /trunk/psLib/src/collections/psCollectionsErrors.h	(revision 2855)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-10 02:50:14 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 //~Start #define PS_ERRORTEXT_$1 "$2"
 #define PS_ERRORTEXT_psArray_REALLOC_NULL "psArrayRealloc must be given a non-NULL psArray to resize."
+#define PS_ERRORTEXT_psArray_ARRAY_NULL "Specified psArray can not be NULL."
 #define PS_ERRORTEXT_psVector_REALLOC_NULL "psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown."
 #define PS_ERRORTEXT_psVector_NOT_A_VECTOR "The input psVector must have a vector dimension type."
@@ -53,5 +54,5 @@
 #define PS_ERRORTEXT_psList_ITERATOR_INVALID "Specified iterator is not valid."
 #define PS_ERRORTEXT_psList_ITERATOR_NULL "Specified iterator is NULL."
-#define PS_ERRORTEXT_psList_LIST_NULL "Specified psList reference is NULL. "
+#define PS_ERRORTEXT_psList_LIST_NULL "Specified psList reference is NULL."
 #define PS_ERRORTEXT_psList_DATA_NULL "Specified data item is NULL."
 #define PS_ERRORTEXT_psList_DATA_NOT_FOUND "Specified data item is not found in the psList."
Index: /trunk/psLib/src/types/psArray.c
===================================================================
--- /trunk/psLib/src/types/psArray.c	(revision 2854)
+++ /trunk/psLib/src/types/psArray.c	(revision 2855)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-28 01:48:05 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -114,4 +114,9 @@
     psBool success = false;
 
+    if (psArr == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psArray_ARRAY_NULL);
+        return false;
+    }
 
     psS32 n = psArr->n;
Index: /trunk/psLib/test/astronomy/tst_psAstrometry.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2854)
+++ /trunk/psLib/test/astronomy/tst_psAstrometry.c	(revision 2855)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-30 21:47:19 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:36 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -278,5 +278,5 @@
 
     /*
-        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is 
+        2. Call psFPAAlloc with nChips = 0. Verify that the chips array is
            zero in size and the program execution does not stop.
     */
@@ -291,5 +291,5 @@
 
     /*
-        3. Call psFPAAlloc with a NULL psExposure. Verify that the program 
+        3. Call psFPAAlloc with a NULL psExposure. Verify that the program
            execution doe not stop and the exposure attribute is NULL.
     */
@@ -303,6 +303,6 @@
 
     /*
-        4. Call psFPAAlloc and set all references in the struct to a memory 
-           buffer. Verify that psFree cleans up all the buffers referenced in 
+        4. Call psFPAAlloc and set all references in the struct to a memory
+           buffer. Verify that psFree cleans up all the buffers referenced in
            the struct, i.e., there is no memory leaks generated.
     */
@@ -353,8 +353,8 @@
 
     /*
-        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify 
+        1. invoke psChipAlloc with nCells > 0 and parentFPA non-NULL. Verify
            that:
         a. the cells array is of the size nCells and all elements are NULL.
-        b. parent attribute is set to parentFPA parameter and the ref. count 
+        b. parent attribute is set to parentFPA parameter and the ref. count
            was incremented.
         c. all other attributes are initialized to NULL or 0.
@@ -368,7 +368,13 @@
     }
 
-    if (chip->cells->n != 8) {
+    if (chip->cells->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psChipAlloc did not set the number of cells properly.");
+        return 2;
+    }
+
+    if (chip->cells->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array size properly.");
         return 2;
     }
@@ -382,4 +388,5 @@
         chip->cells->data[lcv] = psAlloc(4); // to check if these are freed.
     }
+    chip->cells->n = 8;
 
     if (chip->parent != fpa) {
@@ -419,5 +426,5 @@
         2. invoke psChipAlloc with nCells = 0. Verify that:
         a. execution does not halt
-        b. the cells array is of the size of zero.    
+        b. the cells array is of the size of one.
     */
 
@@ -435,4 +442,10 @@
     }
 
+    if (chip2->cells->nalloc != 1) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array size properly.");
+        return 12;
+    }
+
     if (chip2->parent != fpa) {
         psLogMsg(__func__,PS_LOG_ERROR,
@@ -448,5 +461,5 @@
 
     /*
-        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent 
+        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
            attribute is NULL and no error is generated.
     */
@@ -459,8 +472,14 @@
     }
 
-    if (chip3->cells->n != 8) {
+    if (chip3->cells->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psChipAlloc did not set the number of cells properly.");
         return 22;
+    }
+
+    if (chip3->cells->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psChipAlloc did not allocate cell array properly.");
+        return 23;
     }
 
@@ -487,8 +506,22 @@
 
     psObservatory* obs = psObservatoryAlloc(name,
-                                            20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f);
-
-    psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0,
-                                      now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs);
+                                            20.7*M_PI/180.0,
+                                            156.3*M_PI/180.0,
+                                            3055.0,
+                                            0.0065f);
+
+    psExposure* exp = psExposureAlloc(1.0,
+                                      2.0,
+                                      3.0,
+                                      4.0,
+                                      5.0,
+                                      now,
+                                      6.0f,
+                                      260.0f,
+                                      1013.0f,
+                                      0.7f,
+                                      10.0f,
+                                      0.650f,
+                                      obs);
 
     psFPA* fpa = psFPAAlloc(8, exp);
@@ -507,5 +540,5 @@
         1. invoke psCellAlloc with nReadouts > 0 and parentChip non-NULL. Verify that:
         a. the readouts array is of the size nReadouts and all elements are NULL.
-        b. parent attribute is set to parentChip parameter and the ref. count 
+        b. parent attribute is set to parentChip parameter and the ref. count
            was incremented.
         c. all other attributes are initialized to NULL or 0.
@@ -519,7 +552,13 @@
     }
 
-    if (cell1->readouts->n != 8) {
+    if (cell1->readouts->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psCellAlloc did not set the number of readouts properly.");
+        return 2;
+    }
+
+    if (cell1->readouts->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not allocat the readout array properly.");
         return 2;
     }
@@ -533,4 +572,5 @@
         cell1->readouts->data[lcv] = psAlloc(4); // to check if these are freed.
     }
+    cell1->readouts->n = 8;
 
     if (cell1->parent != chip) {
@@ -584,5 +624,5 @@
         2. invoke psChipAlloc with nCells = 0. Verify that:
         a. execution does not halt
-        b. the cells array is of the size of zero.    
+        b. the cells array is of the size of one.
     */
 
@@ -600,4 +640,10 @@
     }
 
+    if (cell2->readouts->nalloc != 1) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not allocate the readout array properly.");
+        return 13;
+    }
+
     if (cell2->parent != chip) {
         psLogMsg(__func__,PS_LOG_ERROR,
@@ -613,5 +659,5 @@
 
     /*
-        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent 
+        3. invoke psChipAlloc with parentFPA = NULL. Verify that parent
            attribute is NULL and no error is generated.
     */
@@ -624,8 +670,14 @@
     }
 
-    if (cell3->readouts->n != 8) {
+    if (cell3->readouts->n != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psCellAlloc did not set the number of cells properly.");
         return 22;
+    }
+
+    if (cell3->readouts->nalloc != 8) {
+        psLogMsg(__func__,PS_LOG_ERROR,
+                 "psCellAlloc did not set the number of cells properly.");
+        return 23;
     }
 
@@ -647,14 +699,5 @@
 static psS32 testReadoutAlloc(void)
 {
-    psImage* image = psImageAlloc(64,64,PS_TYPE_S8);
-
-
-    /*
-        1. invoke psReadoutAlloc with unique/non-zero x0,y0 and non-NULL image. Verify that:
-        a. col0 & row0 are set to the parameters x0 and y0, respectively.
-        b. image attribute is set to image parameter and referenece is incremented
-        c. mask, objects, and metadata attributes are all NULL
-    */
-    psReadout* readout = psReadoutAlloc(1,2,image);
+    psReadout* readout = psReadoutAlloc();
 
     if (readout == NULL) {
@@ -663,5 +706,5 @@
     }
 
-    if (readout->col0 != 1) {
+    if (readout->col0 != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set col0 properly.");
@@ -669,5 +712,5 @@
     }
 
-    if (readout->row0 != 2) {
+    if (readout->row0 != 0) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set row0 properly.");
@@ -675,5 +718,5 @@
     }
 
-    if (readout->image != image) {
+    if (readout->image != NULL) {
         psLogMsg(__func__,PS_LOG_ERROR,
                  "psReadoutAlloc did not set the image properly.");
@@ -681,9 +724,5 @@
     }
 
-    if (psMemGetRefCounter(image) != 1) {
-        psLogMsg(__func__,PS_LOG_ERROR,
-                 "psReadoutAlloc incremented reference counter for image.");
-        return 5;
-    }
+    readout->image = psAlloc(4); // to check if these are freed.
 
     if (readout->metadata != NULL) {
Index: /trunk/psLib/test/collections/verified/tst_psArray.stderr
===================================================================
--- /trunk/psLib/test/collections/verified/tst_psArray.stderr	(revision 2854)
+++ /trunk/psLib/test/collections/verified/tst_psArray.stderr	(revision 2855)
@@ -3,2 +3,4 @@
 <DATE><TIME>|<HOST>|E|psArrayRealloc (psArray.c:<LINENO>)
     psArrayRealloc must be given a non-NULL psArray to resize.
+<DATE><TIME>|<HOST>|E|psArrayRemove (psArray.c:<LINENO>)
+    Specified psArray can not be NULL.
Index: /trunk/psLib/test/image/tst_psImageManip.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageManip.c	(revision 2854)
+++ /trunk/psLib/test/image/tst_psImageManip.c	(revision 2855)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-12-28 01:43:17 $
+ *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-30 20:18:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
