Changeset 18860
- Timestamp:
- Aug 1, 2008, 1:58:37 PM (18 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmShutterCorrection.c (modified) (5 diffs)
-
pmShutterCorrection.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r17995 r18860 957 957 } 958 958 959 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, psMaskType maskVal) 960 { 961 PS_ASSERT_PTR_NON_NULL(shutter, false); 962 PS_ASSERT_PTR_NON_NULL(pattern, false); 963 PS_ASSERT_ARRAY_NON_NULL(inputs, false); 964 965 // determine the output image size based on the input images 966 int row0, col0, numCols, numRows; 967 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, inputs)) { 968 psError(PS_ERR_UNKNOWN, false, "problem setting output readout size."); 969 return false; 970 } 971 972 // generate the required output image based on the specified sizes 973 pmReadoutStackDefineOutput(shutter, col0, row0, numCols, numRows, false, false, maskVal); 974 if (pattern) { 975 pmReadoutStackDefineOutput(pattern, col0, row0, numCols, numRows, false, false, maskVal); 976 } 977 978 psImage *nums = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, numCols, numRows, PS_TYPE_U16, 0); // Image with number fitted per pixel 979 if (!nums) { 980 return false; 981 } 982 psImage *sigma = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, numCols, numRows, PS_TYPE_F32, NAN); // Image with stdev per pixel 983 if (!sigma) { 984 return false; 985 } 986 987 // Update the "concepts" 988 psList *inputCells = psListAlloc(NULL); // List of cells 989 for (long i = 0; i < inputs->n; i++) { 990 pmReadout *readout = inputs->data[i]; // Readout of interest 991 psListAdd(inputCells, PS_LIST_TAIL, readout->parent); 992 } 993 bool success = pmConceptsAverageCells(shutter->parent, inputCells, NULL, NULL, true); 994 psFree(inputCells); 995 996 // Correct the exposure times --- they don't make sense any more. 997 psMetadataItem *item = psMetadataLookup(shutter->parent->concepts, "CELL.EXPOSURE"); 998 item->data.F32 = NAN; 999 item = psMetadataLookup(shutter->parent->concepts, "CELL.DARKTIME"); 1000 item->data.F32 = NAN; 1001 1002 shutter->data_exists = true; 1003 shutter->parent->data_exists = true; 1004 shutter->parent->parent->data_exists = true; 1005 1006 pattern->data_exists = true; 1007 if (pattern->parent) { 1008 pattern->parent->data_exists = true; 1009 if (pattern->parent->parent) { 1010 pattern->parent->parent->data_exists = true; 1011 } 1012 } 1013 1014 return success; 1015 } 1016 959 1017 bool pmShutterCorrectionGenerate(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 960 1018 float reference, const pmShutterCorrectionData *data, … … 962 1020 { 963 1021 PS_ASSERT_PTR_NON_NULL(shutter, false); 1022 PS_ASSERT_PTR_NON_NULL(pattern, false); 964 1023 PS_ASSERT_ARRAY_NON_NULL(inputs, false); 965 1024 PS_ASSERT_INT_EQUAL(data->num, inputs->n, false); … … 975 1034 } 976 1035 977 pmReadoutUpdateSize(shutter, minInputCols, minInputRows, xSize, ySize, false, false, maskVal); 978 if (pattern) { 979 pmReadoutUpdateSize(pattern, minInputCols, minInputRows, xSize, ySize, false, false, maskVal); 980 } 981 982 psImage *nums = pmReadoutAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, xSize, ySize, 983 PS_TYPE_U16, 0); // Image with number fitted per pixel 1036 psImage *nums = pmReadoutGetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT); 984 1037 if (!nums) { 985 1038 return false; 986 1039 } 987 psImage *sigma = pmReadoutAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, xSize, ySize, 988 PS_TYPE_F32, NAN); // Image with stdev per pixel 1040 psImage *sigma = pmReadoutGetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA); 989 1041 if (!sigma) { 990 psFree(nums);991 1042 return false; 992 1043 } 993 1044 994 1045 psImage *shutterImage = shutter->image; // Shutter correction image 995 psImage *patternImage; // Illumination pattern 996 if (pattern) { 997 patternImage = psMemIncrRefCounter(pattern->image); 998 } else { 999 patternImage = psImageAlloc(xSize, ySize, PS_TYPE_F32); 1000 } 1046 psImage *patternImage = pattern->image; // Illumination pattern 1001 1047 1002 1048 int num = data->num; // Number of images … … 1024 1070 errors->data.F32[r] = sqrtf(readout->weight->data.F32[yIn][xIn]) * ref; 1025 1071 } else { 1026 errors->data.F32[r] = sqrtf(image->data.F32[yIn][xIn]) * ref; 1072 // XXX guess that the input data is Poisson distributed; if we go negative, force high 1073 errors->data.F32[r] = sqrtf(fabs(image->data.F32[yIn][xIn])) * ref; 1027 1074 } 1028 1075 } … … 1049 1096 psFree(errors); 1050 1097 psFree(counts); 1051 psFree(nums); 1052 psFree(sigma); 1053 1054 // Update the "concepts" 1055 psList *inputCells = psListAlloc(NULL); // List of cells 1056 for (long i = 0; i < inputs->n; i++) { 1057 pmReadout *readout = inputs->data[i]; // Readout of interest 1058 psListAdd(inputCells, PS_LIST_TAIL, readout->parent); 1059 } 1060 bool success = pmConceptsAverageCells(shutter->parent, inputCells, NULL, NULL, true); 1061 psFree(inputCells); 1062 1063 // Correct the exposure times --- they don't make sense any more. 1064 psMetadataItem *item = psMetadataLookup(shutter->parent->concepts, "CELL.EXPOSURE"); 1065 item->data.F32 = NAN; 1066 item = psMetadataLookup(shutter->parent->concepts, "CELL.DARKTIME"); 1067 item->data.F32 = NAN; 1068 1069 shutter->data_exists = true; 1070 shutter->parent->data_exists = true; 1071 shutter->parent->parent->data_exists = true; 1072 1073 if (pattern) { 1074 pattern->data_exists = true; 1075 pattern->parent->data_exists = true; 1076 pattern->parent->parent->data_exists = true; 1077 } 1078 1079 return success; 1080 } 1098 1099 return true; 1100 } -
trunk/psModules/src/detrend/pmShutterCorrection.h
r17994 r18860 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2008-0 6-09 00:39:37 $7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2008-08-01 23:58:37 $ 9 9 * Copyright 2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 189 189 ); 190 190 191 191 // prepare outputs for shutter correction 192 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, psMaskType maskVal); 192 193 193 194 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
