Index: trunk/ppImage/src/ppImageOptions.c
===================================================================
--- trunk/ppImage/src/ppImageOptions.c	(revision 6396)
+++ trunk/ppImage/src/ppImageOptions.c	(revision 6747)
@@ -1,5 +1,5 @@
 #include <stdio.h>
 #include "pslib.h"
-#include "ppConfig.h"
+#include "ppImage.h"
 #include "ppImageData.h"
 #include "ppImageOptions.h"
@@ -28,5 +28,5 @@
 // XXX EAM : this needs signficant work to choose the detrend images based on the detrend database
 
-bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, ppConfig *config)
+bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, pmConfig *config)
 {
 
@@ -56,5 +56,11 @@
 
     bool mdStatus = false;              // Result of MD lookup
-    const char *depth = psMetadataLookupStr(&mdStatus, config->recipe, "LOAD.DEPTH");
+    psMetadata *recipe = psMetadataLookupMD(&mdStatus, config->recipes, RECIPE_NAME);
+    if (! mdStatus || !recipe) {
+        psLogMsg("ppImage", PS_LOG_ERROR, "Can't find recipe %s in the RECIPES.\n", RECIPE_NAME);
+        exit(EXIT_FAILURE);
+    }
+
+    const char *depth = psMetadataLookupStr(&mdStatus, recipe, "LOAD.DEPTH");
     if (! mdStatus || ! depth || strlen(depth) == 0) {
         psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe.");
@@ -68,10 +74,10 @@
         options->imageLoadDepth = PP_LOAD_CELL;
     } else {
-        psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL.");
+        psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe %s is not FPA, CHIP or CELL.", RECIPE_NAME);
         exit(EXIT_FAILURE);
     }
 
     // Mask recipe options
-    if (psMetadataLookupBool(NULL, config->recipe, "MASK")) {
+    if (psMetadataLookupBool(NULL, recipe, "MASK")) {
         data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
         if (data->mask->filename && strlen(data->mask->filename) > 0) {
@@ -84,9 +90,9 @@
 
     // Non-linearity recipe options
-    if (psMetadataLookupBool(NULL, config->recipe, "NONLIN")) {
-        psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA");
+    if (psMetadataLookupBool(NULL, recipe, "NONLIN")) {
+        psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA");
         if (! dataItem) {
             psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
-                     "find NONLIN.DATA in recipe.");
+                     "find NONLIN.DATA in recipe %s.", RECIPE_NAME);
             exit(EXIT_FAILURE);
         }
@@ -106,8 +112,8 @@
             {
                 bool status;
-                options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE");
+                options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE");
                 if (! status || ! options->nonLinearSource) {
                     psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
-                            "find NONLIN.SOURCE in recipe");
+                            "find NONLIN.SOURCE in recipe %s.", RECIPE_NAME);
                     exit(EXIT_FAILURE);
                 }
@@ -116,5 +122,5 @@
           default:
             psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but "
-                    "NONLIN.DATA is of invalid type.");
+                    "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME);
             exit(EXIT_FAILURE);
         }
@@ -122,22 +128,22 @@
 
     // Bias recipe options
-    if (psMetadataLookupBool(NULL, config->recipe, "BIAS")) {
+    if (psMetadataLookupBool(NULL, recipe, "BIAS")) {
         data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");
         if (data->bias->filename && strlen(data->bias->filename) > 0) {
             options->doBias = true;
         } else {
-            psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- "
-                     "no bias subtraction will be performed.\n");
+            psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired in recipe %s, but no bias was "
+                     "supplied --- no bias subtraction will be performed.\n", RECIPE_NAME);
         }
     }
 
     // Dark recipe options
-    if (psMetadataLookupBool(NULL, config->recipe, "DARK")) {
+    if (psMetadataLookupBool(NULL, recipe, "DARK")) {
         data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");
         if (data->dark->filename && strlen(data->dark->filename) > 0) {
             options->doDark = true;
         } else {
-            psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- "
-                     "no dark subtraction will be performed.\n");
+            psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired in recipe %s, but no dark was "
+                     "supplied --- no dark subtraction will be performed.\n", RECIPE_NAME);
         }
     }
@@ -147,26 +153,26 @@
     // Overscan recipe options
     // XXX EAM : we should abort on invalid options. default options?
-    if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) {
+    if (psMetadataLookupBool(NULL, recipe, "OVERSCAN")) {
         options->doOverscan = true;
 
         // Do the overscan as a single value?
-        overscanSingle = psMetadataLookupBool(NULL, config->recipe, "OVERSCAN.SINGLE");
+        overscanSingle = psMetadataLookupBool(NULL, recipe, "OVERSCAN.SINGLE");
 
         // How do we fit it?
-        psString fit = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.FIT");
+        psString fit = psMetadataLookupStr(NULL, recipe, "OVERSCAN.FIT");
         if (! strcasecmp(fit, "POLYNOMIAL")) {
             overscanFit = PM_FIT_POLY_ORD;
-            overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
+            overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER");
         } else if (! strcasecmp(fit, "CHEBYSHEV")) {
             overscanFit = PM_FIT_POLY_CHEBY;
-            overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
+            overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER");
         } else if (! strcasecmp(fit, "SPLINE")) {
             overscanFit = PM_FIT_SPLINE;
         } else if (strcasecmp(fit, "NONE")) {
-            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
-                     " assuming NONE.\n", fit);
-        }
-
-        psString stat = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.STAT");
+            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) in recipe %s is not one of NONE, "
+                     "POLYNOMIAL, or SPLINE: assuming NONE.\n", fit, RECIPE_NAME);
+        }
+
+        psString stat = psMetadataLookupStr(NULL, recipe, "OVERSCAN.STAT");
         if (! strcasecmp(stat, "MEAN")) {
             overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
@@ -174,5 +180,6 @@
             overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
         } else {
-            psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat);
+            psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) in recipe %s is not one of MEAN, MEDIAN: "
+                              "assuming MEAN\n", stat, RECIPE_NAME);
             overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
         }
@@ -184,11 +191,11 @@
 
     // flat-field - recipe options
-    if (psMetadataLookupBool(NULL, config->recipe, "FLAT")) {
+    if (psMetadataLookupBool(NULL, recipe, "FLAT")) {
         data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat");
         if (strlen(data->flat->filename) > 0) {
             options->doFlat = true;
         } else {
-            psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- "
-                     "no flat-fielding will be performed.\n");
+            psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired in recipe %s, but no flat was "
+                     "supplied --- no flat-fielding will be performed.\n", RECIPE_NAME);
         }
     }
