Changeset 36635 for trunk/ppBackground/src/ppBackgroundStackLoop.c
- Timestamp:
- Apr 2, 2014, 1:13:06 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ppBackground/src/ppBackgroundStackLoop.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppBackground/src/ppBackgroundStackLoop.c
r36615 r36635 68 68 69 69 } 70 71 70 } // End initialization block. 71 72 73 // Loop over the input images, and apply the models to construct the restored versions. 74 for (i = 0; i < data->stack_data->n; i++) { 75 pmFPAfile *stack = data->stack_data->data[i]; 76 pmFPAview *view = pmFPAviewAlloc(0); 77 78 // PART 1: 79 // Determine the extent of the model map for this stack 80 data->x_min = 99e99; data->x_max = -99e99; 81 data->y_min = 99e99; data->y_max = -99e99; 82 // Allocate the modelMap for the region we're covering. 83 psPlane *pix = psPlaneAlloc(); // Pixel coordinates on chip 84 psPlane *tp = psPlaneAlloc(); // Focal plane coordinates 85 86 pix->x = 0; pix->y = 0; 87 psPlaneTransformApply(tp, stack->fpa->toTPA, pix); 88 printf("%f %f -> %f %f\n",pix->x,pix->y,tp->x,tp->y); 89 if (tp->x < data->x_min) { data->x_min = tp->x; } 90 if (tp->x > data->x_max) { data->x_max = tp->x; } 91 if (tp->y < data->y_min) { data->y_min = tp->y; } 92 if (tp->y > data->y_max) { data->y_max = tp->y; } 93 94 pix->x = 6240; pix->y = 0; 95 psPlaneTransformApply(tp, stack->fpa->toTPA, pix); 96 printf("%f %f -> %f %f\n",pix->x,pix->y,tp->x,tp->y); 97 if (tp->x < data->x_min) { data->x_min = tp->x; } 98 if (tp->x > data->x_max) { data->x_max = tp->x; } 99 if (tp->y < data->y_min) { data->y_min = tp->y; } 100 if (tp->y > data->y_max) { data->y_max = tp->y; } 101 102 pix->x = 6240; pix->y = 6243; 103 psPlaneTransformApply(tp, stack->fpa->toTPA, pix); 104 printf("%f %f -> %f %f\n",pix->x,pix->y,tp->x,tp->y); 105 if (tp->x < data->x_min) { data->x_min = tp->x; } 106 if (tp->x > data->x_max) { data->x_max = tp->x; } 107 if (tp->y < data->y_min) { data->y_min = tp->y; } 108 if (tp->y > data->y_max) { data->y_max = tp->y; } 109 110 pix->x = 0; pix->y = 6243; 111 psPlaneTransformApply(tp, stack->fpa->toTPA, pix); 112 printf("%f %f -> %f %f\n",pix->x,pix->y,tp->x,tp->y); 113 if (tp->x < data->x_min) { data->x_min = tp->x; } 114 if (tp->x > data->x_max) { data->x_max = tp->x; } 115 if (tp->y < data->y_min) { data->y_min = tp->y; } 116 if (tp->y > data->y_max) { data->y_max = tp->y; } 117 118 /* data->x_min -= data->ra_min; */ 119 /* data->x_max -= data->ra_min; */ 120 /* data->y_min -= data->dec_min; */ 121 /* data->y_max -= data->dec_min; */ 122 123 124 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 125 psImageBinning *binning = psImageBinningAlloc(); 126 binning->nXruff = 15; // Number of samples 127 binning->nYruff = 15; 128 // binning->nXfine = ceil(data->ra_max - data->ra_min) + 1; // This is the range we're looking at 129 // binning->nYfine = ceil(data->dec_max - data->dec_min) + 1; 130 binning->nXfine = ceil(data->x_max - data->x_min) + 1; 131 binning->nYfine = ceil(data->y_max - data->y_min) + 1; 132 binning->nXskip = floor(data->x_min - data->ra_min) + 1; 133 binning->nYskip = floor(data->y_min - data->dec_min) + 1; 134 psImageBinningSetScale(binning,PS_IMAGE_BINNING_CENTER); 135 printf("Sizes: sky: %f %f -> %f %f :: tp: %f %f -> %f %f :: map: %d %d\n", 136 0.0,0.0,0.0,0.0,data->ra_min,data->dec_min,data->ra_max,data->dec_max,binning->nXfine,binning->nYfine); 137 printf("Sizes: corners: %f %f -> %f %f map: %d %d\n", 138 data->x_min,data->y_min,data->x_max,data->y_max, 139 binning->nXfine,binning->nYfine); 140 psImage *sizeImage = psImageAlloc(binning->nXfine,binning->nYfine,PS_TYPE_F32); 141 P_PSIMAGE_SET_COL0(sizeImage, data->x_min); 142 P_PSIMAGE_SET_ROW0(sizeImage, data->y_min); 143 data->modelMap = psImageMapAlloc(sizeImage,binning,stats); 144 /* psFree(sizeImage); */ 145 /* data->modelMap = psImageMapNoImageAlloc( binning,stats); */ 146 /* P_PSIMAGE_SET_COL0(data->modelMap->map, (data->x_min - binning->nXskip) / binning->nXbin); */ 147 /* P_PSIMAGE_SET_ROW0(data->modelMap->map, (data->y_min - binning->nYskip) / binning->nYbin); */ 148 149 // force col0/row0 150 /* data->modelMap->map->col0 = data->modelMap->binning->nXskip; */ 151 /* data->modelMap->map->row0 = data->modelMap->binning->nYskip; */ 152 153 // PART 2: 154 // Solve the data into a model for this region of the sky. 155 72 156 // This seems wrong, but I need a blank modelMap object, so we fit the zero-data we've stored in the calib objects 73 157 printf("Determining blank modelMap!\n"); … … 83 167 return(false); 84 168 } 85 } // End initialization block. 86 87 // This is where a loop would likely start. 88 { 89 // Construct the offset information 90 printf("Model fit!\n"); 91 if (!ppBackgroundStackDataModelFit(data)) { 92 psError(psErrorCodeLast(), false, "Error determining the exposure/OTA scaling."); 93 return(false); 94 } 95 96 // Apply full correction 97 printf("Calib apply!\n"); 98 if (!ppBackgroundStackCalibApply(data)) { 99 psError(psErrorCodeLast(), false, "Error applying the calibration models."); 100 return(false); 101 } 102 103 // Fit the new model 104 printf("Determining model!\n"); 105 if (!ppBackgroundStackModelFit(data)) { 106 psError(psErrorCodeLast(), false, "Error determining the modelMap object."); 107 return(false); 108 } 109 } // End loop 110 111 // Loop over the input images, and apply the models to construct the restored versions. 112 113 for (i = 0; i < data->stack_data->n; i++) { 114 pmFPAfile *stack = data->stack_data->data[i]; 115 pmFPAview *view = pmFPAviewAlloc(0); 116 169 170 // This is where an iterative solution loop would likely start. 171 { 172 // Construct the offset information 173 printf("Model fit!\n"); 174 if (!ppBackgroundStackDataModelFit(data)) { 175 psError(psErrorCodeLast(), false, "Error determining the exposure/OTA scaling."); 176 return(false); 177 } 178 179 // Apply full correction 180 printf("Calib apply!\n"); 181 if (!ppBackgroundStackCalibApply(data)) { 182 psError(psErrorCodeLast(), false, "Error applying the calibration models."); 183 return(false); 184 } 185 186 // Fit the new model 187 printf("Determining model!\n"); 188 if (!ppBackgroundStackModelFit(data)) { 189 psError(psErrorCodeLast(), false, "Error determining the modelMap object."); 190 return(false); 191 } 192 } // End loop 193 194 // PART 3: 195 // Define output products 117 196 // Define output image. Why is this always so hard to do? 118 197 pmFPA *tmp_fpa1,*tmp_fpa2; 119 198 tmp_fpa1 = pmFPAConstruct(config->camera,config->cameraName); 120 199 tmp_fpa2 = pmFPAConstruct(config->camera,config->cameraName); 121 200 122 201 pmFPAfile *stack_model = pmFPAfileDefineOutput(config,tmp_fpa1,"PPBACKGROUND.STACK.MODEL"); 123 202 … … 134 213 stack_model->save = true; 135 214 stack_corr->save = true; 136 215 137 216 printf("I'm about to loop over the parts of this stack: %d\n",i); 138 217 // Iterate over the images. … … 144 223 return(false); 145 224 } 146 147 225 148 226 pmChip *chip; … … 151 229 continue; 152 230 } 153 231 154 232 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 155 233 psError(psErrorCodeLast(), false, "load failure for Chip"); … … 256 334 } 257 335 psFree(view); 258 } 336 psFree(data->modelMap); 337 } 259 338 260 339
Note:
See TracChangeset
for help on using the changeset viewer.
