Changeset 25626 for branches/eam_branches/20090715/psModules/src/imcombine
- Timestamp:
- Sep 27, 2009, 11:36:17 AM (17 years ago)
- Location:
- branches/eam_branches/20090715/psModules/src/imcombine
- Files:
-
- 3 edited
-
pmPSFEnvelope.c (modified) (5 diffs)
-
pmStackReject.c (modified) (6 diffs)
-
pmSubtractionMatch.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psModules/src/imcombine/pmPSFEnvelope.c
r25496 r25626 34 34 35 35 // #define TESTING // Enable test output 36 // #define PEAK_NORM // Normalise peaks? 36 37 #define PEAK_FLUX 1.0e4 // Peak flux for each source 37 38 #define SKY_VALUE 0.0e0 // Sky value for fake image … … 122 123 continue; 123 124 } 125 126 if (psTraceGetLevel("psModules.imcombine") >= 1) { 127 psString string = NULL; // String with values 128 psStringAppend(&string, "PSF %d: ", i); 129 float x = numCols / 2.0, y = numRows / 2.0; // Coordinates of interest 130 for (int j = 4; j < psf->params->n; j++) { 131 pmTrend2D *trend = psf->params->data[j]; // Trend of interest 132 double val = pmTrend2DEval(trend, x, y); 133 double err; 134 switch (trend->mode) { 135 case PM_TREND_POLY_ORD: 136 case PM_TREND_POLY_CHEB: 137 err = NAN; 138 break; 139 case PM_TREND_MAP: 140 err = psImageUnbinPixel(x, y, trend->map->error, trend->map->binning); 141 break; 142 default: 143 psAbort("Unsupported mode: %x", trend->mode); 144 } 145 psStringAppend(&string, "%lf %lf ", val, err); 146 } 147 psTrace("psModules.imcombine", 1, "%s\n", string); 148 psFree(string); 149 } 150 124 151 pmResiduals *resid = psf->residuals;// PSF residuals 125 152 psf->residuals = NULL; … … 144 171 float y = source->peak->yf + yOffset->data.S32[j]; // y coordinate of source 145 172 146 double flux = fakeRO->image->data.F32[(int)y][(int)x]; 173 #ifdef PEAK_NORM 174 // Perhaps I'm being paranoid, but specify a range to check 175 int uMax = PS_MIN(x + radius, numCols - 1), uMin = PS_MAX(x - radius, 0); 176 int vMax = PS_MIN(y + radius, numRows - 1), vMin = PS_MAX(y - radius, 0); 177 178 double flux = -INFINITY; // Peak flux 179 for (int v = vMin; v <= vMax; v++) { 180 for (int u = uMin; u <= uMax; u++) { 181 if (fakeRO->image->data.F32[v][u] > flux) { 182 flux = fakeRO->image->data.F32[v][u]; 183 } 184 } 185 } 147 186 if (!isfinite(flux) || flux < 0) { 148 187 continue; 149 188 } 150 189 float norm = PEAK_FLUX / flux; // Normalisation for source 190 #endif 151 191 psRegion region = psRegionSet(x - radius, x + radius, y - radius, y + radius); // PSF region 152 192 psImage *subImage = psImageSubset(fakeRO->image, region); // Subimage of fake PSF 153 193 psImage *subEnv = psImageSubset(envelope, region); // Subimage of envelope 194 #ifdef PEAK_NORM 154 195 psBinaryOp(subImage, subImage, "*", psScalarAlloc(norm, PS_TYPE_F32)); 196 #endif 155 197 psBinaryOp(subEnv, subEnv, "MAX", subImage); 156 198 psFree(subImage); … … 345 387 psFree(try); 346 388 389 if (psTraceGetLevel("psModules.imcombine") >= 1) { 390 psString string = NULL; // String with values 391 psStringAppend(&string, "Envelope PSF: "); 392 float x = numCols / 2.0, y = numRows / 2.0; // Coordinates of interest 393 for (int j = 4; j < psf->params->n; j++) { 394 pmTrend2D *trend = psf->params->data[j]; // Trend of interest 395 double val = pmTrend2DEval(trend, x, y); 396 double err; 397 switch (trend->mode) { 398 case PM_TREND_POLY_ORD: 399 case PM_TREND_POLY_CHEB: 400 err = NAN; 401 break; 402 case PM_TREND_MAP: 403 err = psImageUnbinPixel(x, y, trend->map->error, trend->map->binning); 404 break; 405 default: 406 psAbort("Unsupported mode: %x", trend->mode); 407 } 408 psStringAppend(&string, "%lf %lf ", val, err); 409 } 410 psTrace("psModules.imcombine", 1, "%s\n", string); 411 psFree(string); 412 } 413 347 414 #ifdef TESTING 348 415 { … … 358 425 359 426 pmReadout *generated = pmReadoutAlloc(NULL); // Generated image 360 pmReadoutFakeFromSources(generated, numCols, numRows, fakes, NULL, NULL, psf, NAN, radius,427 pmReadoutFakeFromSources(generated, numCols, numRows, fakes, 0, NULL, NULL, psf, NAN, radius, 361 428 false, true); 362 429 { -
branches/eam_branches/20090715/psModules/src/imcombine/pmStackReject.c
r21351 r25626 43 43 if (box > 0) { 44 44 // Convolve a subimage, then stick it in the target 45 // XXX if (threaded) {46 // XXX psMutexLock(source);47 // XXX }48 45 psImage *mask = psImageSubset(source, psRegionSet(xMin - box, xMax + box, 49 46 yMin - box, yMax + box)); // Mask to convolve 50 // XXX if (threaded) {51 // XXX psMutexUnlock(source);52 // XXX }53 47 psImage *convolved = psImageConvolveMask(NULL, mask, PM_STACK_MASK_BAD, PM_STACK_MASK_CONVOLVE, 54 48 -box, box, -box, box); // Convolved mask 55 // XXX if (threaded) {56 // XXX psMutexLock(source);57 // XXX }58 49 psFree(mask); 59 // XXX if (threaded) {60 // XXX psMutexUnlock(source);61 // XXX }62 50 63 51 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy … … 162 150 pmReadout *inRO = pmReadoutAlloc(NULL); // Readout with input image 163 151 inRO->image = image; 164 // XXX if (threaded) {165 // XXX psMutexInit(image);166 // XXX }167 152 for (int i = 0; i < numRegions; i++) { 168 153 psRegion *region = subRegions->data[i]; // Region of interest 169 154 pmSubtractionKernels *kernels = subKernels->data[i]; // Kernel of interest 170 if (!pmSubtractionConvolve( convRO, NULL, inRO, NULL, NULL, stride, 0, 0, 1.0, 0.0,155 if (!pmSubtractionConvolve(NULL, convRO, NULL, inRO, NULL, stride, 0, 0, 1.0, 0.0, 171 156 region, kernels, false, true)) { 172 157 psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i); … … 211 196 } 212 197 } 213 // XXX if (threaded) {214 // XXX psMutexDestroy(image);215 // XXX }216 198 psFree(inRO); 217 199 psImage *convolved = psMemIncrRefCounter(convRO->image); … … 264 246 psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image 265 247 psImageInit(target, 0); 266 // XXX if (threaded) {267 // XXX psMutexInit(source);268 // XXX }269 248 for (int i = 0; i < subRegions->n; i++) { 270 249 psRegion *region = subRegions->data[i]; // Subtraction region … … 287 266 psArray *args = job->args; // Job arguments 288 267 psArrayAdd(args, 1, target); 289 // XXX psMutexLock(source);290 268 psArrayAdd(args, 1, source); 291 // XXX psMutexUnlock(source);292 269 psArrayAdd(args, 1, kernels); 293 270 PS_ARRAY_ADD_SCALAR(args, numCols, PS_TYPE_S32); … … 332 309 } 333 310 334 // XXX psMutexDestroy(source);335 311 } 336 312 -
branches/eam_branches/20090715/psModules/src/imcombine/pmSubtractionMatch.c
r25407 r25626 628 628 variance = NULL; 629 629 630 if (!pmSubtractionBorder(conv1->image, conv1->variance, conv1->mask, size, maskBad)) { 630 if (conv1 && !pmSubtractionBorder(conv1->image, conv1->variance, conv1->mask, size, maskBad)) { 631 psError(PS_ERR_UNKNOWN, false, "Unable to set border of convolved image."); 632 goto MATCH_ERROR; 633 } 634 if (conv2 && !pmSubtractionBorder(conv2->image, conv2->variance, conv2->mask, size, maskBad)) { 631 635 psError(PS_ERR_UNKNOWN, false, "Unable to set border of convolved image."); 632 636 goto MATCH_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
