Index: /branches/rel10_ifa/psModules/src/astrom/pmConcepts.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmConcepts.c	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmConcepts.c	(revision 6580)
@@ -76,5 +76,5 @@
 
 // Set all registered concepts to blank value for the specified level
-static bool conceptsBlank(psMetadata *specs,  // One of the concepts specifications
+static bool conceptsBlank(psMetadata **specs,  // One of the concepts specifications
                           psMetadata *target // Place to install the concepts
                          )
@@ -83,5 +83,5 @@
         pmConceptsInit();
     }
-    psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator on specs
+    psMetadataIterator *specsIter = psMetadataIteratorAlloc(*specs, PS_LIST_HEAD, NULL); // Iterator on specs
     psMetadataItem *specItem = NULL;    // Item from the specs metadata
     while ((specItem = psMetadataGetAndIncrement(specsIter))) {
@@ -99,5 +99,5 @@
 
 // Read all registered concepts for the specified level
-static bool conceptsRead(psMetadata *specs, // One of the concepts specifications
+static bool conceptsRead(psMetadata **specs, // One of the concepts specifications
                          pmFPA *fpa,    // The FPA
                          pmChip *chip,  // The chip
@@ -113,14 +113,14 @@
 
     if (source & PM_CONCEPT_SOURCE_CAMERA || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsReadFromCamera(specs, cell, target);
+        pmConceptsReadFromCamera(*specs, cell, target);
     }
     if (source & PM_CONCEPT_SOURCE_DEFAULTS || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsReadFromDefaults(specs, fpa, chip, cell, target);
+        pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target);
     }
     if (source & PM_CONCEPT_SOURCE_HEADER || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsReadFromHeader(specs, fpa, chip, cell, target);
+        pmConceptsReadFromHeader(*specs, fpa, chip, cell, target);
     }
     if (source & PM_CONCEPT_SOURCE_DATABASE || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsReadFromDatabase(specs, fpa, chip, cell, db, target);
+        pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target);
     }
 
@@ -129,5 +129,5 @@
 
 // Write all registered concepts for the specified level
-static bool conceptsWrite(psMetadata *specs, // One of the concepts specifications
+static bool conceptsWrite(psMetadata **specs, // One of the concepts specifications
                           pmFPA *fpa,   // The FPA
                           pmChip *chip, // The chip
@@ -143,14 +143,14 @@
 
     if (source & PM_CONCEPT_SOURCE_CAMERA || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsWriteToCamera(specs, cell, concepts);
+        pmConceptsWriteToCamera(*specs, cell, concepts);
     }
     if (source & PM_CONCEPT_SOURCE_DEFAULTS || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsWriteToDefaults(specs, fpa, chip, cell, concepts);
+        pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts);
     }
     if (source & PM_CONCEPT_SOURCE_HEADER || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsWriteToHeader(specs, fpa, chip, cell, concepts);
+        pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts);
     }
     if (source & PM_CONCEPT_SOURCE_DATABASE || source == PM_CONCEPT_SOURCE_ALL) {
-        pmConceptsWriteToDatabase(specs, fpa, chip, cell, db, concepts);
+        pmConceptsWriteToDatabase(*specs, fpa, chip, cell, db, concepts);
     }
 
@@ -164,5 +164,5 @@
 {
     psTrace("psModule.concepts", 5, "Blanking FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
-    return conceptsBlank(conceptsFPA, fpa->concepts);
+    return conceptsBlank(&conceptsFPA, fpa->concepts);
 }
 
@@ -174,5 +174,5 @@
 {
     psTrace("psModule.concepts", 5, "Reading FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
-    return conceptsRead(conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
+    return conceptsRead(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
 }
 
@@ -184,5 +184,5 @@
 {
     psTrace("psModule.concepts", 5, "Writing FPA concepts: %x %x\n", conceptsFPA, fpa->concepts);
-    return conceptsWrite(conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
+    return conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source, db, fpa->concepts);
 }
 
@@ -192,5 +192,5 @@
 {
     psTrace("psModule.concepts", 5, "Blanking chip concepts: %x %x\n", conceptsChip, chip->concepts);
-    return conceptsBlank(conceptsChip, chip->concepts);
+    return conceptsBlank(&conceptsChip, chip->concepts);
 }
 
@@ -203,5 +203,5 @@
     psTrace("psModule.concepts", 5, "Reading chip concepts: %x %x\n", conceptsChip, chip->concepts);
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    return conceptsRead(conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
+    return conceptsRead(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
 }
 
@@ -214,5 +214,5 @@
     psTrace("psModule.concepts", 5, "Writing chip concepts: %x %x\n", conceptsChip, chip->concepts);
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    return conceptsWrite(conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
+    return conceptsWrite(&conceptsChip, fpa, chip, NULL, source, db, chip->concepts);
 }
 
@@ -222,5 +222,5 @@
 {
     psTrace("psModule.concepts", 5, "Blanking cell concepts: %x %x\n", conceptsCell, cell->concepts);
-    return conceptsBlank(conceptsCell, cell->concepts);
+    return conceptsBlank(&conceptsCell, cell->concepts);
 }
 
@@ -234,5 +234,5 @@
     pmChip *chip = cell->parent;        // Chip to which the cell belongs
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    return conceptsRead(conceptsCell, fpa, chip, cell, source, db, cell->concepts);
+    return conceptsRead(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
 }
 
@@ -246,5 +246,5 @@
     pmChip *chip = cell->parent;        // Chip to which the cell belongs
     pmFPA *fpa = chip->parent;          // FPA to which the chip belongs
-    return conceptsWrite(conceptsCell, fpa, chip, cell, source, db, cell->concepts);
+    return conceptsWrite(&conceptsCell, fpa, chip, cell, source, db, cell->concepts);
 }
 
Index: /branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c	(revision 6580)
@@ -175,4 +175,5 @@
 }
 
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Public functions
@@ -201,19 +202,12 @@
                 bool mdok = true;       // Status of MD lookup
                 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
-                if (mdok && strlen(source)) {
-                    if (strcasecmp(source, "HEADER") == 0 && conceptItem->type == PS_DATA_STRING) {
-                        value = psMetadataLookup(hdu->header, conceptItem->data.V);
-                    } else if (strcasecmp(source, "VALUE") == 0) {
-                        value = psMemIncrRefCounter(conceptItem);
-                    } else {
-                        psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source,
-                                name);
-                        continue;
-                    }
-                } else {
-                    // Assume it's specified by value
+                if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
                     value = psMemIncrRefCounter(conceptItem);
+                    conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
+                } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) {
+                    // We leave "HEADER" to pmConceptsReadFromHeader
+                    psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source, name);
+                    continue;
                 }
-                conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
             }
         }
@@ -253,4 +247,5 @@
 }
 
+
 bool pmConceptsReadFromHeader(psMetadata *specs, // The concept specifications
                               pmFPA *fpa, // The FPA
@@ -265,6 +260,4 @@
     psMetadata *transSpec = psMetadataLookupMD(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec
     if (mdok && transSpec) {
-        pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
-        psMetadata *cameraFormat = hdu->format; // The camera format
         psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
         psMetadataItem *specItem = NULL;    // Item from the specs metadata
@@ -272,29 +265,45 @@
             pmConceptSpec *spec = specItem->data.V; // The specification
             psString name = specItem->name; // The concept name
-            psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
-            if (mdok && strlen(keywords) > 0) {
-                // In case there are multiple headers
-                psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
-                psMetadataItem *headerItem = NULL; // The item, to be returned
-                if (keys->n == 1) {
-                    // Only one key --- proceed as usual
-                    headerItem = psMetadataLookup(hdu->header, keywords);
-                } else {
-                    psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
-                    psString key = NULL; // Item from iteration
-                    psList *values = psListAlloc(NULL); // List containing the values
-                    while ((key = psListGetAndIncrement(keysIter))) {
-                        psMetadataItem *value = psMetadataLookup(hdu->header, key);
-                        psListAdd(values, PS_LIST_TAIL, value);
+            psMetadataItem *headerItem = NULL; // The value of the concept from the header
+            // First check the cell configuration
+            if (cell && cell->config) {
+                psMetadataItem *conceptItem = psMetadataLookup(cell->config, name); // The concept, or NULL
+                if (conceptItem) {
+                    // Check the SOURCE
+                    psString nameSource = NULL; // String with the concept name and ".SOURCE" added
+                    psStringAppend(&nameSource, "%s.SOURCE", name);
+                    psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
+                    if (mdok && strlen(source) && strcasecmp(source, "HEADER") == 0) {
+                        headerItem = psMetadataLookup(hdu->header, conceptItem->data.V);
                     }
-                    psFree(keysIter);
-                    headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
-                    psFree(values);
+                    // Leave the error handling to pmConceptsFromCamera, which should already have been called
                 }
-                psFree(keys);
-
-                // This will also clean up the name
-                conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
-            }
+            }
+            if (! headerItem) {
+                psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
+                if (mdok && strlen(keywords) > 0) {
+                    // In case there are multiple headers
+                    psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
+                    if (keys->n == 1) {
+                        // Only one key --- proceed as usual
+                        headerItem = psMetadataLookup(hdu->header, keywords);
+                    } else {
+                        psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
+                        psString key = NULL; // Item from iteration
+                        psList *values = psListAlloc(NULL); // List containing the values
+                        while ((key = psListGetAndIncrement(keysIter))) {
+                            psMetadataItem *value = psMetadataLookup(hdu->header, key);
+                            psListAdd(values, PS_LIST_TAIL, value);
+                        }
+                        psFree(keysIter);
+                        headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
+                        psFree(values);
+                    }
+                    psFree(keys);
+                }
+            }
+
+            // This will also clean up the name
+            conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
         }
         psFree(specsIter);
@@ -303,4 +312,5 @@
     return false;
 }
+
 
 // XXX --- the below code has NOT been tested!
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c	(revision 6580)
@@ -147,13 +147,10 @@
         while ((cellName = psListGetAndIncrement(cellNamesIter))) {
             pmCell *cell = pmCellAlloc(chip, cellName); // New cell
-            pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
             psFree(cell);               // Drop reference
         }
-        pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
         psFree(chip);                   // Drop reference
         psFree(cellNamesIter);
     }
     psFree(componentsIter);
-    pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
 
     return fpa;
@@ -166,5 +163,5 @@
                     pmCell *cell,       // Cell to which to add, or NULL
                     psMetadata *phu,    // Primary header of file
-                    const psMetadata *format // Format of file
+                    psMetadata *format // Format of file
                    )
 {
@@ -192,8 +189,11 @@
     pmHDU *phdu = pmHDUAlloc("PHU");    // The primary header data unit
     phdu->header = psMemIncrRefCounter(phu);
+    phdu->format = psMemIncrRefCounter(format);
     if (fpa && !fpa->hdu && strcasecmp(phuType, "FPA") == 0) {
         fpa->hdu = phdu;
+        pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
     } else if (chip && !chip->hdu && strcasecmp(phuType, "CHIP") == 0) {
         chip->hdu = phdu;
+        pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, NULL);
     } else if (cell && !cell->hdu && strcasecmp(phuType, "CELL") == 0) {
         // cell->hdu = phdu;
@@ -244,5 +244,5 @@
             }
             cell->config = psMemIncrRefCounter(cellData);
-            pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
+            pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
         }
     }
@@ -295,5 +295,5 @@
                 }
                 cell->config = psMemIncrRefCounter(cellData);
-                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
+                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
             }
 
@@ -337,5 +337,5 @@
                 }
                 cell->config = psMemIncrRefCounter(cellData);
-                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA, NULL);
+                pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, NULL);
             }
 
@@ -346,4 +346,6 @@
     }
     psFree(contentsIter);
+
+    pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS, NULL);
 
     return true;
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.h
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.h	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.h	(revision 6580)
@@ -14,5 +14,5 @@
                     pmCell *cell,       // Cell to which to add, or NULL
                     psMetadata *phu,    // Primary header of file
-                    const psMetadata *format // Format of file
+                    psMetadata *format  // Format of file
                    );
 
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPAfile.h	(revision 6580)
@@ -7,6 +7,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-03-14 02:21:07 $
+*  @version $Revision: 1.1.2.6 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-03-14 04:40:37 $
 *
 *  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
@@ -15,4 +15,8 @@
 #ifndef PM_FPA_FILE_H
 #define PM_FPA_FILE_H
+
+#include "pslib.h"
+#include "pmFPA.h"
+#include "pmFPAview.h"
 
 typedef enum {
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPAview.h
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPAview.h	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPAview.h	(revision 6580)
@@ -7,6 +7,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-03-14 02:21:07 $
+*  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-03-14 04:40:37 $
 *
 *  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
@@ -15,4 +15,6 @@
 #ifndef PM_FPA_VIEW_H
 #define PM_FPA_VIEW_H
+
+#include "pmFPA.h"
 
 /// @addtogroup AstroImage
Index: /branches/rel10_ifa/psModules/src/config/pmConfig.c
===================================================================
--- /branches/rel10_ifa/psModules/src/config/pmConfig.c	(revision 6579)
+++ /branches/rel10_ifa/psModules/src/config/pmConfig.c	(revision 6580)
@@ -3,6 +3,6 @@
  *  @author PAP, IfA
  *
- *  @version $Revision: 1.7.4.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-03-10 02:05:06 $
+ *  @version $Revision: 1.7.4.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-03-14 04:40:37 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -477,4 +477,8 @@
     PS_ASSERT_PTR_NON_NULL(config->camera, false);
 
+    if (!config->recipes) {
+        config->recipes = psMetadataAlloc();
+    }
+
     bool mdok = true;                   // Status of MD lookup
     psMetadata *recipes = psMetadataLookupMD(&mdok, config->camera, "RECIPES"); // The list of recipes
