Changeset 29679
- Timestamp:
- Nov 5, 2010, 9:22:59 AM (16 years ago)
- Location:
- branches/czw_branch/20100817/ppImage/src
- Files:
-
- 3 edited
-
ppImageArguments.c (modified) (2 diffs)
-
ppImageDetrendNonLinear.c (modified) (2 diffs)
-
ppImageOptions.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100817/ppImage/src/ppImageArguments.c
r24485 r29679 24 24 fprintf(stderr, "\t-mask/-masklist: Mask image.\n"); 25 25 fprintf(stderr, "\t-fringe/-fringelist: Fringe image and data.\n"); 26 fprintf(stderr, "\t-linearity/-linearlist: linearity correction file.\n"); 26 27 fprintf(stderr, "\n"); 27 28 exit (2); … … 120 121 pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 121 122 pmConfigFileSetsMD (config->arguments, &argc, argv, "FRINGE", "-fringe", "-fringelist"); 123 pmConfigFileSetsMD (config->arguments, &argc, argv, "LINEARITY", "-linearity", "-linearlist"); 122 124 123 125 // chip selection is used to limit chips to be processed -
branches/czw_branch/20100817/ppImage/src/ppImageDetrendNonLinear.c
r29486 r29679 4 4 5 5 #include "ppImage.h" 6 7 6 8 7 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem) { … … 47 46 48 47 bool ppImageDetrendNonLinear(pmReadout *input, pmFPAview *detview, pmConfig *config) { 49 bool status;48 bool status; 50 49 51 pmFPAfile *linearity_file = psMetadataLookupPtr(&status,config->files,"PPIMAGE.LINEARITY");52 psFits *linearity_fits = linearity_file->fits;50 pmFPAfile *linearity_file = psMetadataLookupPtr(&status,config->files,"PPIMAGE.LINEARITY"); 51 psFits *linearity_fits = linearity_file->fits; 53 52 54 if (!psFitsMoveExtName(linearity_fits,psMetadataLookupStr(&status,input->parent->concepts,"CELL.NAME"))) { 55 psError(PS_ERR_IO, false, "Unable to move to non-linearity table %s",psMetadataLookupStr(&status,input->parent->concepts,"CELL.NAME")); 56 return(false); 57 } 53 char *extname = psMetadataLookupStr(&status,input->parent->concepts,"CELL.NAME"); 54 if (!extname) { 55 psError(PS_ERR_IO, false, "missing CELL.NAME in concepts"); 56 return(false); 57 } 58 59 if (!psFitsMoveExtName(linearity_fits,extname)) { 60 psError(PS_ERR_IO, false, "Unable to move to non-linearity table %s", extname); 61 return(false); 62 } 58 63 59 psArray *table = psFitsReadTable(linearity_fits);60 if (!table) {61 psError(PS_ERR_IO, false, "Unable to read non-linearity table.\n");62 return(false);63 }64 psArray *table = psFitsReadTable(linearity_fits); 65 if (!table) { 66 psError(PS_ERR_IO, false, "Unable to read non-linearity table.\n"); 67 return(false); 68 } 64 69 65 // It might be better to pack lookup table here...66 // Why? I only use that lookup table once for the single cell it matches.70 // It might be better to pack lookup table here... 71 // Why? I only use that lookup table once for the single cell it matches. 67 72 68 if (!pmNonLinearityApply(input,table)) { 69 psError(PS_ERR_UNKNOWN, false, "Unable to apply non-linearity corrections.\n"); 70 return(false); 71 } 73 if (!pmNonLinearityApply(input,table)) { 74 psError(PS_ERR_UNKNOWN, false, "Unable to apply non-linearity corrections.\n"); 75 psFree (table); 76 return(false); 77 } 78 psFree (table); 72 79 80 return true; 81 } 73 82 74 return(true); 83 bool ppImageDetrendNonLinear_Original(pmReadout *input, ppImageOptions *options) { 84 85 psMetadataItem *concept; 86 pmCell *cell = input->parent; 87 88 switch (options->nonLinearType) { 89 case PS_DATA_VECTOR: 90 ppImageDetrendNonLinearPolynomial (input, options->nonLinearData); 91 return true; 92 93 case PS_DATA_STRING: 94 ppImageDetrendNonLinearLookup (input, options->nonLinearData); 95 return true; 96 97 case PS_DATA_METADATA: 98 // Go looking for the value in the hierarchy 99 concept = psMetadataLookup(cell->concepts, options->nonLinearSource); 100 if (! concept) { 101 pmChip *chip = cell->parent;// Parent chip 102 concept = psMetadataLookup(chip->concepts, options->nonLinearSource); 103 if (! concept) { 104 pmFPA *fpa = chip->parent; // Parent FPA 105 concept = psMetadataLookup(fpa->concepts, options->nonLinearSource); 106 if (! concept) { 107 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 108 "for non-linearity correction --- ignored.\n", (char *)options->nonLinearSource); 109 return false; 110 } 111 } 112 } 113 114 if (concept->type != PS_DATA_STRING) { 115 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %p isn't STRING, as" 116 " expected for non-linearity correction --- ignored.\n", 117 concept); 118 return false; 119 } 120 121 // Get the value of the concept 122 psString conceptValue = concept->data.V; 123 psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; 124 psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); 125 if (!optionItem) { 126 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" 127 " --- ignored.\n", conceptValue); 128 return false; 129 } 130 131 switch (optionItem->type) { 132 case PS_DATA_VECTOR: 133 ppImageDetrendNonLinearPolynomial (input, optionItem); 134 return true; 135 case PS_DATA_STRING: 136 ppImageDetrendNonLinearLookup (input, optionItem); 137 return true; 138 default: 139 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " 140 "desired but unable to interpret NONLIN.DATA for %s" 141 " --- ignored\n", conceptValue); 142 return false; 143 } 144 default: 145 psAbort("Invalid options->nonLinearType"); 146 } 147 return true; 75 148 } 76 /* bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options) { */77 /* psMetadataItem *concept; */78 /* pmCell *cell = input->parent; */79 149 80 /* switch (options->nonLinearType) { */81 /* case PS_DATA_VECTOR: */82 /* ppImageDetrendNonLinearPolynomial (input, options->nonLinearData); */83 /* return true; */84 85 /* case PS_DATA_STRING: */86 /* ppImageDetrendNonLinearLookup (input, options->nonLinearData); */87 /* return true; */88 89 /* case PS_DATA_METADATA: */90 /* // XXX EAM: this is somewhat confusing : let's wrap in a function when i understand it */91 92 /* // Go looking for the value in the hierarchy */93 /* concept = psMetadataLookup(cell->concepts, options->nonLinearSource); */94 /* if (! concept) { */95 /* pmChip *chip = cell->parent;// Parent chip */96 /* concept = psMetadataLookup(chip->concepts, options->nonLinearSource); */97 /* if (! concept) { */98 /* pmFPA *fpa = chip->parent; // Parent FPA */99 /* concept = psMetadataLookup(fpa->concepts, options->nonLinearSource); */100 /* if (! concept) { */101 /* psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " */102 /* "for non-linearity correction --- ignored.\n", (char *)options->nonLinearSource); */103 /* return false; */104 /* } */105 /* } */106 /* } */107 108 /* if (concept->type != PS_DATA_STRING) { */109 /* psLogMsg("phase2", PS_LOG_WARN, "Type for concept %p isn't STRING, as" */110 /* " expected for non-linearity correction --- ignored.\n", */111 /* concept); */112 /* return false; */113 /* } */114 115 /* // Get the value of the concept */116 /* psString conceptValue = concept->data.V; */117 /* psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; */118 /* psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); */119 /* if (!optionItem) { */120 /* psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" */121 /* " --- ignored.\n", conceptValue); */122 /* return false; */123 /* } */124 125 /* switch (optionItem->type) { */126 /* case PS_DATA_VECTOR: */127 /* ppImageDetrendNonLinearPolynomial (input, optionItem); */128 /* return true; */129 /* case PS_DATA_STRING: */130 /* ppImageDetrendNonLinearLookup (input, optionItem); */131 /* return true; */132 /* default: */133 /* psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " */134 /* "desired but unable to interpret NONLIN.DATA for %s" */135 /* " --- ignored\n", conceptValue); */136 /* return false; */137 /* } */138 /* default: */139 /* psAbort("Invalid options->nonLinearType"); */140 /* } */141 /* return true; */142 /* } */143 -
branches/czw_branch/20100817/ppImage/src/ppImageOptions.c
r28043 r29679 8 8 { 9 9 psFree(options->overscan); 10 psFree(options->nonLinearData);11 psFree(options->nonLinearSource);10 // psFree(options->nonLinearData); 11 // psFree(options->nonLinearSource); 12 12 } 13 13 … … 130 130 psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA"); 131 131 if (! dataItem) { 132 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 133 "find NONLIN.DATA in recipe %s.", RECIPE_NAME); 132 psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but unable to find NONLIN.DATA in recipe %s.", RECIPE_NAME); 134 133 exit(EXIT_FAILURE); 135 134 } … … 147 146 // This is a menu; we need the key 148 147 case PS_DATA_METADATA: 149 { 150 bool status; 151 options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE"); 152 if (! status || ! options->nonLinearSource) { 153 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 154 "find NONLIN.SOURCE in recipe %s.", RECIPE_NAME); 155 exit(EXIT_FAILURE); 156 } 157 } 148 options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE"); 149 if (! status || ! options->nonLinearSource) { 150 psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but unable to find NONLIN.SOURCE in recipe %s.", RECIPE_NAME); 151 exit(EXIT_FAILURE); 152 } 158 153 break; 159 154 default: 160 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but " 161 "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME); 155 psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME); 162 156 exit(EXIT_FAILURE); 163 157 }
Note:
See TracChangeset
for help on using the changeset viewer.
