Index: /trunk/ppStats/src/Makefile.am
===================================================================
--- /trunk/ppStats/src/Makefile.am	(revision 13998)
+++ /trunk/ppStats/src/Makefile.am	(revision 13999)
@@ -17,4 +17,6 @@
 	ppStatsFringe.c			\
 	ppStatsLoop.c			\
+	ppStatsPixels.c			\
+	ppStatsMetadata.c		\
 	ppStatsSetupFromRecipe.c	\
 	ppStatsSetupFromArgs.c          \
Index: /trunk/ppStats/src/ppStats.config
===================================================================
--- /trunk/ppStats/src/ppStats.config	(revision 13998)
+++ /trunk/ppStats/src/ppStats.config	(revision 13999)
@@ -2,9 +2,14 @@
 
 MULTI	HEADERS		# May specify multiple HEADERS
-HEADERS		STR	HEADER1,HEADER2			# Read these headers
-HEADERS		STR	HEADER3				# Read these headers too
+HEADER		STR	HEADER1,HEADER2			# Read these headers
+HEADER		STR	HEADER3				# Read these headers too
+
 MULTI	STATS		# May specify multiple STATS
-STATS		STR	SAMPLE_MEAN,SAMPLE_STDEV	# Calculate these statistics
-STATS		STR	ROBUST_MEDIAN			# Calculate these statistics too
+STAT		STR	SAMPLE_MEAN,SAMPLE_STDEV	# Calculate these statistics
+STAT		STR	ROBUST_MEDIAN			# Calculate these statistics too
+
+MULTI   ANALYSIS        # metadata blocks to search in chip/cell/readout->analysis
+ANALYSIS        STR     PSPHOT.HEADER
+ANALYSIS        STR     PSASTRO.HEADER
 
 SAMPLE		F32	0.1				# Fraction of cell to sample
Index: /trunk/ppStats/src/ppStats.h
===================================================================
--- /trunk/ppStats/src/ppStats.h	(revision 13998)
+++ /trunk/ppStats/src/ppStats.h	(revision 13999)
@@ -11,9 +11,10 @@
     pmFPAview *view;                    // View to analyse
     // Stuff to output
-    psStats *stats;                     // Statistics to calculate
-    bool doStats;                       // Do statistics?
+    psStats *stats;                     // pixel Statistics to calculate
+    bool doStats;                       // Do pixel statistics?
     bool fileLevel;                     // Output file level?
     psList *headers;                    // Headers to read
     psList *concepts;                   // Concepts to read
+    psList *analysis;                   // Analysis entries to read
     psList *summary;                    // Summary statistics to calculate
     // Options for input data
@@ -35,4 +36,19 @@
     );
 
+psExit ppStatsChip(psMetadata *fpaResults, // Metadata holding the fpa results
+		   pmChip *chip,     // Chip for which to get statistics
+		   psFits *fits,     // FITS file handle
+		   pmFPAview *view,  // View for analysis
+		   ppStatsData *data,// The data
+		   const pmConfig *config // Configuration
+    );
+
+psExit ppStatsCell(psMetadata *chipResults, // Metadata holding the chip results
+		   pmCell *cell,     // Cell for which to get statistics
+		   psFits *fits,     // FITS file handle
+		   ppStatsData *data,// The data
+		   const pmConfig *config // Configuration
+    );
+
 /// Supplement the statistics with the fringe solution
 bool ppStatsFringe(psMetadata *stats,     ///< Statistics metadata to supplement
@@ -42,4 +58,20 @@
     );
 
+
+// measure only the pixel-related statistics (stats, summary)
+psMetadata *ppStatsPixels(psMetadata *out,
+			  pmFPA *fpa,         // FPA for which to get statistics
+			  pmFPAview *view,    // View for analysis
+			  psMaskType maskVal, // Value to mask
+			  pmConfig *config    // Configuration
+    );
+
+// measure only the non-pixel-related statistics (headers, concepts)
+psMetadata *ppStatsMetadata(psMetadata *out,
+			    pmFPA *fpa,         // FPA for which to get statistics
+			    pmFPAview *view,    // View for analysis
+			    psMaskType maskVal, // Value to mask
+			    pmConfig *config    // Configuration
+    );
 
 /// Loop over the input image and do all the hard work
Index: /trunk/ppStats/src/ppStatsData.c
===================================================================
--- /trunk/ppStats/src/ppStatsData.c	(revision 13998)
+++ /trunk/ppStats/src/ppStatsData.c	(revision 13999)
@@ -12,4 +12,5 @@
     psFree(data->headers);
     psFree(data->concepts);
+    psFree(data->analysis);
     psFree(data->summary);
 
@@ -34,4 +35,5 @@
     data->headers = psListAlloc(NULL);
     data->concepts = psListAlloc(NULL);
+    data->analysis = psListAlloc(NULL);
     data->summary = psListAlloc(NULL);
     data->stats = psStatsAlloc(0);
Index: /trunk/ppStats/src/ppStatsLoop.c
===================================================================
--- /trunk/ppStats/src/ppStatsLoop.c	(revision 13998)
+++ /trunk/ppStats/src/ppStatsLoop.c	(revision 13999)
@@ -1,3 +1,3 @@
-#include "ppStatsInternal.h"
+# include "ppStatsInternal.h"
 
 static void getMetadata(psMetadata *target, // Target for metadata
@@ -12,4 +12,24 @@
         if (item) {
             psMetadataAddItem(target, item, PS_LIST_TAIL, 0);
+        }
+    }
+    psFree(iterator);
+    return;
+}
+
+static void getAnalysis(psMetadata *target, // Output Target for metadata
+                        psList *headers,    // List containing desired keywords
+                        psMetadata *source, // Input Source for metadata
+                        psList *list        // List containing analysis blocks
+    )
+{
+    bool status;
+
+    psListIterator *iterator = psListIteratorAlloc(list, PS_LIST_HEAD, false); // Iterator
+    psString name;                      // Name from iteration
+    while ((name = psListGetAndIncrement(iterator))) {
+        psMetadata *folder = psMetadataLookupMetadata(&status, source, name); // Item of interest, or NULL
+        if (folder) {
+            getMetadata (target, folder, headers); 
         }
     }
@@ -55,9 +75,9 @@
 
 
-static psExit cellStats(psMetadata *chipResults, // Metadata holding the chip results
-                        pmCell *cell,     // Cell for which to get statistics
-                        psFits *fits,     // FITS file handle
-                        ppStatsData *data,// The data
-                        const pmConfig *config // Configuration
+psExit ppStatsCell(psMetadata *chipResults, // Metadata holding the chip results
+		   pmCell *cell,	// Cell for which to get statistics
+		   psFits *fits,	// FITS file handle
+		   ppStatsData *data,	// The data
+		   const pmConfig *config // Configuration
     )
 {
@@ -73,4 +93,6 @@
         return PS_EXIT_SUCCESS;
     }
+
+    // select the header unit for this cell
     pmHDU *hdu = pmHDUFromCell(cell); // HDU for cell
     if (!hdu || hdu->blankPHU) {
@@ -84,5 +106,21 @@
     }
 
-    // Cell-level results
+    /*** psphot and psastro put their results on the readout->analysis metadata (PSPHOT.HEADER,
+	 PSASTRO.HEADER).  we need to pull quantities of interest from those locations. to do
+	 this, we need to select the appropriate readout.  ***/
+
+    // Select the readout
+    psArray *readouts = cell->readouts; // Array of component readouts
+    if (readouts->n == 0) {
+        psLogMsg(__func__, PS_LOG_WARN, "No readouts present in cell %s --- skipping\n", cellName);
+        goto cellDone;
+    }
+    if (readouts->n > 1) {
+        psLogMsg(__func__, PS_LOG_WARN, "Multiple readouts (%ld) present in cell %s --- "
+                 "using only the first.\n", readouts->n, cellName);
+    }
+    pmReadout *readout = readouts->data[0]; // The readout of interest
+
+    // Extract Header and Concept values from the Cell and Readout->analysis level
     bool mdok;                          // Status of MD lookup
     psMetadata *cellResults = psMemIncrRefCounter(psMetadataLookupMetadata(&mdok, chipResults, cellName));
@@ -91,4 +129,5 @@
     }
 
+    // Extract Header values
     if (psListLength(data->headers) > 0 && cell->hdu) {
         if (fits && !pmCellReadHeader(cell, fits)) {
@@ -99,5 +138,12 @@
         pmHDU *hdu = cell->hdu;     // HDU for headers
         getMetadata(cellResults, hdu->header, data->headers);
-    }
+
+	// search in the readout->analysis metadata blocks listed in data->analysis
+	if (psListLength(data->analysis) > 0) {
+	    getAnalysis (cellResults, data->headers, readout->analysis, data->analysis);
+	}
+    }
+
+    // Extract Concept values
     if (psListLength(data->concepts) > 0) {
         if (fits && cell->hdu && !pmCellReadHeader(cell, fits)) {
@@ -110,4 +156,5 @@
     }
 
+    // Do we want to measure pixel statistics?
     if (!data->doStats && psListLength(data->summary)) {
         // Nothing further to do --- don't want to waste our time reading the data
@@ -115,4 +162,5 @@
     }
 
+    // Read the image pixel data
     if (fits && !pmCellRead(cell, fits, config->database)) {
         psError (PS_ERR_IO, false, "trouble reading cell data\n");
@@ -121,14 +169,4 @@
     }
 
-    psArray *readouts = cell->readouts; // Array of component readouts
-    if (readouts->n == 0) {
-        psLogMsg(__func__, PS_LOG_WARN, "No readouts present in cell %s --- skipping\n", cellName);
-        goto cellDone;
-    }
-    if (readouts->n > 1) {
-        psLogMsg(__func__, PS_LOG_WARN, "Multiple readouts (%ld) present in cell %s --- "
-                 "using only the first.\n", readouts->n, cellName);
-    }
-    pmReadout *readout = readouts->data[0]; // The readout of interest
     if (!readout->image) {
         psLogMsg(__func__, PS_LOG_WARN, "No image associated with readout in cell %s --- ignored.\n", cellName);
@@ -243,10 +281,10 @@
 }
 
-static psExit chipStats(psMetadata *fpaResults, // Metadata holding the fpa results
-                        pmChip *chip,     // Chip for which to get statistics
-                        psFits *fits,     // FITS file handle
-                        pmFPAview *view,  // View for analysis
-                        ppStatsData *data,// The data
-                        const pmConfig *config // Configuration
+psExit ppStatsChip(psMetadata *fpaResults, // Metadata holding the fpa results
+		   pmChip *chip,     // Chip for which to get statistics
+		   psFits *fits,     // FITS file handle
+		   pmFPAview *view,  // View for analysis
+		   ppStatsData *data,// The data
+		   const pmConfig *config // Configuration
     )
 {
@@ -301,5 +339,5 @@
     if (view->cell >= 0) {
         pmCell *cell = cells->data[view->cell]; // Cell of interest
-        result = cellStats(chipResults, cell, fits, data, config);
+        result = ppStatsCell(chipResults, cell, fits, data, config);
         if (result != PS_EXIT_SUCCESS) {
             psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", view->cell);
@@ -316,5 +354,5 @@
     for (int i = 0; i < cells->n; i++) {
         pmCell *cell = cells->data[i];  // Cell of interest
-        result = cellStats(chipResults, cell, fits, data, config);
+        result = ppStatsCell(chipResults, cell, fits, data, config);
         if (result != PS_EXIT_SUCCESS) {
             psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", i);
@@ -380,5 +418,5 @@
     if (view->chip >= 0) {
         pmChip *chip = chips->data[view->chip]; // Chip of interest
-        *result = chipStats(newResults, chip, fits, view, data, config);
+        *result = ppStatsChip(newResults, chip, fits, view, data, config);
         if (*result != PS_EXIT_SUCCESS) {
             psError(PS_ERR_UNKNOWN, false, "trouble with stats for cell %d\n", view->cell);
@@ -394,8 +432,8 @@
     }
 
-    // Iterate over cells
+    // Iterate over chips
     for (int i = 0; i < chips->n; i++) {
         pmChip *chip = chips->data[i];  // Chip of interest
-        *result = chipStats(newResults, chip, fits, view, data, config);
+        *result = ppStatsChip(newResults, chip, fits, view, data, config);
         if (*result != PS_EXIT_SUCCESS) {
             psError(PS_ERR_UNKNOWN, false, "trouble with stats for chip %d\n", i);
Index: /trunk/ppStats/src/ppStatsMetadata.c
===================================================================
--- /trunk/ppStats/src/ppStatsMetadata.c	(revision 13999)
+++ /trunk/ppStats/src/ppStatsMetadata.c	(revision 13999)
@@ -0,0 +1,65 @@
+#include "ppStatsInternal.h"
+
+// measure only the non-pixel-related statistics (headers, concepts)
+psMetadata *ppStatsMetadata(psMetadata *out,
+			    pmFPA *fpa,         // FPA for which to get statistics
+			    pmFPAview *view,    // View for analysis
+			    psMaskType maskVal, // Value to mask
+			    pmConfig *config    // Configuration
+    )
+{
+    PS_ASSERT_PTR_NON_NULL(fpa, NULL)
+    PS_ASSERT_PTR_NON_NULL(view, NULL);
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+
+    ppStatsData *data = ppStatsDataAlloc(); // All the input data
+
+    // Get the options, open the files
+    if (!ppStatsSetupFromRecipe(data, config)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to get ppStats options from recipe.");
+        psFree(data);
+        return NULL;
+    }
+
+    // drop the 'concept' and 'header' elements of data:
+    psFree (data->summary);    
+    psFree (data->stats);
+    data->summary = psListAlloc(NULL);
+    data->stats = psStatsAlloc(0);
+    data->doStats = false;
+
+    // Override recipe mask value if one is provided
+    if (maskVal != 0) {
+        data->maskVal = maskVal;
+    }
+
+    if (data->fpa) {
+        psFree(data->fpa);
+    }
+    data->fpa = psMemIncrRefCounter(fpa);
+
+    if (data->view) {
+        psFree(data->view);
+    }
+    data->view = psMemIncrRefCounter(view);
+
+    // Go through the FPA and do the hard work
+    psExit status;                      // Status of statistics loop
+    psMetadata *result = ppStatsLoop(&status, data, config);
+    if (status != PS_EXIT_SUCCESS) {
+        psError (PS_ERR_UNKNOWN, false, "Not able to measure FPA statistics.\n");
+        psFree(result);
+        psFree(data);
+        return (NULL);
+    }
+
+    if (out != NULL) {
+	psMetadataCopy (out, result);
+	psFree(result);
+	psFree(data);
+	return out;
+    }
+
+    psFree(data);
+    return result;
+}
Index: /trunk/ppStats/src/ppStatsPixels.c
===================================================================
--- /trunk/ppStats/src/ppStatsPixels.c	(revision 13999)
+++ /trunk/ppStats/src/ppStatsPixels.c	(revision 13999)
@@ -0,0 +1,64 @@
+#include "ppStatsInternal.h"
+
+// measure only the pixel-related statistics (stats, summary)
+psMetadata *ppStatsPixels(psMetadata *out,
+			  pmFPA *fpa,         // FPA for which to get statistics
+			  pmFPAview *view,    // View for analysis
+			  psMaskType maskVal, // Value to mask
+			  pmConfig *config    // Configuration
+    )
+{
+    PS_ASSERT_PTR_NON_NULL(fpa, NULL)
+    PS_ASSERT_PTR_NON_NULL(view, NULL);
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+
+    ppStatsData *data = ppStatsDataAlloc(); // All the input data
+
+    // Get the options, open the files
+    if (!ppStatsSetupFromRecipe(data, config)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to get ppStats options from recipe.");
+        psFree(data);
+        return NULL;
+    }
+
+    // drop the 'concept' and 'header' elements of data:
+    psFree (data->headers);    
+    psFree (data->concepts);
+    data->headers = psListAlloc(NULL);
+    data->concepts = psListAlloc(NULL);
+
+    // Override recipe mask value if one is provided
+    if (maskVal != 0) {
+        data->maskVal = maskVal;
+    }
+
+    if (data->fpa) {
+        psFree(data->fpa);
+    }
+    data->fpa = psMemIncrRefCounter(fpa);
+
+    if (data->view) {
+        psFree(data->view);
+    }
+    data->view = psMemIncrRefCounter(view);
+
+    // Go through the FPA and do the hard work
+    psExit status;                      // Status of statistics loop
+    psMetadata *result = ppStatsLoop(&status, data, config);
+    if (status != PS_EXIT_SUCCESS) {
+        psError (PS_ERR_UNKNOWN, false, "Not able to measure FPA statistics.\n");
+        psFree(result);
+        psFree(data);
+        return (NULL);
+    }
+
+    if (out != NULL) {
+	psMetadataCopy (out, result);
+	psFree(result);
+	psFree(data);
+	return out;
+    }
+
+    psFree(data);
+    return result;
+}
Index: /trunk/ppStats/src/ppStatsSetupFromRecipe.c
===================================================================
--- /trunk/ppStats/src/ppStatsSetupFromRecipe.c	(revision 13998)
+++ /trunk/ppStats/src/ppStatsSetupFromRecipe.c	(revision 13999)
@@ -73,4 +73,5 @@
     listFromRecipe(data->headers,  recipe, "HEADER");
     listFromRecipe(data->concepts, recipe, "CONCEPT");
+    listFromRecipe(data->analysis, recipe, "ANALYSIS");
 
     // Parse SUMMARY statistics information
