Changeset 25027 for branches/pap/ppImage/src/ppImageDetrendReadout.c
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ppImage
- Property svn:mergeinfo deleted
-
branches/pap/ppImage/src/ppImageDetrendReadout.c
r23825 r25027 17 17 // Masking on the basis of pixel value needs to be done before anything else, so the values are pristine. 18 18 if (options->doMaskBuild) { 19 psImageMaskType satMask = options->doMaskSat ? options->satMask : 0;20 psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0;19 psImageMaskType satMask = options->doMaskSat ? options->satMask : 0; 20 psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0; 21 21 pmReadoutGenerateMask(input, satMask, lowMask); 22 22 } … … 56 56 if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) { 57 57 psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias."); 58 psFree(detview);58 psFree(detview); 59 59 return false; 60 60 } … … 64 64 if (options->doVarianceBuild) { 65 65 // create the target mask and variance images 66 pmReadoutGenerateVariance(input, true); 66 psImage *noiseImage = NULL; 67 if (options->doNoiseMap) { 68 // XXX convert the noiseMap image to a binned image 69 pmReadout *noiseMap = NULL; 70 noiseMap = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.NOISEMAP"); 71 noiseImage = psImageCopy (NULL, input->image, PS_TYPE_F32); 72 psImageInit (noiseImage, 0.0); 73 74 // XXX this works, but is not really quite right: the model shoud include the 75 // offset information, we are not really getting exactly the right mapping from the 76 // original file. 77 psImageBinning *binning = psImageBinningAlloc(); 78 binning->nXruff = noiseMap->image->numCols; 79 binning->nYruff = noiseMap->image->numRows; 80 binning->nXfine = input->image->numCols; 81 binning->nYfine = input->image->numRows; 82 psImageBinningSetScale(binning, PS_IMAGE_BINNING_LEFT); 83 84 psImageUnbin (noiseImage, noiseMap->image, binning); 85 psFree (binning); 86 } 87 pmReadoutGenerateVariance(input, noiseImage, true); 88 psFree (noiseImage); 67 89 } 68 90 69 91 if (options->doDark && dark) { 70 if (!pmDarkApply(input, dark, options-> maskValue)) {92 if (!pmDarkApply(input, dark, options->darkMask)) { 71 93 psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark."); 72 psFree(detview);94 psFree(detview); 73 95 return false; 74 96 } … … 79 101 options->remnanceSize, options->remnanceThresh)) { 80 102 psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance."); 81 psFree(detview);103 psFree(detview); 82 104 return false; 83 105 } … … 88 110 pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER"); 89 111 if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) { 90 psFree(detview);112 psFree(detview); 91 113 return false; 92 114 } … … 97 119 pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT"); 98 120 if (!pmFlatField(input, flat, options->flatMask)) { 99 psFree(detview); 121 psFree(detview); 122 return false; 123 } 124 } 125 126 // Pattern noise correction 127 if (options->doPattern) { 128 if (!pmPatternRow(input, options->patternOrder, options->patternIter, options->patternRej, 129 options->patternThresh, options->patternMean, options->patternStdev, 130 options->maskValue, options->darkMask)) { 131 psFree(detview); 100 132 return false; 101 133 } … … 119 151 psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE"); 120 152 if (normlist) { 121 pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");122 123 // get the menu of class IDs124 psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 153 pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT"); 154 155 // get the menu of class IDs 156 psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 125 157 if (!menu) { 126 158 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 127 psFree(detview);128 return false; 129 } 130 // get the rule for class_id for the desired class131 const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 159 psFree(detview); 160 return false; 161 } 162 // get the rule for class_id for the desired class 163 const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 132 164 if (!rule) { 133 165 psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass); 134 psFree(detview);135 return false; 136 } 137 // get the class_id from the rule166 psFree(detview); 167 return false; 168 } 169 // get the class_id from the rule 138 170 char *classID = pmFPAfileNameFromRule(rule, inputFile, view); 139 171 if (!classID) { 140 172 psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule); 141 psFree(detview);142 return false; 143 } 144 145 // get normalization from the class_id146 float norm = psMetadataLookupF32 (&mdok, normlist, classID);147 if (!mdok) {148 psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID);149 psFree(detview);150 return false;151 }173 psFree(detview); 174 return false; 175 } 176 177 // get normalization from the class_id 178 float norm = psMetadataLookupF32 (&mdok, normlist, classID); 179 if (!mdok) { 180 psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID); 181 psFree(detview); 182 return false; 183 } 152 184 153 185 pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest … … 157 189 psFree(comment); 158 190 159 // apply the normalization191 // apply the normalization 160 192 psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32)); 161 193 162 psFree (classID);194 psFree (classID); 163 195 } 164 196 # endif … … 167 199 pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE"); 168 200 if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) { 169 psFree(detview);201 psFree(detview); 170 202 return false; 171 203 }
Note:
See TracChangeset
for help on using the changeset viewer.
