Index: /branches/eam_rel9_p0/psModules/src/astrom/Makefile.am
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/Makefile.am	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/Makefile.am	(revision 5974)
@@ -6,12 +6,16 @@
 	pmAstrometry.c \
 	pmAstrometryObjects.c \
-	pmChipMosaic.c \
-	pmFPAConceptsGet.c \
-	pmFPAConceptsSet.c \
 	pmFPAConstruct.c \
 	pmFPARead.c \
 	pmFPAWrite.c \
 	pmReadout.c \
-	psAdditionals.c
+	psAdditionals.c \
+	pmConcepts.c \
+	pmConceptsRead.c \
+	pmConceptsWrite.c \
+	pmConceptsStandard.c \
+	pmChipMosaic.c
+###	pmFPAConceptsGet.c
+###	pmFPAConceptsSet.c
 
 psmoduleincludedir = $(includedir)
@@ -19,10 +23,14 @@
 	pmAstrometry.h \
 	pmAstrometryObjects.h \
-	pmChipMosaic.h \
-	pmFPAConceptsGet.h \
-	pmFPAConceptsSet.h \
 	pmFPAConstruct.h \
 	pmFPARead.h \
 	pmFPAWrite.h \
 	pmReadout.h \
-	psAdditionals.h
+	psAdditionals.h \
+	pmConcepts.h \
+	pmConceptsRead.h \
+	pmConceptsWrite.h \
+	pmConceptsStandard.h \
+	pmChipMosaic.h
+###	pmFPAConceptsGet.h
+###	pmFPAConceptsSet.h
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.c	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.c	(revision 5974)
@@ -13,6 +13,6 @@
 * XXX: Should we implement non-linear cell->chip transforms?
 *
-*  @version $Revision: 1.11.2.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-12-17 03:18:38 $
+*  @version $Revision: 1.11.2.1.2.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-01-14 03:10:19 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,5 +25,7 @@
 #include <math.h>
 #include "pslib.h"
+
 #include "pmAstrometry.h"
+#include "pmConcepts.h"
 
 /*****************************************************************************
@@ -201,6 +203,9 @@
         chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell);
     }
-    tmpCell->valid = true;              // All cells are valid by default
+    tmpCell->process = true;            // All cells are processed by default
+    tmpCell->exists = false;            // Not yet read in
     tmpCell->hdu = NULL;
+
+    pmConceptsBlankCell(tmpCell);
 
     psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree);
@@ -231,6 +236,9 @@
         fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
     }
-    tmpChip->valid = true;              // Work on all chips, by default
+    tmpChip->process = true;            // Work on all chips, by default
+    tmpChip->exists = false;            // Not read in yet
     tmpChip->hdu = NULL;
+
+    pmConceptsBlankChip(tmpChip);
 
     psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
@@ -251,4 +259,6 @@
     tmpFPA->hdu = NULL;
     tmpFPA->phu = NULL;
+
+    pmConceptsBlankFPA(tmpFPA);
 
     psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
@@ -817,8 +827,8 @@
  *****************************************************************************/
 
-// Set cells within a chip to a specified validity
-static bool setCellsValid(const pmChip *chip, // Chip of interest
-                          bool valid    // Valid?
-                         )
+// Set cells within a chip to be processed or not
+static bool setCellsProcess(const pmChip *chip, // Chip of interest
+                            bool process  // Process this chip?
+                           )
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
@@ -831,5 +841,5 @@
         pmCell *tmpCell = cells->data[i]; // Cell of interest
         if (tmpCell) {
-            tmpCell->valid = valid;
+            tmpCell->process = process;
         }
     }
@@ -857,9 +867,9 @@
         }
         if (i == chipNum) {
-            tmpChip->valid = true;
-            setCellsValid(tmpChip, true);
+            tmpChip->process = true;
+            setCellsProcess(tmpChip, true);
         } else {
-            tmpChip->valid = false;
-            setCellsValid(tmpChip, false);
+            tmpChip->process = false;
+            setCellsProcess(tmpChip, false);
         }
 
@@ -872,13 +882,13 @@
 /*****************************************************************************
 XXX: The SDRS is ambiguous on a few things:
-    Whether or not the other chips should be set valid=true. [PAP: No]
-    Should we return the number of chip valid=true before or after they're set, [PAP: After]
+    Whether or not the other chips should be set process=true. [PAP: No]
+    Should we return the number of chip process=true before or after they're set, [PAP: After]
  *****************************************************************************/
 /**
  *
- * pmFPAExcludeChip shall set valid to false only for the specified chip
+ * pmFPAExcludeChip shall set process to false only for the specified chip
  * number (chipNum). In the event that the specified chip number does not exist
  * within the fpa, the function shall generate a warning, and perform no action.
- * The function shall return the number of chips within the fpa that have valid
+ * The function shall return the number of chips within the fpa that have process
  * set to true.
  *
@@ -900,12 +910,12 @@
     }
 
-    int numChips = 0;                   // Number of valid chips
+    int numChips = 0;                   // Number of chips to be processed
     for (int i = 0 ; i < chips->n ; i++) {
         pmChip *tmpChip = (pmChip *) chips->data[i]; // Chip of interest
         if (tmpChip != NULL) {
             if (i == chipNum) {
-                tmpChip->valid = false;
-                setCellsValid(tmpChip, false); // Wipe out the cell as well
-            } else if (tmpChip->valid) {
+                tmpChip->process = false;
+                setCellsProcess(tmpChip, false); // Wipe out the cell as well
+            } else if (tmpChip->process) {
                 numChips++;
             }
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.h
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.h	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmAstrometry.h	(revision 5974)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.5.2.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-12-17 03:18:38 $
+*  @version $Revision: 1.5.2.1.2.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-01-14 03:10:19 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -96,5 +96,6 @@
     psArray *cells;                     ///< The cells (referred to by name)
     pmFPA *parent;                      ///< Parent FPA
-    bool valid;                         ///< Do we bother about reading and working with this chip?
+    bool process;                       ///< Do we bother about reading and working with this chip?
+    bool exists;                        ///< Does the chip exist --- has it been read in?
     p_pmHDU *hdu;                       ///< FITS data
 }
@@ -125,5 +126,6 @@
     psArray *readouts;                  ///< The readouts (referred to by number)
     pmChip *parent;                     ///< Parent chip
-    bool valid;                         ///< Do we bother about reading and working with this cell?
+    bool process;                       ///< Do we bother about reading and working with this cell?
+    bool exists;                        ///< Does the cell exist --- has it been read in?
     p_pmHDU *hdu;                       ///< FITS data
 }
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c	(revision 5974)
@@ -106,8 +106,10 @@
 }
 
-psImage *pmChipMosaic(pmChip *chip,     // Chip to mosaic
-                      int xBinChip, int yBinChip // Binning of mosaic image in x and y
-                     )
+// Mosaic a chip together into a single image
+static psImage *mosaicChip(pmChip *chip,// Chip to mosaic
+                           int xBinChip, int yBinChip // Binning of mosaic image in x and y
+                          )
 {
+
     psArray *cells = chip->cells;       // The array of cells
     psArray *images = psArrayAlloc(cells->n); // Array of images that will be mosaicked
@@ -174,2 +176,33 @@
     return mosaic;
 }
+
+
+int pmFPAMosaicChips(pmFPA *fpa,        // FPA
+                     int xBinChip, int yBinChip // Binning of mosaic image in x and y
+                    )
+{
+    assert(fpa);
+
+    int numChips = 0;
+    psArray *chips = fpa->chips;        // Component chips
+    for (int i = 0; i < chips->n; i++) {
+        pmChip *chip = chips->data[i];  // The chip of interest
+        if (! chip || ! chip->exists || ! chip->process) {
+            continue;
+        }
+
+        numChips++;
+        psImage *mosaic = mosaicChip(chip, xBinChip, yBinChip); // Mosaic of cells within the chip
+
+        // Chop off all the component cells, and put in a new one
+        psArrayElementsFree(chip->cells);
+        chip->cells = psArrayRealloc(chip->cells, 1);
+        pmCell *cell = pmCellAlloc(chip, NULL, __func__); // New cell
+        pmReadout *readout = pmReadoutAlloc(cell); // New readout
+        readout->image = mosaic;
+        psFree(readout);
+    }
+
+    return numChips;
+
+}
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.h
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.h	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.h	(revision 5974)
@@ -14,9 +14,8 @@
                         );
 
-// Mosaic all the cells in a chip together (neglecting the overscans)
-psImage *pmChipMosaic(pmChip *chip,     // Chip to mosaic
-                      int xBinChip, int yBinChip // Binning of mosaic image in x and y
-                     );
-
+// Mosaic all the cells in all (valid) chips together (neglecting the overscans); return number of chips
+int pmFPAMosaicChips(pmFPA *fpa,        // FPA
+                     int xBinChip, int yBinChip // Binning of mosaic image in x and y
+                    );
 
 #endif
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmFPAConstruct.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmFPAConstruct.c	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmFPAConstruct.c	(revision 5974)
@@ -62,5 +62,5 @@
                      )
 {
-    pmFPA *fpa = pmFPAAlloc(camera); // The FPA to fill out
+    pmFPA *fpa = pmFPAAlloc(camera);    // The FPA to fill out
     bool mdStatus = true;               // Status from metadata lookups
     const char *phuType = psMetadataLookupStr(&mdStatus, camera, "PHU"); // What is the PHU?
@@ -266,7 +266,4 @@
     }
 
-    // Initialise with dummy concepts, until the real ones can be read.
-    pmFPABlankConcepts(fpa);
-
     return fpa;
 }
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c	(revision 5974)
@@ -4,6 +4,6 @@
 
 #include "pmAstrometry.h"
-#include "pmFPAConceptsGet.h"
 #include "pmFPARead.h"
+#include "pmConcepts.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -157,5 +157,5 @@
         }
     }
-    pmFPAIngestConcepts(fpa, db);
+    pmConceptsReadFPA(fpa, db);
 
     psArray *chips = fpa->chips;        // Array of chips
@@ -164,6 +164,6 @@
         pmChip *chip = chips->data[i]; // The chip
 
-        // Only read chips marked "valid"
-        if (! chip->valid) {
+        // Only read chips marked to "process"
+        if (! chip->process) {
             psTrace(__func__, 2, "Ignoring chip %d...\n", i);
             continue;
@@ -179,5 +179,6 @@
             }
         }
-        pmChipIngestConcepts(chip, db);
+
+        pmConceptsReadChip(chip, db);
 
         // Iterate over the chip
@@ -186,6 +187,6 @@
             pmCell *cell = cells->data[j]; // The cell
 
-            // Only read cells marked "valid"
-            if (! cell->valid) {
+            // Only read cells marked to "process"
+            if (! cell->process) {
                 psTrace(__func__, 3, "Ignoring chip %d...\n", i);
                 continue;
@@ -203,10 +204,13 @@
                 }
             }
-            pmCellIngestConcepts(cell, db);
+            pmConceptsReadCell(cell, db);
 
             psTrace(__func__, 5, "Allocating readouts for chip %d cell %d...\n",
                     i, j);
             generateReadouts(cell, hdu);
-        }
+
+            cell->exists = true;
+        }
+        chip->exists = true;
     }
 
@@ -396,5 +400,5 @@
     for (int chipNum = 0; chipNum < chips->n; chipNum++) {
         pmChip *chip = chips->data[chipNum]; // The current chip of interest
-        if (chip->valid) {
+        if (chip->process) {
             if (chip->hdu) {
                 hdu = chip->hdu;
@@ -403,5 +407,5 @@
             for (int cellNum = 0; cellNum < cells->n; cellNum++) {
                 pmCell *cell = cells->data[cellNum]; // The current cell of interest
-                if (cell->valid) {
+                if (cell->process) {
                     if (cell->hdu) {
                         hdu = cell->hdu;
@@ -534,5 +538,5 @@
     for (int chipNum = 0; chipNum < chips->n; chipNum++) {
         pmChip *chip = chips->data[chipNum]; // The current chip of interest
-        if (chip->valid) {
+        if (chip->process) {
             if (chip->hdu) {
                 hdu = chip->hdu;
@@ -541,5 +545,5 @@
             for (int cellNum = 0; cellNum < cells->n; cellNum++) {
                 pmCell *cell = cells->data[cellNum]; // The current cell of interest
-                if (cell->valid) {
+                if (cell->process) {
                     if (cell->hdu) {
                         hdu = cell->hdu;
Index: /branches/eam_rel9_p0/psModules/src/astrom/pmFPAWrite.c
===================================================================
--- /branches/eam_rel9_p0/psModules/src/astrom/pmFPAWrite.c	(revision 5973)
+++ /branches/eam_rel9_p0/psModules/src/astrom/pmFPAWrite.c	(revision 5974)
@@ -4,6 +4,6 @@
 
 #include "pmAstrometry.h"
-#include "pmFPAConceptsSet.h"
 #include "pmFPARead.h"
+#include "pmConcepts.h"
 
 static bool writeHDU(psFits *fits,      // FITS file to which to write
@@ -29,5 +29,5 @@
 
     psTrace(__func__, 7, "Outgesting FPA concepts...\n");
-    pmFPAOutgestConcepts(fpa, db);
+    pmConceptsWriteFPA(fpa, db);
 
     // Write the primary header
@@ -40,16 +40,16 @@
     for (int i = 0; i < chips->n; i++) {
         pmChip *chip = chips->data[i];  // The component chip
-        if (chip->valid) {
+        if (chip->exists && chip->process) {
             psTrace(__func__, 1, "Writing out chip %d...\n", i);
 
-            pmChipOutgestConcepts(chip, db);
+            pmConceptsWriteChip(chip, db);
 
             psArray *cells = chip->cells;       // Array of component cells
             for (int j = 0; j < cells->n; j++) {
                 pmCell *cell = cells->data[j]; // The component cell
-                if (cell->valid) {
+                if (cell->exists && cell->process) {
                     psTrace(__func__, 2, "Writing out cell, %d...\n", j);
 
-                    pmCellOutgestConcepts(cell, db);
+                    pmConceptsWriteCell(cell, db);
 
                     if (cell->hdu && strlen(cell->hdu->extname) > 0) {
@@ -107,5 +107,5 @@
     for (int chipNum = 0; chipNum < chips->n; chipNum++) {
         pmChip *chip = chips->data[chipNum]; // The current chip of interest
-        if (chip->valid) {
+        if (chip->exists && chip->process) {
             if (chip->hdu) {
                 hdu = chip->hdu;
@@ -114,5 +114,5 @@
             for (int cellNum = 0; cellNum < cells->n; cellNum++) {
                 pmCell *cell = cells->data[cellNum]; // The current cell of interest
-                if (cell->valid) {
+                if (cell->exists && cell->process) {
                     if (cell->hdu) {
                         hdu = cell->hdu;
@@ -198,5 +198,5 @@
     for (int chipNum = 0; chipNum < chips->n; chipNum++) {
         pmChip *chip = chips->data[chipNum]; // The current chip of interest
-        if (chip->valid) {
+        if (chip->exists && chip->process) {
             if (chip->hdu) {
                 hdu = chip->hdu;
@@ -205,5 +205,5 @@
             for (int cellNum = 0; cellNum < cells->n; cellNum++) {
                 pmCell *cell = cells->data[cellNum]; // The current cell of interest
-                if (cell->valid) {
+                if (cell->exists && cell->process) {
                     if (cell->hdu) {
                         hdu = cell->hdu;
