Index: trunk/ppImage/src/ppImageOptions.c
===================================================================
--- trunk/ppImage/src/ppImageOptions.c	(revision 6747)
+++ trunk/ppImage/src/ppImageOptions.c	(revision 6817)
@@ -1,7 +1,3 @@
-#include <stdio.h>
-#include "pslib.h"
 #include "ppImage.h"
-#include "ppImageData.h"
-#include "ppImageOptions.h"
 
 static void imageOptionsFree(ppImageOptions *options)
@@ -25,34 +21,33 @@
 }
 
-
-// XXX EAM : this needs signficant work to choose the detrend images based on the detrend database
-
-bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, pmConfig *config)
+ppImageOptions *ppImageOptionsParse(pmConfig *config)
 {
 
-    // Flags for various activities
-    options->doMask = false;            // Mask bad pixels
-    options->doNonLin = false;          // Non-linearity correction
-    options->doBias = false;            // Bias subtraction
-    options->doDark = false;            // Dark subtraction
+    ppImageOptions *options = ppImageOptionsAlloc ();
+
+    // default flags for various activities
+    options->doMask   	= false;	// Mask bad pixels
+    options->doNonLin 	= false;	// Non-linearity correction
+    options->doBias   	= false;	// Bias subtraction
+    options->doDark     = false;	// Dark subtraction
     options->doOverscan = false;        // Overscan subtraction
-    options->doFlat = false;            // Flat-field normalisation
-    options->doFringe = false;          // Fringe subtraction
-    options->doSource = false;          // Source identification and photometry
-    options->doAstrom = false;          // Astrometry
-    // Overscan options
-    options->overscan = NULL;           // Overscan options
-    bool overscanSingle = false;        // A single value for entire overscan?
-    pmFit overscanFit = PM_FIT_NONE;    // Fit type for overscan
-    int overscanOrder = 0;              // Order for overscan fit
+    options->doFlat   	= false;	// Flat-field normalisation
+    options->doFringe 	= false;	// Fringe subtraction
+    options->doSource 	= false;	// Source identification and photometry
+    options->doAstrom 	= false;	// Astrometry
+
+    // Overscan defaults
+    options->overscan      = NULL;	// Overscan options
+    bool overscanSingle    = false;	// A single value for entire overscan?
+    pmFit overscanFit      = PM_FIT_NONE; // Fit type for overscan
+    int overscanOrder      = 0;		// Order for overscan fit
     psStats *overscanStats = NULL;      // Statistics for overscan
-    // Non-linearity options
-    options->nonLinearType = 0;         // Type of non-linearity data (vector, string or metadata)
-    options->nonLinearData = NULL;      // The non-linearity data
+
+    // Non-linearity default options
+    options->nonLinearType   = 0;       // Type of non-linearity data (vector, string or metadata)
+    options->nonLinearData   = NULL;	// The non-linearity data
     options->nonLinearSource = NULL;    // If the non-linearity data is a menu, this provides the key
-    // Various others
-    options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet
 
-
+    // select the recipe for this analysis
     bool mdStatus = false;              // Result of MD lookup
     psMetadata *recipe = psMetadataLookupMD(&mdStatus, config->recipes, RECIPE_NAME);
@@ -60,31 +55,4 @@
         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.");
-        exit(EXIT_FAILURE);
-    }
-    if (!strcasecmp(depth, "FPA")) {
-        options->imageLoadDepth = PP_LOAD_FPA;
-    } else if (!strcasecmp(depth, "CHIP")) {
-        options->imageLoadDepth = PP_LOAD_CHIP;
-    } else if (!strcasecmp(depth, "CELL")) {
-        options->imageLoadDepth = PP_LOAD_CELL;
-    } else {
-        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, recipe, "MASK")) {
-        data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
-        if (data->mask->filename && strlen(data->mask->filename) > 0) {
-            options->doMask = true;
-        } else {
-            psLogMsg(__func__, PS_LOG_WARN, "Masking is desired, but no mask was supplied"
-                     " --- no masking will be performed.\n");
-        }
     }
 
@@ -124,26 +92,4 @@
                     "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME);
             exit(EXIT_FAILURE);
-        }
-    }
-
-    // Bias recipe options
-    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 in recipe %s, but no bias was "
-                     "supplied --- no bias subtraction will be performed.\n", RECIPE_NAME);
-        }
-    }
-
-    // Dark recipe options
-    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 in recipe %s, but no dark was "
-                     "supplied --- no dark subtraction will be performed.\n", RECIPE_NAME);
         }
     }
@@ -190,23 +136,24 @@
     }
 
-    // flat-field - recipe options
-    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 in recipe %s, but no flat was "
-                     "supplied --- no flat-fielding will be performed.\n", RECIPE_NAME);
-        }
+    // Mask recipe options
+    if (psMetadataLookupBool(NULL, recipe, "MASK")) {
+	options->doMask = true;
     }
 
-    // XXX need to add the following:
+    // Bias recipe options
+    if (psMetadataLookupBool(NULL, recipe, "BIAS")) {
+	options->doBias = true;
+    }
 
-    // fringe - recipe options
+    // Dark recipe options
+    if (psMetadataLookupBool(NULL, recipe, "DARK")) {
+	options->doDark = true;
+    }
 
-    // photom - recipe options
+    // Flat recipe options
+    if (psMetadataLookupBool(NULL, recipe, "FLAT")) {
+	options->doFlat = true;
+    }
 
-    // astrom - recipe options
-
-    return true;
+    return options;
 }
