Changeset 5976 for trunk/ppImage/src/ppImageOptions.c
- Timestamp:
- Jan 13, 2006, 5:14:07 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageOptions.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageOptions.c
r5858 r5976 1 # include "ppImage.h"1 #include "ppImage.h" 2 2 3 3 // XXX EAM : this needs signficant work to choose the detrend images based on the detrend database 4 4 5 bool ppImageOptions (ppData *data, ppOptions *options, ppConfig *config) { 5 bool ppImageOptions(ppData *data, ppOptions *options, ppConfig *config) 6 { 6 7 7 bool status; 8 9 // default initial values 10 options->doMask = false; // Mask bad pixels 11 options->doNonLin = false; // Non-linearity correction 12 options->doBias = false; // Bias subtraction 13 options->doDark = false; // Dark subtraction 14 options->doOverscan = false; // Overscan subtraction 15 options->doFlat = false; // Flat-field normalisation 16 options->doFringe = false; // Fringe subtraction 17 options->doSource = false; // Source identification and photometry 18 options->doAstrom = false; // Astrometry 19 options->overscanBins = 1; // Number of pixels per bin for overscan 8 // Flags for various activities 9 options->doMask = false; // Mask bad pixels 10 options->doNonLin = false; // Non-linearity correction 11 options->doBias = false; // Bias subtraction 12 options->doDark = false; // Dark subtraction 13 options->doOverscan = false; // Overscan subtraction 14 options->doFlat = false; // Flat-field normalisation 15 options->doFringe = false; // Fringe subtraction 16 options->doSource = false; // Source identification and photometry 17 options->doAstrom = false; // Astrometry 18 // Overscan options 19 options->overscanBins = 1; // Number of pixels per bin for overscan 20 20 options->overscanStats = NULL; // Statistics for overscan 21 options->overscanFit = NULL; // Overscan fit (polynomial or spline)21 options->overscanFit = NULL; // Overscan fit (polynomial or spline) 22 22 options->overscanFitType = PM_FIT_NONE; // Fit type for overscan 23 23 options->overscanMode = PM_OVERSCAN_NONE; // Axis for overscan 24 // Non-linearity options 25 options->nonLinearType = 0; // Type of non-linearity data (vector, string or metadata) 26 options->nonLinearData = NULL; // The non-linearity data 27 options->nonLinearSource = NULL; // If the non-linearity data is a menu, this provides the key 28 // Various others 29 options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet 24 30 25 options->doNonLin = false; 26 options->nonLinearType = false; 27 options->nonLinearData = NULL; 28 options->nonLinearSource = NULL; 29 30 options->imageLoadDepth = PP_LOAD_NONE; 31 char *depth = psMetadataLookupPtr(NULL, config->recipe, "LOAD.DEPTH"); 32 if (depth == NULL) { 33 psAbort ("phase2", "load depth not specified"); 31 bool mdStatus = false; // Result of MD lookup 32 const char *depth = psMetadataLookupStr(&mdStatus, config->recipe, "LOAD.DEPTH"); 33 if (! mdStatus || ! depth || strlen(depth) == 0) { 34 psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe."); 35 exit(EXIT_FAILURE); 34 36 } 35 37 if (!strcasecmp(depth, "FPA")) { 36 options->imageLoadDepth = PP_LOAD_FPA; 37 } 38 if (!strcasecmp(depth, "CHIP")) { 39 options->imageLoadDepth = PP_LOAD_CHIP; 40 } 41 if (!strcasecmp(depth, "CELL")) { 42 options->imageLoadDepth = PP_LOAD_CELL; 43 } 44 if (options->imageLoadDepth == PP_LOAD_NONE) { 45 psAbort ("phase2", "load depth not specified"); 38 options->imageLoadDepth = PP_LOAD_FPA; 39 } else if (!strcasecmp(depth, "CHIP")) { 40 options->imageLoadDepth = PP_LOAD_CHIP; 41 } else if (!strcasecmp(depth, "CELL")) { 42 options->imageLoadDepth = PP_LOAD_CELL; 43 } else { 44 psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL."); 45 exit(EXIT_FAILURE); 46 46 } 47 47 48 // mask -recipe options48 // Mask recipe options 49 49 if (psMetadataLookupBool(NULL, config->recipe, "MASK")) { 50 data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");51 if ( strlen(data->mask->filename) > 0) {50 data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask"); 51 if (data->mask->filename && strlen(data->mask->filename) > 0) { 52 52 options->doMask = true; 53 53 } else { 54 psLogMsg( "phase2", PS_LOG_WARN, "Masking is desired, but no mask was supplied"55 " --- no masking will be performed.\n");54 psLogMsg(__func__, PS_LOG_WARN, "Masking is desired, but no mask was supplied" 55 " --- no masking will be performed.\n"); 56 56 } 57 57 } 58 58 59 // non-linear -recipe options59 // Non-linearity recipe options 60 60 if (psMetadataLookupBool(NULL, config->recipe, "NONLIN")) { 61 psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA"); 62 if (! dataItem) { 63 psAbort("phase2", "Non-linearity correction desired, but unable to " 64 "find NONLIN.DATA in recipe"); 65 } 61 psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA"); 62 if (! dataItem) { 63 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 64 "find NONLIN.DATA in recipe."); 65 exit(EXIT_FAILURE); 66 } 66 67 67 68 options->doNonLin = true; 68 options->nonLinearType = dataItem->type;69 options->nonLinearData = dataItem;69 options->nonLinearType = dataItem->type; 70 options->nonLinearData = dataItem; 70 71 71 switch (dataItem->type) { 72 case PS_DATA_VECTOR: 73 case PS_DATA_STRING: 74 break; 72 switch (dataItem->type) { 73 // No immediate action required 74 case PS_DATA_VECTOR: 75 case PS_DATA_STRING: 76 break; 75 77 76 case PS_DATA_METADATA: 77 // This is a menu 78 options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE"); 79 if (! status || ! options->nonLinearSource) { 80 psAbort("phase2", "Non-linearity correction desired, but unable to " 81 "find NONLIN.SOURCE in recipe"); 82 } 83 break; 84 85 default: 86 psAbort("phase2", "Non-linearity correction desired, but " 87 "NONLIN.DATA is of invalid type."); 88 } 89 78 // This is a menu; we need the key 79 case PS_DATA_METADATA: 80 { 81 bool status; 82 options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE"); 83 if (! status || ! options->nonLinearSource) { 84 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 85 "find NONLIN.SOURCE in recipe"); 86 exit(EXIT_FAILURE); 87 } 88 } 89 break; 90 default: 91 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but " 92 "NONLIN.DATA is of invalid type."); 93 exit(EXIT_FAILURE); 94 } 90 95 } 91 96 92 // bias -recipe options97 // Bias recipe options 93 98 if (psMetadataLookupBool(NULL, config->recipe, "BIAS")) { 94 data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");95 if ( strlen(data->bias->filename) > 0) {99 data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias"); 100 if (data->bias->filename && strlen(data->bias->filename) > 0) { 96 101 options->doBias = true; 97 102 } else { 98 psLogMsg( "phase2", PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- "103 psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- " 99 104 "no bias subtraction will be performed.\n"); 100 105 } 101 106 } 102 107 103 // dark -recipe options108 // Dark recipe options 104 109 if (psMetadataLookupBool(NULL, config->recipe, "DARK")) { 105 data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");106 if ( strlen(data->dark->filename) > 0) {110 data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark"); 111 if (data->dark->filename && strlen(data->dark->filename) > 0) { 107 112 options->doDark = true; 108 113 } else { 109 psLogMsg( "phase2", PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- "114 psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- " 110 115 "no dark subtraction will be performed.\n"); 111 116 } 112 117 } 113 118 114 // overscan - recipe options 119 // XXX PAP: The overscan stuff needs to be updated following the reworked API 120 121 // Overscan recipe options 115 122 // XXX EAM : we should abort on invalid options. default options? 116 123 if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) { 117 // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false?124 // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false? 118 125 options->doOverscan = true; 119 126 psString mode = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.MODE"); … … 123 130 options->overscanMode = PM_OVERSCAN_ALL; 124 131 } else if (strcasecmp(mode, "NONE")) { 125 psLogMsg( "phase2", PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:"132 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:" 126 133 " assuming NONE.\n", mode); 127 134 } … … 135 142 options->overscanFitType = PM_FIT_SPLINE; 136 143 // int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit 137 // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc();144 // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc(); 138 145 } else if (strcasecmp(fit, "NONE")) { 139 psLogMsg( "phase2", PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"146 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:" 140 147 " assuming NONE.\n", fit); 141 148 } … … 158 165 // flat-field - recipe options 159 166 if (psMetadataLookupBool(NULL, config->recipe, "FLAT")) { 160 data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat");167 data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat"); 161 168 if (strlen(data->flat->filename) > 0) { 162 169 options->doFlat = true; 163 170 } else { 164 psLogMsg( "phase2", PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- "171 psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- " 165 172 "no flat-fielding will be performed.\n"); 166 173 }
Note:
See TracChangeset
for help on using the changeset viewer.
