Changeset 29486
- Timestamp:
- Oct 19, 2010, 5:41:33 PM (16 years ago)
- Location:
- branches/czw_branch/20100817
- Files:
-
- 20 edited
-
ippconfig/gpc1/ppImage.config (modified) (1 diff)
-
ippconfig/recipes/filerules-mef.mdc (modified) (1 diff)
-
ippconfig/recipes/filerules-simple.mdc (modified) (1 diff)
-
ippconfig/recipes/filerules-split.mdc (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (1 diff)
-
ppImage/src/ppImageDefineFile.c (modified) (4 diffs)
-
ppImage/src/ppImageDetrendFree.c (modified) (2 diffs)
-
ppImage/src/ppImageDetrendNonLinear.c (modified) (2 diffs)
-
ppImage/src/ppImageDetrendReadout.c (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (1 diff)
-
ppImage/src/ppImageParseCamera.c (modified) (1 diff)
-
psLib/src/types/psMetadata.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfile.c (modified) (2 diffs)
-
psModules/src/camera/pmFPAfile.h (modified) (1 diff)
-
psModules/src/camera/pmFPAfileFitsIO.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileIO.c (modified) (6 diffs)
-
psModules/src/detrend/pmDetrendDB.c (modified) (1 diff)
-
psModules/src/detrend/pmDetrendDB.h (modified) (1 diff)
-
psModules/src/detrend/pmNonLinear.c (modified) (2 diffs)
-
psModules/src/detrend/pmNonLinear.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100817/ippconfig/gpc1/ppImage.config
r27407 r29486 262 262 NOISEMAP METADATA 263 263 END 264 LINEARITY METADATA 265 END 264 266 END 265 267 -
branches/czw_branch/20100817/ippconfig/recipes/filerules-mef.mdc
r28541 r29486 63 63 PPIMAGE.FRINGE INPUT @DETDB CHIP FRINGE 64 64 PPIMAGE.SHUTTER INPUT @DETDB CHIP IMAGE 65 PPIMAGE.LINEARITY INPUT @DETDB CHIP LINEARITY 65 66 66 67 ## Files used by ppMerge -
branches/czw_branch/20100817/ippconfig/recipes/filerules-simple.mdc
r28541 r29486 25 25 PPIMAGE.FRINGE INPUT @DETDB CHIP FRINGE 26 26 PPIMAGE.SHUTTER INPUT @DETDB CHIP IMAGE 27 PPIMAGE.LINEARITY INPUT @DETDB CHIP LINEARITY 27 28 28 29 ## Files used by ppMerge -
branches/czw_branch/20100817/ippconfig/recipes/filerules-split.mdc
r28619 r29486 36 36 PPIMAGE.FRINGE INPUT @DETDB CHIP FRINGE 37 37 PPIMAGE.SHUTTER INPUT @DETDB CHIP IMAGE 38 PPIMAGE.LINEARITY INPUT @DETDB CHIP LINEARITY 38 39 39 40 ## Files used by ppMerge -
branches/czw_branch/20100817/ppImage/src/ppImage.h
r28043 r29486 155 155 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options); 156 156 157 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options); 157 //bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options); 158 bool ppImageDetrendNonLinear(pmReadout *input, pmFPAview *linearity, pmConfig *config); 158 159 bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem); 159 160 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem); -
branches/czw_branch/20100817/ppImage/src/ppImageDefineFile.c
r26494 r29486 15 15 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 16 16 if (!status) { 17 psError(PS_ERR_UNKNOWN, false, "failed to load file definition ");17 psError(PS_ERR_UNKNOWN, false, "failed to load file definition ARG LIST"); 18 18 return false; 19 19 } … … 23 23 file = pmFPAfileDefineFromRun(&status, NULL, config, filerule); 24 24 if (!status) { 25 psError(PS_ERR_UNKNOWN, false, "failed to load file definition ");25 psError(PS_ERR_UNKNOWN, false, "failed to load file definition RUN"); 26 26 return false; 27 27 } … … 31 31 file = pmFPAfileDefineFromConf(&status, config, filerule); 32 32 if (!status) { 33 psError(PS_ERR_UNKNOWN, false, "failed to load file definition ");33 psError(PS_ERR_UNKNOWN, false, "failed to load file definition CONFIG"); 34 34 return false; 35 35 } … … 39 39 file = pmFPAfileDefineFromDetDB(&status, config, filerule, input, detrendType); 40 40 if (!status) { 41 psError(PS_ERR_UNKNOWN, false, "failed to load file definition ");41 psError(PS_ERR_UNKNOWN, false, "failed to load file definition DETREND"); 42 42 return false; 43 43 } -
branches/czw_branch/20100817/ppImage/src/ppImageDetrendFree.c
r24485 r29486 13 13 "PPIMAGE.FLAT", 14 14 "PPIMAGE.SHUTTER", 15 "PPIMAGE.LINEARITY", 15 16 NULL 16 17 }; … … 23 24 24 25 pmFPAfile *file = psMetadataLookupPtr(&status, config->files, detrendTypes[i]); // File of interest 26 psTrace("pmFPAfileFree",1,"Working on %s\n",detrendTypes[i]); 25 27 if (!file) continue; // not all detrends are used in any given run 26 28 -
branches/czw_branch/20100817/ppImage/src/ppImageDetrendNonLinear.c
r11702 r29486 4 4 5 5 #include "ppImage.h" 6 6 7 7 8 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem) { … … 44 45 } 45 46 46 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options) {47 47 48 psMetadataItem *concept; 49 pmCell *cell = input->parent;48 bool ppImageDetrendNonLinear(pmReadout *input, pmFPAview *detview, pmConfig *config) { 49 bool status; 50 50 51 switch (options->nonLinearType) { 52 case PS_DATA_VECTOR: 53 ppImageDetrendNonLinearPolynomial (input, options->nonLinearData); 54 return true; 51 pmFPAfile *linearity_file = psMetadataLookupPtr(&status,config->files,"PPIMAGE.LINEARITY"); 52 psFits *linearity_fits = linearity_file->fits; 55 53 56 case PS_DATA_STRING: 57 ppImageDetrendNonLinearLookup (input, options->nonLinearData); 58 return true; 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 } 58 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 } 59 64 60 case PS_DATA_METADATA: 61 // XXX EAM: this is somewhat confusing : let's wrap in a function when i understand it 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. 67 68 if (!pmNonLinearityApply(input,table)) { 69 psError(PS_ERR_UNKNOWN, false, "Unable to apply non-linearity corrections.\n"); 70 return(false); 71 } 62 72 63 // Go looking for the value in the hierarchy64 concept = psMetadataLookup(cell->concepts, options->nonLinearSource);65 if (! concept) {66 pmChip *chip = cell->parent;// Parent chip67 concept = psMetadataLookup(chip->concepts, options->nonLinearSource);68 if (! concept) {69 pmFPA *fpa = chip->parent; // Parent FPA70 concept = psMetadataLookup(fpa->concepts, options->nonLinearSource);71 if (! concept) {72 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s "73 "for non-linearity correction --- ignored.\n", (char *)options->nonLinearSource);74 return false;75 }76 }77 }78 73 79 if (concept->type != PS_DATA_STRING) { 80 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %p isn't STRING, as" 81 " expected for non-linearity correction --- ignored.\n", 82 concept); 83 return false; 84 } 74 return(true); 75 } 76 /* bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options) { */ 77 /* psMetadataItem *concept; */ 78 /* pmCell *cell = input->parent; */ 85 79 86 // Get the value of the concept 87 psString conceptValue = concept->data.V; 88 psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; 89 psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); 90 if (!optionItem) { 91 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" 92 " --- ignored.\n", conceptValue); 93 return false; 94 } 80 /* switch (options->nonLinearType) { */ 81 /* case PS_DATA_VECTOR: */ 82 /* ppImageDetrendNonLinearPolynomial (input, options->nonLinearData); */ 83 /* return true; */ 95 84 96 switch (optionItem->type) { 97 case PS_DATA_VECTOR: 98 ppImageDetrendNonLinearPolynomial (input, optionItem); 99 return true; 100 case PS_DATA_STRING: 101 ppImageDetrendNonLinearLookup (input, optionItem); 102 return true; 103 default: 104 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " 105 "desired but unable to interpret NONLIN.DATA for %s" 106 " --- ignored\n", conceptValue); 107 return false; 108 } 109 default: 110 psAbort("Invalid options->nonLinearType"); 111 } 112 return true; 113 } 85 /* case PS_DATA_STRING: */ 86 /* ppImageDetrendNonLinearLookup (input, options->nonLinearData); */ 87 /* return true; */ 114 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/ppImageDetrendReadout.c
r26653 r29486 51 51 } 52 52 53 54 # if 055 53 // Non-linearity correction 56 54 if (options->doNonLin) { 57 ppImageDetrendNonLinear(detrend->input, input, options); 58 } 59 # endif 55 // linearity = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.LINEARITY"); 56 if (!ppImageDetrendNonLinear(input,detview,config)) { 57 psError(PS_ERR_UNKNOWN, false, "Unable to correct NonLinearity"); 58 psFree(detview); 59 return(false); 60 } 61 /* ppImageDetrendNonLinear(detrend->input, input, options); */ 62 } 60 63 61 64 // set up the dark and bias -
branches/czw_branch/20100817/ppImage/src/ppImageLoop.c
r28375 r29486 152 152 ESCAPE("Unable to free detrend images"); 153 153 } 154 154 155 155 // Apply the fringe correction 156 156 if (options->doFringe) { -
branches/czw_branch/20100817/ppImage/src/ppImageParseCamera.c
r26895 r29486 73 73 return NULL; 74 74 } 75 } 76 77 if (options->doNonLin) { 78 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.LINEARITY", "LINEARITY", 79 PM_FPA_FILE_LINEARITY, PM_DETREND_TYPE_LINEARITY)) { 80 psError(PS_ERR_IO, false, "Can't find a non-linearity correction source"); 81 psFree(options); 82 return NULL; 83 } 75 84 } 76 85 -
branches/czw_branch/20100817/psLib/src/types/psMetadata.c
r27646 r29486 109 109 type = metadataItem->type; 110 110 111 111 // fprintf(stderr,"%s %s %d\n",metadataItem->name,metadataItem->comment,type); 112 112 psMemDecrRefCounter(metadataItem->name); 113 113 psMemDecrRefCounter(metadataItem->comment); -
branches/czw_branch/20100817/psModules/src/camera/pmFPAfile.c
r27657 r29486 36 36 return; 37 37 } 38 38 psTrace ("pmFPAfileFree", 5, "freeing %s %ld\n", file->name,(psU64) file->fits); 39 39 psAssert(!fpaFileFreeStrict || file->fits == NULL, "File %s wasn't closed.", file->name); 40 40 … … 523 523 if (!strcasecmp(type, "HEADER")) { 524 524 return PM_FPA_FILE_HEADER; 525 } 526 if (!strcasecmp(type, "LINEARITY")) { 527 return PM_FPA_FILE_LINEARITY; 525 528 } 526 529 // deprecate this? -
branches/czw_branch/20100817/psModules/src/camera/pmFPAfile.h
r27657 r29486 50 50 PM_FPA_FILE_SRCTEXT, 51 51 PM_FPA_FILE_PATTERN, 52 PM_FPA_FILE_LINEARITY, 52 53 } pmFPAfileType; 53 54 -
branches/czw_branch/20100817/psModules/src/camera/pmFPAfileFitsIO.c
r27989 r29486 145 145 case PM_FPA_FILE_FRINGE: 146 146 case PM_FPA_FILE_DARK: 147 case PM_FPA_FILE_LINEARITY: 147 148 case PM_FPA_FILE_CMP: 148 149 case PM_FPA_FILE_CMF: -
branches/czw_branch/20100817/psModules/src/camera/pmFPAfileIO.c
r28340 r29486 224 224 case PM_FPA_FILE_JPEG: 225 225 case PM_FPA_FILE_KAPA: 226 case PM_FPA_FILE_LINEARITY: 226 227 break; 227 228 default: … … 551 552 case PM_FPA_FILE_ASTROM_MODEL: 552 553 case PM_FPA_FILE_ASTROM_REFSTARS: 554 case PM_FPA_FILE_LINEARITY: 553 555 psTrace ("psModules.camera", 5, "closing %s (%s) (%d:%d:%d)\n", file->filename, file->name, view->chip, view->cell, view->readout); 554 556 status = psFitsClose (file->fits); … … 566 568 case PM_FPA_FILE_JPEG: 567 569 case PM_FPA_FILE_KAPA: 570 568 571 break; 569 572 … … 610 613 case PM_FPA_FILE_FRINGE: 611 614 case PM_FPA_FILE_DARK: 615 // 612 616 status = pmFPAviewFreeData(view, file); 613 617 break; … … 627 631 case PM_FPA_FILE_JPEG: 628 632 case PM_FPA_FILE_KAPA: 633 case PM_FPA_FILE_LINEARITY: 629 634 psTrace ("psModules.camera", 5, "nothing to free for %s (%s)\n", file->filename, file->name); 630 635 return true; … … 782 787 case PM_FPA_FILE_ASTROM_MODEL: 783 788 case PM_FPA_FILE_ASTROM_REFSTARS: 789 case PM_FPA_FILE_LINEARITY: 784 790 psTrace ("psModules.camera", 5, "opening %s (%s) (%d:%d:%d)\n", 785 791 file->filename, file->name, view->chip, view->cell, view->readout); -
branches/czw_branch/20100817/psModules/src/detrend/pmDetrendDB.c
r24490 r29486 106 106 DETREND_STRING_CASE(ASTROM); 107 107 DETREND_STRING_CASE(NOISEMAP); 108 DETREND_STRING_CASE(LINEARITY); 108 109 default: 109 110 return NULL; -
branches/czw_branch/20100817/psModules/src/detrend/pmDetrendDB.h
r24490 r29486 36 36 PM_DETREND_TYPE_ASTROM, 37 37 PM_DETREND_TYPE_NOISEMAP, 38 PM_DETREND_TYPE_LINEARITY, 38 39 } pmDetrendType; 39 40 -
branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.c
r12696 r29486 45 45 } } 46 46 47 48 # define PS_BIN_INTERPOLATE(RESULT, VECTOR, BOUNDS, BIN, VALUE) { \ 49 float dX, dY, Xo, Yo, Xt; \ 50 if (BIN == BOUNDS->n - 1) { \ 51 dX = 0.5*(BOUNDS->data.F32[BIN+1] - BOUNDS->data.F32[BIN-1]); \ 52 dY = VECTOR->data.F32[BIN] - VECTOR->data.F32[BIN-1]; \ 53 Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]); \ 54 Yo = VECTOR->data.F32[BIN]; \ 55 } else { \ 56 dX = 0.5*(BOUNDS->data.F32[BIN+2] - BOUNDS->data.F32[BIN]); \ 57 dY = VECTOR->data.F32[BIN+1] - VECTOR->data.F32[BIN]; \ 58 Xo = 0.5*(BOUNDS->data.F32[BIN+1] + BOUNDS->data.F32[BIN]); \ 59 Yo = VECTOR->data.F32[BIN]; \ 60 } \ 61 if (dY != 0) { \ 62 Xt = (VALUE - Yo)*dX/dY + Xo; \ 63 } else { \ 64 Xt = Xo; \ 65 } \ 66 Xt = PS_MIN (BOUNDS->data.F32[BIN+1], PS_MAX(BOUNDS->data.F32[BIN], Xt)); \ 67 psTrace("pmNonLinear", 6, "(Xo, Yo, dX, dY, Xt, Yt) is (%.2f %.2f %.2f %.2f %.2f %.2f)\n", \ 68 Xo, Yo, dX, dY, Xt, VALUE); \ 69 RESULT = Xt; } 70 47 71 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout, const psVector *inFlux, const psVector *outFlux) 48 72 { … … 92 116 return inputReadout; 93 117 } 118 119 bool pmNonLinearityApply(pmReadout *inputReadout, psArray *Ltab) 120 { 121 PS_ASSERT_PTR_NON_NULL(inputReadout, false); 122 PS_ASSERT_PTR_NON_NULL(inputReadout->image, false); 123 PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, false); 124 PS_ASSERT_PTR_NON_NULL(Ltab, false); 125 126 // psS32 tableSize = Ltab->n; 127 128 psImage *image = inputReadout->image; 129 psS32 numSamples = 39; 130 131 psS32 numBorder = 10; 132 // Load default data. 133 psVector *default_row_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32); 134 psVector *default_col_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32); 135 psVector *row_correction_fluxes; 136 psVector *col_correction_fluxes; 137 138 psVector *default_row_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32); 139 psVector *default_col_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32); 140 psVector *row_correction_factors; 141 psVector *col_correction_factors; 142 143 int n = 0; 144 int m = 0; 145 for (int k = 0; k < Ltab->n; k++) { // Begin load default tables 146 psMetadata *row = Ltab->data[k]; 147 if (psMetadataLookupS32(NULL,row,"POSITION") != -1) { 148 continue; 149 } 150 if (psMetadataLookupS32(NULL,row,"DIRECTION") == 0) { 151 psVectorSet(default_row_correction_fluxes,n,psMetadataLookupF32(NULL,row,"FLUX")); 152 psVectorSet(default_row_correction_factors,n,psMetadataLookupF32(NULL,row,"FACTOR")); 153 n++; 154 } 155 else { 156 psVectorSet(default_col_correction_fluxes,m,psMetadataLookupF32(NULL,row,"FLUX")); 157 psVectorSet(default_col_correction_factors,m,psMetadataLookupF32(NULL,row,"FACTOR")); 158 m++; 159 } 160 } // End load default tables 161 162 for (int i = 0; i < image->numRows; i++) { // Loop over rows : note: problem with discontinuity here 163 n = 0; 164 if ((i < numBorder)||(image->numRows - i < numBorder)) { // Load row correction data 165 row_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32); 166 row_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32); 167 168 for (int k = 0; k < Ltab->n; k++) { 169 psMetadata *row = Ltab->data[k]; 170 if ((psMetadataLookupS32(NULL,row,"DIRECTION") != 0)|| 171 (psMetadataLookupS32(NULL,row,"POSITION") != i + 1)) { // image data is 0 indexed, but correction data is 1 indexed. 172 continue; 173 } 174 psVectorSet(row_correction_fluxes,n,psMetadataLookupF32(NULL,row,"FLUX")); 175 psVectorSet(row_correction_factors,n,psMetadataLookupF32(NULL,row,"FACTOR")); 176 // psTrace("psModules.camera",6,"rows: %d\n",n); 177 n++; 178 } 179 } // End load specific row 180 else { 181 row_correction_fluxes = default_row_correction_fluxes; 182 row_correction_factors = default_row_correction_factors; 183 } // End load default row 184 185 for (int j = 0; j < image->numCols; j++) { // Loop over columns 186 m = 0; 187 188 if ((j < numBorder)||(image->numCols - j < numBorder)) { // Load col correction data 189 col_correction_fluxes = psVectorAlloc(numSamples,PS_TYPE_F32); 190 col_correction_factors = psVectorAlloc(numSamples,PS_TYPE_F32); 191 for (int k = 0; k < Ltab->n; k++) { 192 psMetadata *row = Ltab->data[k]; 193 if ((psMetadataLookupS32(NULL,row,"DIRECTION") != 1)|| 194 (psMetadataLookupS32(NULL,row,"POSITION") != j + 1)) { 195 continue; 196 } 197 psVectorSet(col_correction_fluxes,m,psMetadataLookupF32(NULL,row,"FLUX")); 198 psVectorSet(col_correction_factors,m,psMetadataLookupF32(NULL,row,"FACTOR")); 199 // psTrace("psModules.camera",6,"columns: %d\n",m); 200 m++; 201 } 202 } // End load specific col 203 else { 204 col_correction_fluxes = default_col_correction_fluxes; 205 col_correction_factors = default_col_correction_factors; 206 } // End load default col 207 208 // Calculate correction factor contribution for this pixel. 209 psF32 factor_row = pmNonLinearityMeasure(image->data.F32[i][j], 210 row_correction_fluxes,row_correction_factors); 211 psF32 factor_col = pmNonLinearityMeasure(image->data.F32[i][j], 212 col_correction_fluxes,col_correction_factors); 213 214 if (((i <= 9)&&(j <= 9))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case. 215 psTrace("psModules.camera",6,"Linearity: %d %d %s %f %f %f %d %d\n",i,j, 216 psMetadataLookupStr(NULL,inputReadout->parent->concepts,"CELL.NAME"), 217 image->data.F32[i][j],factor_row,factor_col,numBorder,numSamples); 218 psTrace("psModules.camera",6,"Linearity: R: %d %d %d C: %d %d %d\n", 219 i,(i < numBorder),(image->numRows - i), 220 j,(j < numBorder),(image->numCols - j)); 221 222 /* psTrace("psModules.camera",6,"Linearity: V: "); */ 223 /* for (int k = 0; k < numSamples; k++) { */ 224 /* psTrace("psModules.camera",6,"(%f %f) ", */ 225 /* col_correction_fluxes->data.F32[k],col_correction_factors->data.F32[k]); */ 226 /* } */ 227 /* psTrace("psModules.camera",6,"\n"); */ 228 } // End Test case 229 230 // Apply correction to image data 231 image->data.F32[i][j] = image->data.F32[i][j] * ( factor_row * factor_col ) ; 232 233 // Free correction if we allocated 234 if ((j < numBorder)||(image->numCols - j < numBorder)) { 235 psFree(col_correction_fluxes); 236 psFree(col_correction_factors); 237 } 238 239 } // End loop over columns 240 241 // Free correction if we allocated 242 if ((i < numBorder)||(image->numRows - i < numBorder)) { 243 psFree(row_correction_fluxes); 244 psFree(row_correction_factors); 245 } 246 247 } // End loop over rows 248 249 psFree(default_row_correction_fluxes); 250 psFree(default_row_correction_factors); 251 psFree(default_col_correction_fluxes); 252 psFree(default_col_correction_factors); 253 254 return(true); 255 } 256 257 psF32 pmNonLinearityMeasure(psF32 flux, psVector *correction_fluxes, psVector *correction_factors) { 258 // psS32 numPixels = 0; 259 psF32 result = 0; 260 psU32 bin = 0; 261 262 bin = correction_fluxes->n - 1; 263 if (flux < correction_fluxes->data.F32[0]) { 264 return(1.0); 265 } 266 if (flux > correction_fluxes->data.F32[bin]) { 267 return(1.0); 268 } 269 270 for (int i = 0; i < correction_fluxes->n - 1; i++) { 271 if ((flux >= correction_fluxes->data.F32[i])&& 272 (flux < correction_fluxes->data.F32[i+1])) { 273 result = correction_factors->data.F32[i] + 274 (flux - correction_fluxes->data.F32[i]) * 275 ((correction_factors->data.F32[i+1] - correction_factors->data.F32[i]) / 276 (correction_fluxes->data.F32[i+1] - correction_fluxes->data.F32[i])); 277 continue; 278 } 279 } 280 281 /* PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */ 282 /* if ((bin < 0)||(bin > correction_fluxes->n)) { */ 283 /* return(1.0); */ 284 /* } */ 285 286 /* PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */ 287 if (!isfinite(result)) { 288 result = 1.0; 289 } 290 if (result <= 0) { 291 result = 1.0; 292 } 293 return(result); 294 } 295 296 297 -
branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.h
r12696 r29486 31 31 const psVector *outFlux ///< Table column with output fluxes 32 32 ); 33 33 bool pmNonLinearityApply(pmReadout *inputReadout, psArray *Ltab); 34 psF32 pmNonLinearityMeasure(psF32 flux, psVector *correction_fluxes, psVector *correction_factors); 34 35 /// @} 35 36 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
