Index: trunk/psModules/src/camera/pmFPAHeader.c
===================================================================
--- trunk/psModules/src/camera/pmFPAHeader.c	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAHeader.c	(revision 18163)
@@ -17,5 +17,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmCellReadHeader(pmCell *cell, psFits *fits, psDB *db)
+bool pmCellReadHeader(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -23,5 +23,5 @@
 
     if (!cell->hdu) {
-        return pmChipReadHeader(cell->parent, fits, db);
+        return pmChipReadHeader(cell->parent, fits, config);
     }
     if (!pmHDUReadHeader(cell->hdu, fits)) {
@@ -30,9 +30,9 @@
     }
 
-    return pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, false, db);
+    return pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, false, config);
 }
 
 
-bool pmChipReadHeader(pmChip *chip, psFits *fits, psDB *db)
+bool pmChipReadHeader(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
@@ -40,5 +40,5 @@
 
     if (!chip->hdu) {
-        return pmFPAReadHeader(chip->parent, fits, db);
+        return pmFPAReadHeader(chip->parent, fits, config);
     }
     if (!pmHDUReadHeader(chip->hdu, fits)) {
@@ -47,5 +47,5 @@
     }
 
-    if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, true, db)) {
+    if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, true, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for chip.\n");
         return false;
@@ -56,5 +56,5 @@
 
 
-bool pmFPAReadHeader(pmFPA *fpa, psFits *fits, psDB *db)
+bool pmFPAReadHeader(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
@@ -69,5 +69,5 @@
     }
 
-    if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, db)) {
+    if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to read concepts for FPA.\n");
         return false;
Index: trunk/psModules/src/camera/pmFPAHeader.h
===================================================================
--- trunk/psModules/src/camera/pmFPAHeader.h	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAHeader.h	(revision 18163)
@@ -1,9 +1,9 @@
 /*  @file pmFPAHeader.h
  *  @brief Functions read FITS headers for FPA components
- * 
+ *
  *  @author Paul Price, IfA
- * 
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-06-14 02:15:05 $
+ *
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-06-17 22:16:38 $
  *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -21,5 +21,5 @@
 bool pmFPAReadHeader(pmFPA *fpa,        ///< FPA for which to read header
                      psFits *fits,       ///< FITS file handle
-		     psDB *db
+                     pmConfig *config   ///< Configuration
                     );
 
@@ -30,5 +30,5 @@
 bool pmChipReadHeader(pmChip *chip,     ///< Chip for which to read header
                       psFits *fits,      ///< FITS file handle
-		     psDB *db
+                     pmConfig *config   ///< Configuration
                      );
 
@@ -39,5 +39,5 @@
 bool pmCellReadHeader(pmCell *cell,     ///< Cell for which to read header
                       psFits *fits,      ///< FITS file handle
-		     psDB *db
+                     pmConfig *config   ///< Configuration
                      );
 /// @}
Index: trunk/psModules/src/camera/pmFPARead.c
===================================================================
--- trunk/psModules/src/camera/pmFPARead.c	(revision 18146)
+++ trunk/psModules/src/camera/pmFPARead.c	(revision 18163)
@@ -82,5 +82,5 @@
 static bool cellNumReadouts(pmCell *cell,    // Cell of interest
                             psFits *fits,    // FITS file
-			    psDB *db
+                            pmConfig *config // Configuration
     )
 {
@@ -94,5 +94,5 @@
         return false;
     }
-    if (!pmCellReadHeader(cell, fits, db)) {
+    if (!pmCellReadHeader(cell, fits, config)) {
         psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
         return false;
@@ -143,5 +143,5 @@
                                   int numScans, // Number of scans to read at a time
                                   fpaReadType type, // Type of image
-                                  psDB *db // Database handle for concepts
+                                  pmConfig *config // Configuration
     )
 {
@@ -153,5 +153,5 @@
 
     if (!pmConceptsReadCell(readout->parent, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE,
-                            true, db)) {
+                            true, config)) {
         psError(PS_ERR_IO, false, "Failed to read concepts for cell.");
         return false;
@@ -209,5 +209,5 @@
                         int numScans,   // Number of scans to read at a time
                         fpaReadType type, // Type of image
-                        psDB *db        // Database handle for concepts
+                        pmConfig *config// Configuration
     )
 {
@@ -229,5 +229,5 @@
         return false;
     }
-    int naxis3 = cellNumReadouts(cell, fits, db); // Number of planes
+    int naxis3 = cellNumReadouts(cell, fits, config); // Number of planes
     if (z >= naxis3) {
         // No more to read
@@ -237,5 +237,5 @@
     int next;                           // Next position
     int last;                           // Last position
-    if (!readoutScanProperties(&next, &last, readout, numScans, type, db)) {
+    if (!readoutScanProperties(&next, &last, readout, numScans, type, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
         return false;
@@ -395,5 +395,5 @@
                              int overlap, // Number of scans (row/col) to overlap between scans
                              fpaReadType type, // Type of image
-                             psDB *db   // Database handle for concepts
+                             pmConfig *config   // Configuration
     )
 {
@@ -416,5 +416,5 @@
     }
 
-    int naxis3 = cellNumReadouts(cell, fits, db); // Number of image planes
+    int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes
     if (z >= naxis3) {
         psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).",
@@ -425,5 +425,5 @@
     int next;                           // Next position
     int last;                           // Last position
-    if (!readoutScanProperties(&next, &last, readout, numScans, type, db)) {
+    if (!readoutScanProperties(&next, &last, readout, numScans, type, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties.");
         return false;
@@ -532,5 +532,5 @@
 static bool cellRead(pmCell *cell,      // Cell into which to read
                      psFits *fits,      // FITS file from which to read
-                     psDB *db,          // Database handle, for concepts ingest
+                     pmConfig *config,  // Configuration
                      fpaReadType type   // Type to read
                     )
@@ -578,5 +578,5 @@
 
     // load in the concept information for this cell
-    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, db)) {
+    if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_DATABASE, true, config)) {
         //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell");
         //return false;
@@ -653,5 +653,5 @@
 static bool chipRead(pmChip *chip,      // Chip into which to read
                      psFits *fits,      // FITS file from which to read
-                     psDB *db,          // Database handle, for concepts ingest
+                     pmConfig *config,  // Configuration
                      fpaReadType type   // Type to read
                     )
@@ -664,5 +664,5 @@
     for (int i = 0; i < cells->n; i++) {
         pmCell *cell = cells->data[i];  // The cell of interest
-        success |= cellRead(cell, fits, db, type);
+        success |= cellRead(cell, fits, config, type);
     }
     if (success) {
@@ -684,5 +684,5 @@
 static bool fpaRead(pmFPA *fpa,         // FPA into which to read
                     psFits *fits,       // FITS file from which to read
-                    psDB *db,           // Database handle, for concepts ingest
+                    pmConfig *config,   // Configuration
                     fpaReadType type    // Type to read
                    )
@@ -695,5 +695,5 @@
     for (int i = 0; i < chips->n; i++) {
         pmChip *chip = chips->data[i];  // The cell of interest
-        success |= chipRead(chip, fits, db, type);
+        success |= chipRead(chip, fits, config, type);
     }
     if (success) {
@@ -720,5 +720,5 @@
 // pmReadoutReadNext is maintained here (for now) to maintain backwards compatibility.
 // pmReadoutReadNext has been replaced by pmReadoutRead, pmReadoutReadChunk, pmReadoutMore
-bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
+bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -741,5 +741,5 @@
     }
 
-    if (!pmCellReadHeader(cell, fits, db)) {
+    if (!pmCellReadHeader(cell, fits, config)) {
         psError(PS_ERR_IO, false, "Unable to read header for cell!\n");
         return false;
@@ -896,13 +896,13 @@
 
 
-bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
+bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, db);
-}
-
-bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
+    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, config);
+}
+
+bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -911,45 +911,45 @@
     PS_ASSERT_INT_NONNEGATIVE(numScans, false);
 
-    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, db);
-}
-
-bool pmReadoutRead(pmReadout *readout, psFits *fits, int z, psDB *db)
+    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, config);
+}
+
+bool pmReadoutRead(pmReadout *readout, psFits *fits, int z, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, db);
-}
-
-int pmCellNumReadouts(pmCell *cell, psFits *fits, psDB *db)
+    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, config);
+}
+
+int pmCellNumReadouts(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return cellNumReadouts(cell, fits, db);
-}
-
-bool pmCellRead(pmCell *cell, psFits *fits, psDB *db)
+    return cellNumReadouts(cell, fits, config);
+}
+
+bool pmCellRead(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return cellRead(cell, fits, db, FPA_READ_TYPE_IMAGE);
-}
-
-bool pmChipRead(pmChip *chip, psFits *fits, psDB *db)
+    return cellRead(cell, fits, config, FPA_READ_TYPE_IMAGE);
+}
+
+bool pmChipRead(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return chipRead(chip, fits, db, FPA_READ_TYPE_IMAGE);
-}
-
-bool pmFPARead(pmFPA *fpa, psFits *fits, psDB *db)
+    return chipRead(chip, fits, config, FPA_READ_TYPE_IMAGE);
+}
+
+bool pmFPARead(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return fpaRead(fpa, fits, db, FPA_READ_TYPE_IMAGE);
+    return fpaRead(fpa, fits, config, FPA_READ_TYPE_IMAGE);
 }
 
@@ -959,13 +959,14 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
+bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, db);
-}
-
-bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
+    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, config);
+}
+
+bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
+                            pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -974,37 +975,37 @@
     PS_ASSERT_INT_NONNEGATIVE(numScans, false);
 
-    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, db);
-}
-
-bool pmReadoutReadMask(pmReadout *readout, psFits *fits, int z, psDB *db)
+    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, config);
+}
+
+bool pmReadoutReadMask(pmReadout *readout, psFits *fits, int z, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, db);
-}
-
-bool pmCellReadMask(pmCell *cell, psFits *fits, psDB *db)
+    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, config);
+}
+
+bool pmCellReadMask(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return cellRead(cell, fits, db, FPA_READ_TYPE_MASK);
-}
-
-bool pmChipReadMask(pmChip *chip, psFits *fits, psDB *db)
+    return cellRead(cell, fits, config, FPA_READ_TYPE_MASK);
+}
+
+bool pmChipReadMask(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return chipRead(chip, fits, db, FPA_READ_TYPE_MASK);
-}
-
-bool pmFPAReadMask(pmFPA *fpa, psFits *fits, psDB *db)
+    return chipRead(chip, fits, config, FPA_READ_TYPE_MASK);
+}
+
+bool pmFPAReadMask(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return fpaRead(fpa, fits, db, FPA_READ_TYPE_MASK);
+    return fpaRead(fpa, fits, config, FPA_READ_TYPE_MASK);
 }
 
@@ -1013,13 +1014,14 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmReadoutMoreWeight(pmReadout *readout, psFits *fits, int z, int numScans, psDB *db)
+bool pmReadoutMoreWeight(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_WEIGHT, db);
-}
-
-bool pmReadoutReadChunkWeight(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, psDB *db)
+    return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_WEIGHT, config);
+}
+
+bool pmReadoutReadChunkWeight(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,
+                              pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -1028,37 +1030,37 @@
     PS_ASSERT_INT_NONNEGATIVE(numScans, false);
 
-    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_WEIGHT, db);
-}
-
-bool pmReadoutReadWeight(pmReadout *readout, psFits *fits, int z, psDB *db)
+    return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_WEIGHT, config);
+}
+
+bool pmReadoutReadWeight(pmReadout *readout, psFits *fits, int z, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_WEIGHT, db);
-}
-
-bool pmCellReadWeight(pmCell *cell, psFits *fits, psDB *db)
+    return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_WEIGHT, config);
+}
+
+bool pmCellReadWeight(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return cellRead(cell, fits, db, FPA_READ_TYPE_WEIGHT);
-}
-
-bool pmChipReadWeight(pmChip *chip, psFits *fits, psDB *db)
+    return cellRead(cell, fits, config, FPA_READ_TYPE_WEIGHT);
+}
+
+bool pmChipReadWeight(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return chipRead(chip, fits, db, FPA_READ_TYPE_WEIGHT);
-}
-
-bool pmFPAReadWeight(pmFPA *fpa, psFits *fits, psDB *db)
+    return chipRead(chip, fits, config, FPA_READ_TYPE_WEIGHT);
+}
+
+bool pmFPAReadWeight(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return fpaRead(fpa, fits, db, FPA_READ_TYPE_WEIGHT);
+    return fpaRead(fpa, fits, config, FPA_READ_TYPE_WEIGHT);
 }
 
@@ -1067,26 +1069,26 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmCellReadHeaderSet(pmCell *cell, psFits *fits, psDB *db)
+bool pmCellReadHeaderSet(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return cellRead(cell, fits, db, FPA_READ_TYPE_HEADER);
-}
-
-bool pmChipReadHeaderSet(pmChip *chip, psFits *fits, psDB *db)
+    return cellRead(cell, fits, config, FPA_READ_TYPE_HEADER);
+}
+
+bool pmChipReadHeaderSet(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return chipRead(chip, fits, db, FPA_READ_TYPE_HEADER);
-}
-
-bool pmFPAReadHeaderSet(pmFPA *fpa, psFits *fits, psDB *db)
+    return chipRead(chip, fits, config, FPA_READ_TYPE_HEADER);
+}
+
+bool pmFPAReadHeaderSet(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    return fpaRead(fpa, fits, db, FPA_READ_TYPE_HEADER);
+    return fpaRead(fpa, fits, config, FPA_READ_TYPE_HEADER);
 }
 
Index: trunk/psModules/src/camera/pmFPARead.h
===================================================================
--- trunk/psModules/src/camera/pmFPARead.h	(revision 18146)
+++ trunk/psModules/src/camera/pmFPARead.h	(revision 18163)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-06-14 02:15:05 $
+ * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -11,4 +11,6 @@
 #ifndef PM_FPA_READ_H
 #define PM_FPA_READ_H
+
+#include <pmConfig.h>
 
 /// @addtogroup Camera Camera Layout
@@ -20,5 +22,5 @@
                    int z,               ///< Readout number/plane; zero-offset indexing
                    int numScans,        ///< Number of scans (rows/cols) to read
-                   psDB *db             ///< Database handle for concepts
+                   pmConfig *config     ///< Configuration
     );
 
@@ -31,5 +33,5 @@
                         int numScans,   ///< Number of scans (rows/cols) to read
                         int overlap,    ///< Overlap between consecutive reads
-                        psDB *db        ///< Database handle for concepts
+                        pmConfig *config ///< Configuration
     );
 
@@ -38,5 +40,5 @@
                    psFits *fits,        ///< FITS file from which to read
                    int z,               ///< Readout number/plane; zero-offset indexing
-                   psDB *db             ///< Database handle for concepts
+                   pmConfig *config     ///< Configuration
     );
 
@@ -57,5 +59,5 @@
                        int z,           // Readout number/plane; zero-offset indexing
                        int numRows,      // The number of rows to read
-		       psDB *db
+                       pmConfig *config
                       );
 
@@ -63,5 +65,5 @@
 ///
 /// This function is type-independent (doesn't matter if you are interested in the image/mask/weight).
-int pmCellNumReadouts(pmCell *cell, psFits *fits, psDB *db);
+int pmCellNumReadouts(pmCell *cell, psFits *fits, pmConfig *config);
 
 /// Read an entire cell
@@ -71,5 +73,5 @@
 bool pmCellRead(pmCell *cell,           // Cell to read into
                 psFits *fits,           // FITS file from which to read
-                psDB *db                // Database handle, for "concepts" ingest
+                pmConfig *config        // Configuration
                );
 
@@ -79,5 +81,5 @@
 bool pmChipRead(pmChip *chip,           // Chip to read into
                 psFits *fits,           // FITS file from which to read
-                psDB *db                // Database handle, for "concepts" ingest
+                pmConfig *config        // Configuration
                );
 
@@ -87,5 +89,5 @@
 bool pmFPARead(pmFPA *fpa,              // FPA to read into
                psFits *fits,            // FITS file from which to read
-               psDB *db                 // Database handle, for "concepts" ingest
+               pmConfig *config         // Configuration
               );
 
@@ -97,5 +99,5 @@
                        int z,           ///< Readout number/plane; zero-offset indexing
                        int numScans,    ///< Number of scans (rows/cols) to read
-                       psDB *db         ///< Database handle for concepts
+                       pmConfig *config ///< Configuration
     );
 
@@ -108,5 +110,5 @@
                             int numScans, ///< Number of scans (rows/cols) to read
                             int overlap, ///< Overlap between consecutive reads
-                            psDB *db    ///< Database handle for concepts
+                            pmConfig *config ///< Configuration
     );
 
@@ -115,5 +117,5 @@
                        psFits *fits,    ///< FITS file from which to read
                        int z,           ///< Readout number/plane; zero-offset indexing
-                       psDB *db         ///< Database handle for concepts
+                       pmConfig *config ///< Configuration
     );
 
@@ -123,5 +125,5 @@
 bool pmCellReadMask(pmCell *cell,       // Cell to read into
                     psFits *fits,       // FITS file from which to read
-                    psDB *db            // Database handle, for "concepts" ingest
+                    pmConfig *config    // Configuration
                    );
 
@@ -131,5 +133,5 @@
 bool pmChipReadMask(pmChip *chip,       // Chip to read into
                     psFits *fits,       // FITS file from which to read
-                    psDB *db            // Database handle, for "concepts" ingest
+                    pmConfig *config    // Configuration
                    );
 
@@ -139,5 +141,5 @@
 bool pmFPAReadMask(pmFPA *fpa,          // FPA to read into
                    psFits *fits,        // FITS file from which to read
-                   psDB *db             // Database handle, for "concepts" ingest
+                   pmConfig *config     // Configuration
                   );
 
@@ -149,5 +151,5 @@
                          int z,         ///< Readout number/plane; zero-offset indexing
                          int numScans,  ///< Number of scans (rows/cols) to read
-                         psDB *db       ///< Database handle for concepts
+                         pmConfig *config ///< Configuration
     );
 
@@ -160,5 +162,5 @@
                               int numScans, ///< Number of scans (rows/cols) to read
                               int overlap, ///< Overlap between consecutive reads
-                              psDB *db  ///< Database handle for concepts
+                              pmConfig *config ///< Configuration
     );
 
@@ -167,5 +169,5 @@
                          psFits *fits,  ///< FITS file from which to read
                          int z,         ///< Readout number/plane; zero-offset indexing
-                         psDB *db       ///< Database handle for concepts
+                         pmConfig *config ///< Configuration
     );
 
@@ -173,7 +175,7 @@
 ///
 /// Same as pmCellRead, but reads into the weight element of the readouts.
-bool pmCellReadWeight(pmCell *cell,           // Cell to read into
-                      psFits *fits,           // FITS file from which to read
-                      psDB *db                // Database handle, for "concepts" ingest
+bool pmCellReadWeight(pmCell *cell,     // Cell to read into
+                      psFits *fits,     // FITS file from which to read
+                      pmConfig *config  // Configuration
                      );
 
@@ -181,7 +183,7 @@
 ///
 /// Same as pmChipRead, but reads into the weight element of the readouts.
-bool pmChipReadWeight(pmChip *chip,           // Chip to read into
-                      psFits *fits,           // FITS file from which to read
-                      psDB *db                // Database handle, for "concepts" ingest
+bool pmChipReadWeight(pmChip *chip,     // Chip to read into
+                      psFits *fits,     // FITS file from which to read
+                      pmConfig *config  // Configuration
                      );
 
@@ -189,7 +191,7 @@
 ///
 /// Same as pmFPARead, but reads into the weight element of the readouts.
-bool pmFPAReadWeight(pmFPA *fpa,              // FPA to read into
-                     psFits *fits,            // FITS file from which to read
-                     psDB *db                 // Database handle, for "concepts" ingest
+bool pmFPAReadWeight(pmFPA *fpa,        // FPA to read into
+                     psFits *fits,      // FITS file from which to read
+                     pmConfig *config   // Configuration
                     );
 
@@ -197,7 +199,7 @@
 ///
 /// Same as pmCellRead, but reads only the headers of the readouts.
-bool pmCellReadHeaderSet(pmCell *cell,           // Cell to read into
-                         psFits *fits,           // FITS file from which to read
-                         psDB *db                // Database handle, for "concepts" ingest
+bool pmCellReadHeaderSet(pmCell *cell,  // Cell to read into
+                         psFits *fits,  // FITS file from which to read
+                         pmConfig *config // Configuration
     );
 
@@ -205,7 +207,7 @@
 ///
 /// Same as pmChipRead, but reads only the headers of the readouts.
-bool pmChipReadHeaderSet(pmChip *chip,           // Chip to read into
-                      psFits *fits,           // FITS file from which to read
-                      psDB *db                // Database handle, for "concepts" ingest
+bool pmChipReadHeaderSet(pmChip *chip,  // Chip to read into
+                      psFits *fits,     // FITS file from which to read
+                      pmConfig *config  // Configuration
                      );
 
@@ -213,7 +215,7 @@
 ///
 /// Same as pmFPARead, but reads only the headers of the readouts.
-bool pmFPAReadHeaderSet(pmFPA *fpa,              // FPA to read into
-                        psFits *fits,            // FITS file from which to read
-                        psDB *db                 // Database handle, for "concepts" ingest
+bool pmFPAReadHeaderSet(pmFPA *fpa,     // FPA to read into
+                        psFits *fits,   // FITS file from which to read
+                        pmConfig *config // Configuration
     );
 
Index: trunk/psModules/src/camera/pmFPAWrite.c
===================================================================
--- trunk/psModules/src/camera/pmFPAWrite.c	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAWrite.c	(revision 18163)
@@ -128,5 +128,5 @@
 static bool cellWrite(pmCell *cell,     // Cell to write
                       psFits *fits,     // FITS file to which to write
-                      psDB *db,         // Database handle for "concepts" update
+                      pmConfig *config, // Configuration
                       bool blank,       // Write a blank PHU?
                       fpaWriteType type // Type to write
@@ -178,5 +178,5 @@
 static bool chipWrite(pmChip *chip,     // Chip to write
                       psFits *fits,     // FITS file to which to write
-                      psDB *db,         // Database handle for "concepts" update
+                      pmConfig *config, // Configuration
                       bool blank,       // Write a blank PHU?
                       bool recurse,     // Recurse to lower levels?
@@ -228,5 +228,5 @@
         for (int i = 0; i < cells->n; i++) {
             pmCell *cell = cells->data[i];  // The cell of interest
-            if (!cellWrite(cell, fits, db, false, type)) {
+            if (!cellWrite(cell, fits, config, false, type)) {
                 psError(PS_ERR_IO, false, "Unable to write Chip.\n");
                 return false;
@@ -242,5 +242,5 @@
 static bool fpaWrite(pmFPA *fpa,        // FPA to write
                      psFits *fits,      // FITS file to which to write
-                     psDB *db,          // Database handle for "concepts" update
+                     pmConfig *config,  // Configuration
                      bool blank,        // Write a blank PHU?
                      bool recurse,      // Recurse to lower levels?
@@ -291,5 +291,5 @@
         for (int i = 0; i < chips->n; i++) {
             pmChip *chip = chips->data[i];  // The chip of interest
-            if (!chipWrite(chip, fits, db, false, true, type)) {
+            if (!chipWrite(chip, fits, config, false, true, type)) {
                 psError(PS_ERR_IO, false, "Unable to write FPA.\n");
                 return false;
@@ -372,67 +372,67 @@
 
 
-bool pmCellWrite(pmCell *cell, psFits *fits, psDB *db, bool blank)
+bool pmCellWrite(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_IMAGE);
-}
-
-bool pmChipWrite(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
+    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_IMAGE);
+}
+
+bool pmChipWrite(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
-}
-
-bool pmFPAWrite(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
+    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_IMAGE);
+}
+
+bool pmFPAWrite(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_IMAGE);
-}
-
-
-bool pmCellWriteMask(pmCell *cell, psFits *fits, psDB *db, bool blank)
+    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_IMAGE);
+}
+
+
+bool pmCellWriteMask(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_MASK);
-}
-
-bool pmChipWriteMask(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
+    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_MASK);
+}
+
+bool pmChipWriteMask(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
-}
-
-bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
+    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_MASK);
+}
+
+bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_MASK);
-}
-
-
-bool pmCellWriteWeight(pmCell *cell, psFits *fits, psDB *db, bool blank)
+    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_MASK);
+}
+
+
+bool pmCellWriteWeight(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return cellWrite(cell, fits, db, blank, FPA_WRITE_TYPE_WEIGHT);
-}
-
-bool pmChipWriteWeight(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
+    return cellWrite(cell, fits, config, blank, FPA_WRITE_TYPE_WEIGHT);
+}
+
+bool pmChipWriteWeight(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return chipWrite(chip, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
-}
-
-bool pmFPAWriteWeight(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
+    return chipWrite(chip, fits, config, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
+}
+
+bool pmFPAWriteWeight(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_PTR_NON_NULL(fits, false);
-    return fpaWrite(fpa, fits, db, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
+    return fpaWrite(fpa, fits, config, blank, recurse, FPA_WRITE_TYPE_WEIGHT);
 }
 
Index: trunk/psModules/src/camera/pmFPAWrite.h
===================================================================
--- trunk/psModules/src/camera/pmFPAWrite.h	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAWrite.h	(revision 18163)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-03-31 04:17:41 $
+ * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -11,4 +11,6 @@
 #ifndef PM_FPA_WRITE_H
 #define PM_FPA_WRITE_H
+
+#include <pmConfig.h>
 
 /// @addtogroup Camera Camera Layout
@@ -32,5 +34,5 @@
 bool pmCellWrite(pmCell *cell,          ///<  Cell to write
                  psFits *fits,          ///<  FITS file to which to write
-                 psDB *db,              ///<  Database handle for "concepts" update
+                 pmConfig *config,      ///<  Configuration
                  bool blank             ///<  Write a blank PHU?
                 );
@@ -44,5 +46,5 @@
 bool pmChipWrite(pmChip *chip,          ///<  Chip to write
                  psFits *fits,          ///<  FITS file to which to write
-                 psDB *db,              ///<  Database handle for "concepts" update
+                 pmConfig *config,      ///<  Configuration
                  bool blank,            ///<  Write a blank PHU?
                  bool recurse           ///<  Recurse to lower levels?
@@ -57,5 +59,5 @@
 bool pmFPAWrite(pmFPA *fpa,             ///<  FPA to write
                 psFits *fits,           ///<  FITS file to which to write
-                psDB *db,               ///<  Database handle for "concepts" update
+                pmConfig *config,       ///<  Configuration
                 bool blank,             ///<  Write a blank PHU?
                 bool recurse            ///<  Recurse to lower levels?
@@ -70,5 +72,5 @@
 bool pmCellWriteMask(pmCell *cell,      ///<  Cell to write
                      psFits *fits,      ///<  FITS file to which to write
-                     psDB *db,          ///<  Database handle for "concepts" update
+                     pmConfig *config,  ///<  Configuration
                      bool blank         ///<  Write a blank PHU?
                     );
@@ -83,5 +85,5 @@
 bool pmChipWriteMask(pmChip *chip,      ///<  Chip to write
                      psFits *fits,      ///<  FITS file to which to write
-                     psDB *db,          ///<  Database handle for "concepts" update
+                     pmConfig *config,  ///<  Configuration
                      bool blank,        ///<  Write a blank PHU?
                      bool recurse       ///<  Recurse to lower levels?
@@ -97,5 +99,5 @@
 bool pmFPAWriteMask(pmFPA *fpa,         ///<  FPA to write
                     psFits *fits,       ///<  FITS file to which to write
-                    psDB *db,           ///<  Database handle for "concepts" update
+                    pmConfig *config,   ///<  Configuration
                     bool blank,         ///<  Write a blank PHU?
                     bool recurse        ///<  Recurse to lower levels?
@@ -110,5 +112,5 @@
 bool pmCellWriteWeight(pmCell *cell,    ///<  Cell to write
                        psFits *fits,    ///<  FITS file to which to write
-                       psDB *db,        ///<  Database handle for "concepts" update
+                       pmConfig *config, ///<  Configuration
                        bool blank       ///<  Write a blank PHU?
                       );
@@ -123,5 +125,5 @@
 bool pmChipWriteWeight(pmChip *chip,    ///<  Chip to write
                        psFits *fits,    ///<  FITS file to which to write
-                       psDB *db,        ///<  Database handle for "concepts" update
+                       pmConfig *config, ///<  Configuration
                        bool blank,      ///<  Write a blank PHU?
                        bool recurse     ///<  Recurse to lower levels?
@@ -137,5 +139,5 @@
 bool pmFPAWriteWeight(pmFPA *fpa,       ///<  FPA to write
                       psFits *fits,     ///<  FITS file to which to write
-                      psDB *db,         ///<  Database handle for "concepts" update
+                      pmConfig *config, ///<  Configuration
                       bool blank,       ///<  Write a blank PHU?
                       bool recurse      ///<  Recurse to lower levels?
Index: trunk/psModules/src/camera/pmFPAfileFitsIO.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 18163)
@@ -166,8 +166,8 @@
 static bool fpaViewReadFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
                                  pmFPAfile *file, // FPA file of interest
-				 psDB *db, 
-                                 bool (*fpaReadFunc)(pmFPA*, psFits*, psDB*), // Function to read FPA
-                                 bool (*chipReadFunc)(pmChip*, psFits*, psDB*), // Function to read chip
-                                 bool (*cellReadFunc)(pmCell*, psFits*, psDB*) // Function to read cell
+                                 pmConfig *config, // Configuration
+                                 bool (*fpaReadFunc)(pmFPA*, psFits*, pmConfig*), // Function to read FPA
+                                 bool (*chipReadFunc)(pmChip*, psFits*, pmConfig*), // Function to read chip
+                                 bool (*cellReadFunc)(pmCell*, psFits*, pmConfig*) // Function to read cell
                                 )
 {
@@ -179,5 +179,5 @@
 
     if (view->chip == -1) {
-        return fpaReadFunc(fpa, fits, db);
+        return fpaReadFunc(fpa, fits, config);
     }
 
@@ -189,5 +189,5 @@
 
     if (view->cell == -1) {
-        return chipReadFunc(chip, fits, db);
+        return chipReadFunc(chip, fits, config);
     }
 
@@ -199,5 +199,5 @@
 
     if (view->readout == -1) {
-        return cellReadFunc(cell, fits, db);
+        return cellReadFunc(cell, fits, config);
     }
     psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell);
@@ -215,5 +215,5 @@
 
     if (view->nRows == 0) {
-        pmReadoutRead (readout, fits, db);
+        pmReadoutRead (readout, fits, config);
     } else {
         pmReadoutReadSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
@@ -228,5 +228,5 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
     PS_ASSERT_PTR_NON_NULL(file, false);
-    return fpaViewReadFitsImage(view, file, config->database, pmFPARead, pmChipRead, pmCellRead);
+    return fpaViewReadFitsImage(view, file, config, pmFPARead, pmChipRead, pmCellRead);
 }
 
@@ -235,5 +235,5 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
     PS_ASSERT_PTR_NON_NULL(file, false);
-    return fpaViewReadFitsImage(view, file, config->database, pmFPAReadMask, pmChipReadMask, pmCellReadMask);
+    return fpaViewReadFitsImage(view, file, config, pmFPAReadMask, pmChipReadMask, pmCellReadMask);
 }
 
@@ -242,5 +242,5 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
     PS_ASSERT_PTR_NON_NULL(file, false);
-    return fpaViewReadFitsImage(view, file, config->database, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight);
+    return fpaViewReadFitsImage(view, file, config, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight);
 }
 
@@ -249,5 +249,5 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
     PS_ASSERT_PTR_NON_NULL(file, false);
-    return fpaViewReadFitsImage(view, file, config->database, pmFPAReadDark, pmChipReadDark, pmCellReadDark);
+    return fpaViewReadFitsImage(view, file, config, pmFPAReadDark, pmChipReadDark, pmCellReadDark);
 }
 
@@ -256,5 +256,5 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
     PS_ASSERT_PTR_NON_NULL(file, false);
-    return fpaViewReadFitsImage(view, file, config->database, pmFPAReadHeaderSet, pmChipReadHeaderSet, pmCellReadHeaderSet);
+    return fpaViewReadFitsImage(view, file, config, pmFPAReadHeaderSet, pmChipReadHeaderSet, pmCellReadHeaderSet);
 }
 
@@ -267,8 +267,8 @@
 static bool fpaViewWriteFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest
                                   pmFPAfile *file, // FPA file of interest
-                                  const pmConfig *config, // Configuration
-                                  bool (*fpaWriteFunc)(pmFPA*, psFits*, psDB*, bool, bool), // Func for FPA
-                                  bool (*chipWriteFunc)(pmChip*, psFits*, psDB*, bool, bool), // Func for chip
-                                  bool (*cellWriteFunc)(pmCell*, psFits*, psDB*, bool) // Func for cell
+                                  pmConfig *config, // Configuration
+                                  bool (*fpaWriteFunc)(pmFPA*, psFits*, pmConfig*, bool, bool), // Func FPA
+                                  bool (*chipWriteFunc)(pmChip*, psFits*, pmConfig*, bool, bool),// Func chip
+                                  bool (*cellWriteFunc)(pmCell*, psFits*, pmConfig*, bool) // Func cell
                                  )
 {
@@ -283,5 +283,5 @@
     switch (pmFPAviewLevel(view)) {
     case PM_FPA_LEVEL_FPA: {
-            bool success = fpaWriteFunc(fpa, fits, NULL, false, true);
+            bool success = fpaWriteFunc(fpa, fits, config, false, true);
             psFree(fpa);
             return success;
@@ -289,5 +289,5 @@
     case PM_FPA_LEVEL_CHIP: {
             pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest
-            bool success = chipWriteFunc(chip, fits, NULL, false, true);
+            bool success = chipWriteFunc(chip, fits, config, false, true);
             psFree(fpa);
             return success;
@@ -295,5 +295,5 @@
     case PM_FPA_LEVEL_CELL: {
             pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest
-            bool success = cellWriteFunc(cell, fits, NULL, false);
+            bool success = cellWriteFunc(cell, fits, config, false);
             psFree(fpa);
             return success;
@@ -327,5 +327,5 @@
 }
 
-bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
+bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(view, false);
@@ -334,5 +334,5 @@
 }
 
-bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
+bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(view, false);
@@ -341,5 +341,5 @@
 }
 
-bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
+bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(view, false);
@@ -348,5 +348,5 @@
 }
 
-bool pmFPAviewWriteFitsDark(const pmFPAview *view, pmFPAfile *file, const pmConfig *config)
+bool pmFPAviewWriteFitsDark(const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(view, false);
Index: trunk/psModules/src/camera/pmFPAfileFitsIO.h
===================================================================
--- trunk/psModules/src/camera/pmFPAfileFitsIO.h	(revision 18146)
+++ trunk/psModules/src/camera/pmFPAfileFitsIO.h	(revision 18163)
@@ -5,6 +5,6 @@
  * @author PAP, IfA
  *
- * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-06-14 03:19:31 $
+ * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
  */
@@ -19,5 +19,5 @@
 bool pmFPAviewReadFitsImage(const pmFPAview *view, ///< View specifying level of interest
                             pmFPAfile *file, ///< FPA file into which to read
-			    pmConfig *config
+                            pmConfig *config
                            );
 
@@ -25,10 +25,10 @@
 bool pmFPAviewReadFitsMask(const pmFPAview *view, ///< View specifying level of interest
                            pmFPAfile *file, ///< FPA file into which to read
-			    pmConfig *config
+                            pmConfig *config
                           );
 /// Read a weight map into the current view
 bool pmFPAviewReadFitsWeight(const pmFPAview *view,  ///< View specifying level of interest
                              pmFPAfile *file, ///< FPA file into which to read
-			    pmConfig *config
+                            pmConfig *config
                             );
 
@@ -36,5 +36,5 @@
 bool pmFPAviewReadFitsDark(const pmFPAview *view,  ///< View specifying level of interest
                            pmFPAfile *file, ///< FPA file into which to read
-			    pmConfig *config
+                            pmConfig *config
     );
 
@@ -42,5 +42,5 @@
 bool pmFPAviewReadFitsHeaderSet(const pmFPAview *view,  ///< View specifying level of interest
                                 pmFPAfile *file, ///< FPA file into which to read
-			    pmConfig *config
+                            pmConfig *config
     );
 
@@ -48,5 +48,5 @@
 bool pmFPAviewWriteFitsImage(const pmFPAview *view, ///< View specifying level of interest
                              pmFPAfile *file, ///< FPA file to write
-                             const pmConfig *config ///< Configuration
+                             pmConfig *config ///< Configuration
                             );
 
@@ -54,5 +54,5 @@
 bool pmFPAviewWriteFitsMask(const pmFPAview *view, ///< View specifying level of interest
                             pmFPAfile *file, ///< FPA file to write
-                            const pmConfig *config ///< Configuration
+                            pmConfig *config ///< Configuration
                            );
 
@@ -60,5 +60,5 @@
 bool pmFPAviewWriteFitsWeight(const pmFPAview *view, ///< View specifying level of interest
                               pmFPAfile *file, ///< FPA file to write
-                              const pmConfig *config ///< Configuration
+                              pmConfig *config ///< Configuration
                              );
 
@@ -66,5 +66,5 @@
 bool pmFPAviewWriteFitsDark(const pmFPAview *view, ///< View specifying level of interest
                             pmFPAfile *file, ///< FPA file to write
-                            const pmConfig *config ///< Configuration
+                            pmConfig *config ///< Configuration
     );
 
Index: trunk/psModules/src/concepts/pmConcepts.c
===================================================================
--- trunk/psModules/src/concepts/pmConcepts.c	(revision 18146)
+++ trunk/psModules/src/concepts/pmConcepts.c	(revision 18163)
@@ -10,4 +10,5 @@
 #include <string.h>
 
+#include "pmConfig.h"
 #include "pmHDU.h"
 #include "pmFPA.h"
@@ -195,5 +196,5 @@
                          unsigned int *read,     // What's already been read
                          pmConceptSource source, // The source of the concepts to read
-                         psDB *db,      // Database handle
+                         pmConfig *config, // Configuration
                          psMetadata *target // Place into which to read the concepts
                         )
@@ -256,5 +257,5 @@
     #ifdef HAVE_PSDB
     if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) {
-        if (p_pmConceptsReadFromDatabase(target, *specs, fpa, chip, cell, db)) {
+        if (p_pmConceptsReadFromDatabase(target, *specs, fpa, chip, cell, config)) {
             *read |= PM_CONCEPT_SOURCE_DATABASE;
         } else {
@@ -276,5 +277,5 @@
                           const pmCell *cell, // The cell
                           pmConceptSource source, // The source of the concepts to write
-                          psDB *db,      // Database handle
+                          pmConfig *config, // Configuration
                           const psMetadata *concepts // The concepts to write out
                          )
@@ -299,5 +300,5 @@
     }
     if (source & PM_CONCEPT_SOURCE_DATABASE) {
-        p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, db, concepts);
+        p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts);
     }
 
@@ -306,13 +307,16 @@
 
 
-bool pmConceptsRead(pmFPA *fpa, pmChip *chip, pmCell *cell, pmConceptSource source, psDB *db)
+bool pmConceptsRead(pmFPA *fpa, pmChip *chip, pmCell *cell, pmConceptSource source, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
-    bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db, fpa->concepts);
+    bool success = conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source,
+                                config, fpa->concepts);
     if (chip) {
-        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db, chip->concepts);
+        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source,
+                                config, chip->concepts);
     }
     if (cell) {
-        success &= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db, cell->concepts);
+        success &= conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source,
+                                config, cell->concepts);
     }
 
@@ -329,9 +333,10 @@
 
 
-bool pmConceptsReadFPA(pmFPA *fpa, pmConceptSource source, bool propagateDown, psDB *db)
+bool pmConceptsReadFPA(pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     psTrace("psModules.concepts", 5, "Reading FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
-    bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
+    bool success = conceptsRead(&conceptsFPA, fpa, NULL, NULL, &fpa->conceptsRead, source,
+                                config, fpa->concepts);
     if (propagateDown) {
         psArray *chips = fpa->chips;    // Array of chips
@@ -339,5 +344,5 @@
             pmChip *chip = chips->data[i]; // Chip of interest
             if (chip) {
-                success &= pmConceptsReadChip(chip, source, false, true, db);
+                success &= pmConceptsReadChip(chip, source, false, true, config);
             }
         }
@@ -347,9 +352,9 @@
 }
 
-bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source, bool propagateDown, psDB *db)
+bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source, bool propagateDown, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts);
-    bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
+    bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, config, fpa->concepts);
     if (propagateDown) {
         psArray *chips = fpa->chips;        // Array of chips
@@ -357,5 +362,5 @@
             pmChip *chip = chips->data[i];  // Chip of interest
             if (chip && !chip->hdu) {
-                success &= pmConceptsWriteChip(chip, source, false, true, db);
+                success &= pmConceptsWriteChip(chip, source, false, true, config);
             }
         }
@@ -372,13 +377,14 @@
 
 bool pmConceptsReadChip(pmChip *chip, pmConceptSource source, bool propagateUp,
-                        bool propagateDown, psDB *db)
+                        bool propagateDown, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     psTrace("psModules.concepts", 5, "Reading chip concepts: %p %p\n", conceptsChip, chip->concepts);
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, db,
+    bool success = conceptsRead(&conceptsChip, fpa, chip, NULL, &chip->conceptsRead, source, config,
                                 chip->concepts);
     if (propagateUp) {
-        success &= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source, db, fpa->concepts);
+        success &= conceptsRead(&conceptsFPA, fpa, chip, NULL, &fpa->conceptsRead, source,
+                                config, fpa->concepts);
     }
     if (propagateDown) {
@@ -387,5 +393,5 @@
             pmCell *cell = cells->data[i];  // Cell of interest
             if (cell) {
-                success &= pmConceptsReadCell(cell, source, false, db);
+                success &= pmConceptsReadCell(cell, source, false, config);
             }
         }
@@ -395,12 +401,12 @@
 
 bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp,
-                         bool propagateDown, psDB *db)
+                         bool propagateDown, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts);
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
+    bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source, config, chip->concepts);
     if (propagateUp && !fpa->hdu) {
-        success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, db, fpa->concepts);
+        success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source, config, fpa->concepts);
     }
     if (propagateDown) {
@@ -409,5 +415,5 @@
             pmCell *cell = cells->data[i];  // Cell of interest
             if (cell && !cell->hdu) {
-                success &= pmConceptsWriteCell(cell, source, false, db);
+                success &= pmConceptsWriteCell(cell, source, false, config);
             }
         }
@@ -423,5 +429,5 @@
 }
 
-bool pmConceptsReadCell(pmCell *cell, pmConceptSource source, bool propagateUp, psDB *db)
+bool pmConceptsReadCell(pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -430,10 +436,10 @@
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
 
-    bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, db,
+    bool success = conceptsRead(&conceptsCell, fpa, chip, cell, &cell->conceptsRead, source, config,
                                 cell->concepts);
     if (propagateUp) {
-        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, db,
+        success &= conceptsRead(&conceptsChip, fpa, chip, cell, &chip->conceptsRead, source, config,
                                 chip->concepts);
-        success &= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, db,
+        success &= conceptsRead(&conceptsFPA, fpa, chip, cell, &fpa->conceptsRead, source, config,
                                 fpa->concepts);
     }
@@ -442,5 +448,5 @@
 }
 
-bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source, bool propagateUp, psDB *db)
+bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source, bool propagateUp, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -449,10 +455,10 @@
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
 
-    bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
+    bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source, config, cell->concepts);
     if (propagateUp) {
         if (!chip->hdu) {
-            success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source, db, chip->concepts);
+            success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source, config, chip->concepts);
             if (!fpa->hdu) {
-                success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, db, fpa->concepts);
+                success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source, config, fpa->concepts);
             }
         }
Index: trunk/psModules/src/concepts/pmConcepts.h
===================================================================
--- trunk/psModules/src/concepts/pmConcepts.h	(revision 18146)
+++ trunk/psModules/src/concepts/pmConcepts.h	(revision 18163)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-06-05 01:31:33 $
+ * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -11,4 +11,6 @@
 #ifndef PM_CONCEPTS_H
 #define PM_CONCEPTS_H
+
+#include <pmConfig.h>
 
 /// @addtogroup Concepts Data Abstraction Concepts
@@ -105,5 +107,5 @@
                     pmCell *cell,       ///< Cell for which to read concepts, or NULL
                     pmConceptSource source, ///< The source of the concepts to read
-                    psDB *db            ///< Database handle
+                    pmConfig *config    ///< Configuration
                    );
 
@@ -120,5 +122,5 @@
                        pmConceptSource source, ///< Source for concepts
                        bool propagateDown, ///< Propagate to lower levels?
-                       psDB *db         ///< Database handle
+                       pmConfig *config         ///< Configuration
                       );
 
@@ -130,5 +132,5 @@
                         pmConceptSource source, ///< Source for concepts
                         bool propagateDown, ///< Propagate to lower levels?
-                        psDB *db        ///< Database handle
+                        pmConfig *config        ///< Configuration
                        );
 
@@ -146,5 +148,5 @@
                         bool propagateUp, ///< Propagate to higher levels?
                         bool propagateDown, ///< Propagate to lower levels?
-                        psDB *db        ///< Database handle
+                        pmConfig *config        ///< Configuration
                        );
 
@@ -157,5 +159,5 @@
                          bool propagateUp,///< Propagate to higher levels?
                          bool propagateDown, ///< Propagate to lower levels?
-                         psDB *db       ///< Database handle
+                         pmConfig *config       ///< Configuration
                         );
 
@@ -172,5 +174,5 @@
                         pmConceptSource source, ///< Source for concepts
                         bool propagateUp, ///< Propagate to higher levels?
-                        psDB *db        ///< Database handle
+                        pmConfig *config        ///< Configuration
                        );
 
@@ -183,5 +185,5 @@
                          pmConceptSource source, ///< Source for concepts
                          bool propagateUp, ///< Propagate to higher levels?
-                         psDB *db       ///< Database handle
+                         pmConfig *config ///< Configuration
                         );
 
Index: trunk/psModules/src/concepts/pmConceptsRead.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsRead.c	(revision 18146)
+++ trunk/psModules/src/concepts/pmConceptsRead.c	(revision 18163)
@@ -9,4 +9,5 @@
 #include <pslib.h>
 
+#include "pmConfig.h"
 #include "pmHDU.h"
 #include "pmFPA.h"
@@ -363,9 +364,17 @@
 }
 
-psMetadataItem *p_pmConceptsReadSingleFromDatabase(const char *name, const psMetadata *database, psDB *db,
-                                                   const pmFPA *fpa, const pmChip *chip, const pmCell *cell)
+psMetadataItem *p_pmConceptsReadSingleFromDatabase(const char *name, const psMetadata *database,
+                                                   pmConfig *config, const pmFPA *fpa, const pmChip *chip,
+                                                   const pmCell *cell)
 {
     PS_ASSERT_STRING_NON_EMPTY(name, NULL);
-    PS_ASSERT_METADATA_NON_NULL(database, NULL);
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+
+    psDB *db = pmConfigDB(config);      // Database handle
+    if (!db) {
+        psErrorClear();
+        psWarning("Unable to initialise database to write concepts.");
+        return NULL;
+    }
 
     psMetadataItem *item = psMetadataLookup(database, name); // Item to return
@@ -384,5 +393,5 @@
 
     psString sql = pmConceptsInterpolate(item->data.str, fpa, chip, cell);
-    if (!p_psDBRunQuery(db, sql)) {
+    if (!p_psDBRunQuery(config->database, sql)) {
         psWarning("Unable to query database for concept %s --- ignored.", name);
         psFree(sql);
@@ -391,5 +400,5 @@
     psFree(sql);
 
-    psArray *rows = p_psDBFetchResult(db); // Rows returned from the query
+    psArray *rows = p_psDBFetchResult(config->database); // Rows returned from the query
     if (rows->n == 0) {
         psWarning("No rows returned from database query for concept %s --- ignored.", name);
@@ -408,8 +417,9 @@
 
 bool p_pmConceptsReadFromDatabase(psMetadata *target, const psMetadata *specs,
-                                  const pmFPA *fpa, const pmChip *chip, const pmCell *cell, psDB *db)
+                                  const pmFPA *fpa, const pmChip *chip, const pmCell *cell, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(specs, false);
     PS_ASSERT_PTR_NON_NULL(target, false);
+    PS_ASSERT_PTR_NON_NULL(config, false);
 
 #ifndef HAVE_PSDB
@@ -434,5 +444,6 @@
         pmConceptSpec *spec = specItem->data.V; // The specification
         psString name = specItem->name; // The concept name
-        psMetadataItem *conceptItem = p_pmConceptsReadSingleFromDatabase(name, dbSpec, db, fpa, chip, cell);
+        psMetadataItem *conceptItem = p_pmConceptsReadSingleFromDatabase(name, dbSpec, config,
+                                                                         fpa, chip, cell);
         if (conceptItem && !conceptParse(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,
                                          cameraFormat, target, fpa, chip, cell)) {
Index: trunk/psModules/src/concepts/pmConceptsRead.h
===================================================================
--- trunk/psModules/src/concepts/pmConceptsRead.h	(revision 18146)
+++ trunk/psModules/src/concepts/pmConceptsRead.h	(revision 18163)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-06-05 01:31:33 $
+ * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -62,5 +62,5 @@
     const char *name,                   ///< Name of concept
     const psMetadata *database,         ///< DATABASE specification
-    psDB *db,                           ///< Database handle
+    pmConfig *config,                   ///< Configuration
     const pmFPA *fpa,                   ///< The FPA
     const pmChip *chip,                 ///< The chip, or NULL
@@ -72,5 +72,4 @@
 /// Examines the DATABASE metadata in the camera format file
 /// for concepts in the specs, and imports them into the target.
-/// WARNING: This function has not been tested; use at your own risk!
 bool p_pmConceptsReadFromDatabase(psMetadata *target, // Place into which to read the concepts
                                   const psMetadata *specs, // The concept specifications
@@ -78,5 +77,5 @@
                                   const pmChip *chip, // The chip
                                   const pmCell *cell,  // The cell
-                                  psDB *db // The database handle
+                                  pmConfig *config // Configuration
                                  );
 /// @}
Index: trunk/psModules/src/concepts/pmConceptsWrite.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 18146)
+++ trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 18163)
@@ -9,4 +9,5 @@
 #include <pslib.h>
 
+#include "pmConfig.h"
 #include "pmHDU.h"
 #include "pmFPA.h"
@@ -427,12 +428,9 @@
 // XXX Warning: This code has not been tested at all
 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,
-                                 const pmCell *cell, psDB *db, const psMetadata *concepts)
+                                 const pmCell *cell, pmConfig *config, const psMetadata *concepts)
 {
     PS_ASSERT_PTR_NON_NULL(specs, false);
     PS_ASSERT_PTR_NON_NULL(concepts, false);
-
-    if (!db) {
-        return false;
-    }
+    PS_ASSERT_PTR_NON_NULL(config, false);
 
     #ifndef HAVE_PSDB
@@ -456,5 +454,5 @@
         psString name = specItem->name; // The concept name
 
-        psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, db, fpa, chip, cell);
+        psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, config, fpa, chip, cell);
         if (!dbItem) {
             continue;
Index: trunk/psModules/src/concepts/pmConceptsWrite.h
===================================================================
--- trunk/psModules/src/concepts/pmConceptsWrite.h	(revision 18146)
+++ trunk/psModules/src/concepts/pmConceptsWrite.h	(revision 18163)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-03-30 21:12:56 $
+ * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-06-17 22:16:38 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -55,5 +55,5 @@
                                  const pmChip *chip, ///< The chip
                                  const pmCell *cell, ///< The cell
-                                 psDB *db,///< The database handle
+                                 pmConfig *config,///< Configuration
                                  const psMetadata *concepts ///< The concepts
                                 );
Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 18146)
+++ trunk/psModules/src/config/pmConfig.c	(revision 18163)
@@ -1297,4 +1297,8 @@
     #else
 
+    if (config->database) {
+        return config->database;
+    }
+
     psBool mdStatus01 = false;
     psBool mdStatus02 = false;
@@ -1322,5 +1326,6 @@
     }
 
-    return psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort);
+    config->database = psDBInit(dbServer, dbUsername, dbPassword, dbName, dbPort);
+    return config->database;
     #endif
 }
Index: trunk/psModules/src/detrend/pmDark.c
===================================================================
--- trunk/psModules/src/detrend/pmDark.c	(revision 18146)
+++ trunk/psModules/src/detrend/pmDark.c	(revision 18163)
@@ -25,5 +25,5 @@
 // Look up the value of an ordinate in a readout
 static bool ordinateLookup(float *value, // Value of ordinate, to return
-			   bool *inRange, // is value within min : max range?
+                           bool *inRange, // is value within min : max range?
                            const char *name, // Name of ordinate (concept name)
                            bool scale,  // Scale the value?
@@ -70,5 +70,5 @@
         if (*value < min || *value > max) {
             psWarning("Value of concept %s (%f) outside range (%f:%f)", name, *value, min, max);
-	    *inRange = false;
+            *inRange = false;
         }
         *value = 2.0 * (*value - min) / (max - min) - 1.0;
@@ -175,5 +175,5 @@
                 continue;
             }
-	    if (!inRange) {
+            if (!inRange) {
                 roMask->data.U8[j] = 0xff;
                 val->data.F32[i] = NAN;
@@ -282,20 +282,20 @@
                     mask->data.PS_TYPE_MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];
                 }
-	    
-            }
-
-	    // XXX test
-	    if (0 && (i == 377) && (j == 80)) {
-		FILE *f = fopen ("test.dat", "w");	
-		for (int r = 0; r < inputs->n; r++) { 
-		    fprintf (f, "%d %d  %d  ", i, j, mask->data.U8[r]);
-		    psVector *value = values->data[r];
-		    for (int tmpj = 0; tmpj < value->n; tmpj++) {
-			fprintf (f, "%f ", value->data.F32[tmpj]);
-		    }
-		    fprintf (f, "%f\n", pixels->data.F32[r]);
-		}
-		fclose (f);
-	    }
+
+            }
+
+            // XXX test
+            if (0 && (i == 377) && (j == 80)) {
+                FILE *f = fopen ("test.dat", "w");
+                for (int r = 0; r < inputs->n; r++) {
+                    fprintf (f, "%d %d  %d  ", i, j, mask->data.U8[r]);
+                    psVector *value = values->data[r];
+                    for (int tmpj = 0; tmpj < value->n; tmpj++) {
+                        fprintf (f, "%f ", value->data.F32[tmpj]);
+                    }
+                    fprintf (f, "%f\n", pixels->data.F32[r]);
+                }
+                fclose (f);
+            }
 
             if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, maskVal, values, iter, rej)) {
@@ -426,10 +426,10 @@
 }
 
-bool pmFPAWriteDark(pmFPA *fpa, psFits *fits, psDB *db, bool blank, bool recurse)
+bool pmFPAWriteDark(pmFPA *fpa, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    if (!pmFPAWrite(fpa, fits, db, blank, recurse)) {
+    if (!pmFPAWrite(fpa, fits, config, blank, recurse)) {
         psError(PS_ERR_IO, false, "Unable to write FPA dark images");
         return false;
@@ -481,10 +481,10 @@
 }
 
-bool pmChipWriteDark(pmChip *chip, psFits *fits, psDB *db, bool blank, bool recurse)
+bool pmChipWriteDark(pmChip *chip, psFits *fits, pmConfig *config, bool blank, bool recurse)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    if (!pmChipWrite(chip, fits, db, blank, recurse)) {
+    if (!pmChipWrite(chip, fits, config, blank, recurse)) {
         psError(PS_ERR_IO, false, "Unable to write chip dark images");
         return false;
@@ -532,5 +532,5 @@
 }
 
-bool pmCellWriteDark(pmCell *cell, psFits *fits, psDB *db, bool blank)
+bool pmCellWriteDark(pmCell *cell, psFits *fits, pmConfig *config, bool blank)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -538,5 +538,5 @@
 
     // Allow the usual pmFPAWrite functions to handle the heavy lifting for the images
-    if (!pmCellWrite(cell, fits, db, blank)) {
+    if (!pmCellWrite(cell, fits, config, blank)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to write dark cell.");
         return false;
@@ -623,10 +623,10 @@
 
 
-bool pmFPAReadDark(pmFPA *fpa, psFits *fits, psDB *db)
+bool pmFPAReadDark(pmFPA *fpa, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    if (!pmFPARead(fpa, fits, db)) {
+    if (!pmFPARead(fpa, fits, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to read dark FPA.");
         return false;
@@ -658,10 +658,10 @@
 }
 
-bool pmChipReadDark(pmChip *chip, psFits *fits, psDB *db)
+bool pmChipReadDark(pmChip *chip, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_FITS_NON_NULL(fits, false);
 
-    if (!pmChipRead(chip, fits, db)) {
+    if (!pmChipRead(chip, fits, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to read dark chip.");
         return false;
@@ -690,5 +690,5 @@
 
 
-bool pmCellReadDark(pmCell *cell, psFits *fits, psDB *db)
+bool pmCellReadDark(pmCell *cell, psFits *fits, pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -696,5 +696,5 @@
 
     // Allow the usual pmFPARead functions to handle the heavy lifting for the images
-    if (!pmCellRead(cell, fits, db)) {
+    if (!pmCellRead(cell, fits, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to read dark cell.");
         return false;
Index: trunk/psModules/src/detrend/pmDark.h
===================================================================
--- trunk/psModules/src/detrend/pmDark.h	(revision 18146)
+++ trunk/psModules/src/detrend/pmDark.h	(revision 18163)
@@ -5,4 +5,5 @@
 #include <pmHDU.h>
 #include <pmFPA.h>
+#include <pmConfig.h>
 
 #define PM_DARK_ANALYSIS_ORDINATES "DARK.ORDINATES" // Name for dark ordinates in the cell analysis metadata
@@ -45,5 +46,5 @@
 bool pmFPAWriteDark(pmFPA *fpa,         // FPA to write
                     psFits *fits,       // FITS file to which to write
-                    psDB *db,           // Database, for concepts
+                    pmConfig *config,   // Configuration
                     bool blank,         // Write a blank only?
                     bool recurse        // Recurse to lower levels?
@@ -53,5 +54,5 @@
 bool pmChipWriteDark(pmChip *chip,      // Chip to write
                      psFits *fits,      // FITS file to which to write
-                     psDB *db,          // Database, for concepts
+                     pmConfig *config,  // Configuration
                      bool blank,        // Write a blank only?
                      bool recurse       // Recurse to lower levels?
@@ -61,5 +62,5 @@
 bool pmCellWriteDark(pmCell *cell,      // Cell containing dark information
                      psFits *fits,      // FITS file to which to write
-                     psDB *db,          // Database, for concepts
+                     pmConfig *config,  // Configuration
                      bool blank         // Write a blank only?
     );
@@ -68,5 +69,5 @@
 bool pmFPAReadDark(pmFPA *fpa,          // FPA for which to read
                    psFits *fits,        // FITS file to read
-                   psDB *db             // Database, for concepts
+                   pmConfig *config     // Configuration
     );
 
@@ -74,5 +75,5 @@
 bool pmChipReadDark(pmChip *chip,       // Chip for which to read
                     psFits *fits,       // FITS file to read
-                    psDB *db            // Database, for concepts
+                    pmConfig *config    // Configuration
     );
 
@@ -80,5 +81,5 @@
 bool pmCellReadDark(pmCell *cell,       // Cell for which to read
                     psFits *fits,       // FITS file to read
-                    psDB *db            // Database, for concepts
+                    pmConfig *config    // Configuration
     );
 
Index: trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtraction.c	(revision 18146)
+++ trunk/psModules/src/imcombine/pmSubtraction.c	(revision 18163)
@@ -4,6 +4,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.93 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-06-10 02:43:01 $
+ *  @version $Revision: 1.94 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-06-17 22:16:38 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -627,4 +627,30 @@
 }
 
+
+float pmSubtractionVarianceFactor(const pmSubtractionKernels *kernels, float x, float y, bool wantDual)
+{
+    PM_ASSERT_SUBTRACTION_KERNELS_NON_NULL(kernels, NAN);
+    PM_ASSERT_SUBTRACTION_KERNELS_SOLUTION(kernels, NAN);
+    PS_ASSERT_FLOAT_WITHIN_RANGE(x, -1.0, 1.0, NAN);
+    PS_ASSERT_FLOAT_WITHIN_RANGE(y, -1.0, 1.0, NAN);
+
+    // Precalulate polynomial values
+    psImage *polyValues = p_pmSubtractionPolynomial(NULL, kernels->spatialOrder, x, y);
+
+    psKernel *kernel = solvedKernel(NULL, kernels, polyValues, wantDual); // The appropriate kernel
+    psFree(polyValues);
+
+    double sumKernel2 = 0.0;            // Sum of the kernel squared
+    for (int y = kernel->yMin; y <= kernel->yMax; y++) {
+        for (int x = kernel->xMin; x <= kernel->xMax; x++) {
+            sumKernel2 += PS_SQR(kernel->kernel[y][x]);
+        }
+    }
+
+    psFree(kernel);
+
+    return sumKernel2;
+}
+
 #if 0
 psArray *pmSubtractionKernelSolutions(const pmSubtractionKernels *kernels, float x, float y, bool wantDual)
