Changeset 15814
- Timestamp:
- Dec 13, 2007, 12:09:35 PM (18 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 4 edited
-
imcombine/Makefile.am (modified) (2 diffs)
-
imcombine/pmPSFEnvelope.c (modified) (10 diffs)
-
objects/pmSource.c (modified) (5 diffs)
-
psmodules.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/Makefile.am
r15756 r15814 14 14 pmSubtractionMatch.c \ 15 15 pmSubtractionParams.c \ 16 pmSubtractionStamps.c \17 pmPSFEnvelope.c16 pmSubtractionStamps.c 17 # pmPSFEnvelope.c 18 18 19 19 pkginclude_HEADERS = \ … … 28 28 pmSubtractionMatch.h \ 29 29 pmSubtractionParams.h \ 30 pmSubtractionStamps.h \31 pmPSFEnvelope.h30 pmSubtractionStamps.h 31 # pmPSFEnvelope.h 32 32 33 33 CLEANFILES = *~ -
trunk/psModules/src/imcombine/pmPSFEnvelope.c
r15764 r15814 72 72 float xOrigSpacing = (float)(numCols - 2 * radius) / (float)(instances - 1); // Spacing between instances 73 73 float yOrigSpacing = (float)(numRows - 2 * radius) / (float)(instances - 1); // Spacing between instances 74 //int fakeSpacing = 2 * radius + 1; // Spacing between instances (x and y) in the fake image75 //int fakeSize = instances * fakeSpacing; // Size of fake image74 int fakeSpacing = 2 * radius + 1; // Spacing between instances (x and y) in the fake image 75 int fakeSize = instances * fakeSpacing; // Size of fake image 76 76 77 77 // Generate list of fake sources (instances of the PSF) … … 82 82 for (int j = 0, index = 0; j < instances; j++) { 83 83 float yOrig = j * yOrigSpacing + radius; // Source position in original image 84 //float yFake = j * fakeSpacing + radius; // Position in fake image85 //int dy = yFake - yOrig; // Difference between fake and original position84 float yFake = j * fakeSpacing + radius; // Position in fake image 85 int dy = yFake - yOrig; // Difference between fake and original position 86 86 87 87 for (int i = 0; i < instances; i++, index++) { 88 88 float xOrig = i * xOrigSpacing + radius; // Source position in original image 89 //float xFake = i * fakeSpacing + radius; // Position in fake image90 //int dx = xFake - xOrig; // Difference between fake and original position89 float xFake = i * fakeSpacing + radius; // Position in fake image 90 int dx = xFake - xOrig; // Difference between fake and original position 91 91 92 92 pmSource *fake = pmSourceAlloc(); // Fake source 93 // fake->peak = pmPeakAlloc(xFake - dx, yFake - dy, PEAK_FLUX, PM_PEAK_LONE); 94 fake->peak = pmPeakAlloc(xOrig, yOrig, PEAK_FLUX, PM_PEAK_LONE); 93 fake->peak = pmPeakAlloc(xFake - dx, yFake - dy, PEAK_FLUX, PM_PEAK_LONE); 95 94 fake->type = PM_SOURCE_TYPE_STAR; 96 95 … … 104 103 105 104 fakes->data[index] = fake; 106 xOffset->data.S32[index] = 0; //dx;107 yOffset->data.S32[index] = 0; //dy;105 xOffset->data.S32[index] = dx; 106 yOffset->data.S32[index] = dy; 108 107 } 109 108 } 110 109 111 110 // Generate fake images with each PSF, and take the envelope 112 psImage *envelope = psImageAlloc( numCols, numRows, PS_TYPE_F32); // Image with envelope of PSFs111 psImage *envelope = psImageAlloc(fakeSize, fakeSize, PS_TYPE_F32); // Image with envelope of PSFs 113 112 psImageInit(envelope, 0.0); 114 113 pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout 115 114 for (int i = 0; i < inputs->n; i++) { 116 115 pmPSF *psf = inputs->data[i]; // PSF of interest 117 if (!pmReadoutFakeFromSources(fakeRO, numCols, numRows, fakes, xOffset, yOffset, psf, 118 NAN, radius)) { 116 pmResiduals *resid = psf->residuals;// PSF residuals 117 psf->residuals = NULL; 118 if (!pmReadoutFakeFromSources(fakeRO, fakeSize, fakeSize, fakes, xOffset, yOffset, psf, 119 NAN, radius, true)) { 119 120 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake readout."); 120 121 psFree(envelope); … … 122 123 psFree(xOffset); 123 124 psFree(fakes); 125 psf->residuals = resid; 124 126 return NULL; 125 127 } 128 psf->residuals = resid; 126 129 127 130 // Need to renormalise sources so they all have the same peak. You would think they do have the same … … 159 162 } 160 163 164 165 161 166 #ifdef TESTING 162 167 { … … 183 188 #endif 184 189 185 // Reset the fake source pixels to the envelope pixels190 // Put the fake sources onto a full-size image 186 191 pmReadout *readout = pmReadoutAlloc(NULL); // Readout to contain envelope pixels 187 readout->image = envelope; 188 readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); 189 psImageInit(readout->weight, WEIGHT_VAL); 192 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 193 psImageInit(readout->image, 0.0); 194 for (int i = 0; i < numFakes; i++) { 195 pmSource *source = fakes->data[i]; // Fake source 196 // Position of source on fake image 197 int xFake = source->peak->x + xOffset->data.S32[i]; 198 int yFake = source->peak->y + yOffset->data.S32[i]; 199 psRegion region = psRegionSet(xFake - radius, xFake + radius, 200 yFake - radius, yFake + radius); // PSF region 201 psImage *subImage = psImageSubset(envelope, region); // Subimage of fake PSF 202 203 // Position of source on "real" image 204 int x0 = source->peak->x - radius; 205 int y0 = source->peak->y - radius; 206 207 if (!psImageOverlaySection(readout->image, subImage, x0, y0, "=")) { 208 psError(PS_ERR_UNKNOWN, false, "Unable to overlay PSF"); 209 psFree(readout); 210 psFree(xOffset); 211 psFree(yOffset); 212 psFree(fakes); 213 return NULL; 214 } 215 } 216 readout->weight = (psImage*)psBinaryOp(NULL, readout->image, "+", psScalarAlloc(1.0, PS_TYPE_F32)); 190 217 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); 191 218 psImageInit(readout->mask, 0); 192 219 220 #ifdef TESTING 221 { 222 // Write out the envelope 223 psFits *fits = psFitsOpen("psf_field_full.fits", "w"); 224 psFitsWriteImage(fits, NULL, readout->image, 0, NULL); 225 psFitsClose(fits); 226 } 227 #endif 228 193 229 for (int i = 0; i < numFakes; i++) { 194 230 pmSource *source = fakes->data[i]; // Fake source 195 float x = source->peak->xf + xOffset->data.S32[i]; // x coordinates of source 196 float y = source->peak->yf + yOffset->data.S32[i]; // y coordinates of source 231 float x = source->peak->xf;// + xOffset->data.S32[i]; // x coordinates of source 232 float y = source->peak->yf;// + yOffset->data.S32[i]; // y coordinates of source 233 234 psFree(source->pixels); 235 psFree(source->weight); 236 psFree(source->maskView); 237 psFree(source->maskObj); 238 source->pixels = NULL; 239 source->weight = NULL; 240 source->maskView = NULL; 241 source->maskObj = NULL; 197 242 198 243 if (!pmSourceDefinePixels(source, readout, x, y, (float)radius)) { … … 205 250 } 206 251 252 #if 0 253 // Need to do some magic so that pmSourceMoments behaves --- the only offsets it understands are the 254 // col0,row0 in the psImage. 255 int oldCol0 = source->pixels->col0; 256 int oldRow0 = source->pixels->row0; 257 int col0 = oldCol0 - xOffset->data.S32[i]; 258 int row0 = oldRow0 - yOffset->data.S32[i]; 259 260 P_PSIMAGE_SET_COL0(source->pixels, col0); 261 P_PSIMAGE_SET_ROW0(source->pixels, row0); 262 P_PSIMAGE_SET_COL0(source->weight, col0); 263 P_PSIMAGE_SET_ROW0(source->weight, row0); 264 P_PSIMAGE_SET_COL0(source->maskObj, col0); 265 P_PSIMAGE_SET_ROW0(source->maskObj, row0); 266 #endif 267 207 268 if (!pmSourceMoments(source, radius)) { 208 269 psError(PS_ERR_UNKNOWN, false, "Unable to measure moments for source."); … … 213 274 return NULL; 214 275 } 215 } 276 277 #if 0 278 P_PSIMAGE_SET_COL0(source->pixels, oldCol0); 279 P_PSIMAGE_SET_ROW0(source->pixels, oldRow0); 280 P_PSIMAGE_SET_COL0(source->weight, oldCol0); 281 P_PSIMAGE_SET_ROW0(source->weight, oldRow0); 282 P_PSIMAGE_SET_COL0(source->maskObj, oldCol0); 283 P_PSIMAGE_SET_ROW0(source->maskObj, oldRow0); 284 #endif 285 } 286 287 psMemCheckCorruption(stderr, true); 288 216 289 217 290 pmPSFOptions *options = pmPSFOptionsAlloc(); // Options for fitting a PSF … … 224 297 options->radius = radius; 225 298 226 options->psfTrendMode = PM_TREND_ POLY_ORD;299 options->psfTrendMode = PM_TREND_MAP; 227 300 options->psfTrendNx = 1; 228 301 options->psfTrendNy = 1; … … 261 334 262 335 pmReadout *generated = pmReadoutAlloc(NULL); // Generated image 263 pmReadoutFakeFromSources(generated, numCols, numRows, fakes, xOffset, yOffset, psf, NAN, radius); 336 pmReadoutFakeFromSources(generated, numCols, numRows, fakes, xOffset, yOffset, psf, NAN, radius, 337 false); 264 338 { 265 339 psFits *fits = psFitsOpen("psf_field_model.fits", "w"); -
trunk/psModules/src/objects/pmSource.c
r15811 r15814 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-12-13 2 1:45:08$8 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-12-13 22:09:35 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 703 703 if (*vMsk) { 704 704 vMsk++; 705 psTrace("psModules.objects", 10, "Ignoring pixel %d,%d due to mask: %d\n", 706 col, row, (int)*vMsk); 705 707 continue; 706 708 } … … 713 715 // radius is just a function of (xDiff, yDiff) 714 716 if (!VALID_RADIUS(xDiff, yDiff, R2)) { 717 #if 1 718 psTrace("psModules.objects", 10, "Ignoring pixel %d,%d due to position: %f %f\n", 719 col, row, xDiff, yDiff); 720 #endif 715 721 continue; 716 722 } … … 722 728 // XXX EAM : should this limit be user-defined? 723 729 if (PS_SQR(pDiff) < wDiff) { 730 #if 1 731 psTrace("psModules.objects", 10, "Ignoring pixel %d,%d due to insignificance: %f, %f\n", 732 col, row, pDiff, wDiff); 733 #endif 724 734 continue; 725 735 } … … 746 756 // XXX EAM - the limit is a bit arbitrary. make it user defined? 747 757 if ((numPixels < 0.75*R2) || (Sum <= 0)) { 748 psTrace ("psModules.objects", 3, "no valid pixels for source\n"); 758 psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n", 759 numPixels, (int)(0.75*R2), Sum); 749 760 psTrace("psModules.objects", 5, "---- end (false) ----\n"); 750 761 return (false); -
trunk/psModules/src/psmodules.h
r15756 r15814 110 110 // The following headers are from random locations, here because they cross bounds 111 111 #include <pmReadoutFake.h> 112 //#include <pmPSFEnvelope.h> 112 113 113 114 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
