Changeset 12611
- Timestamp:
- Mar 27, 2007, 2:58:39 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotImageMedian.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotImageMedian.c
r12600 r12611 1 1 # include "psphot.h" 2 // # define TESTSAVE 2 static int npass = 0; 3 3 4 4 // generate the median in NxN boxes, clipping heavily … … 277 277 } 278 278 279 # ifdef TESTSAVE 280 psphotSaveImage (NULL, image, "image.fits"); 281 psphotSaveImage (NULL, background->image, "back.fits"); 282 psphotSaveImage (NULL, mask, "mask.fits"); 283 psphotSaveImage (NULL, model->image, "backmdl.fits"); 284 # endif 279 if (psTraceGetLevel("psphot") > 5) { 280 char name[256]; 281 sprintf (name, "image.%02d.fits", npass); 282 psphotSaveImage (NULL, image, name); 283 sprintf (name, "back.%02d.fits", npass); 284 psphotSaveImage (NULL, background->image, name); 285 sprintf (name, "mask.%02d.fits", npass); 286 psphotSaveImage (NULL, mask, name); 287 sprintf (name, "backmdl.%02d.fits", npass); 288 psphotSaveImage (NULL, model->image, name); 289 } 285 290 286 291 // subtract the background model (save in backSub, if requested) … … 294 299 } 295 300 296 # ifdef TESTSAVE 297 psphotSaveImage (NULL, image, "backsub.fits"); 298 exit (1); 299 # endif 301 if (psTraceGetLevel("psphot") > 5) { 302 char name[256]; 303 sprintf (name, "backsub.%02d.fits", npass); 304 psphotSaveImage (NULL, image, name); 305 } 306 npass ++; 300 307 301 308 psLogMsg ("psphot", PS_LOG_INFO, "subtracted background model: %f sec\n", psTimerMark ("psphot")); … … 308 315 return true; 309 316 } 310 311 312 # if (0)313 314 // dimensions of input & output image315 int Nx = image->numCols;316 int Ny = image->numRows;317 318 // scaling factor319 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");320 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");321 322 // overhang : we will balance this evenly323 int xExtra = (Nx % DX) / 2;324 int yExtra = (Ny % DY) / 2;325 int xOffset = (xExtra > 0) ? DX - xExtra : 0;326 int yOffset = (yExtra > 0) ? DY - yExtra : 0;327 xOffset -= image->col0;328 yOffset -= image->row0;329 330 // dimensions of binned image331 int nx, ny;332 if (Nx % DX == 0) {333 nx = Nx / DX;334 } else {335 nx = (xExtra) ? (Nx / DX) + 2 : (Nx / DX) + 1;336 }337 if (Ny % DY == 0) {338 ny = Ny / DY;339 } else {340 ny = (yExtra) ? (Ny / DY) + 2 : (Ny / DY) + 1;341 }342 343 // we have 4 possibilities: (INTERNAL or I/O file) and (exists or not)344 // select model pixels (from output background model file, or create internal file)345 file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL");346 if (file == NULL) {347 // we are not using PSPHOT.BACKMDL as an I/O file: define an internal version348 model = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKMDL", nx, ny, PS_TYPE_F32);349 } else {350 if (file->mode == PM_FPA_MODE_INTERNAL) {351 // we are not using PSPHOT.BACKMDL as an I/O file: already defined above352 model = file->readout;353 } else {354 // we are using PSPHOT.BACKMDL as an I/O file: select readout or create355 model = pmFPAviewThisReadout (view, file->fpa);356 if (model == NULL) {357 // readout does not yet exist: create from input358 // XXX we have an inconsistency in this calculation here and in pmFPACopy359 pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view);360 model = pmFPAviewThisReadout (view, file->fpa);361 if ((nx != model->image->numCols) || (ny != model->image->numRows)) {362 psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for model dimensions");363 return false;364 }365 }366 }367 }368 psF32 **modelData = model->image->data.F32;369 370 371 372 // sx, sy are in parent coords373 int sx = ix*DX - xOffset;374 int sy = iy*DY - yOffset;375 region = psRegionSet (sx, sx + 2*DX, sy, sy + 2*DY);376 377 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
