Changeset 25246
- Timestamp:
- Sep 2, 2009, 9:58:54 AM (17 years ago)
- Location:
- branches/pap/psphot/src
- Files:
-
- 5 edited
-
Makefile.am (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotFake.c (modified) (10 diffs)
-
psphotOutput.c (modified) (1 diff)
-
psphotReadout.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psphot/src/Makefile.am
r24586 r25246 128 128 psphotCheckStarDistribution.c \ 129 129 psphotThreadTools.c \ 130 psphotAddNoise.c 130 psphotAddNoise.c \ 131 psphotFake.c 131 132 132 133 # dropped? psphotGrowthCurve.c -
branches/pap/psphot/src/psphot.h
r24890 r25246 76 76 bool psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe); 77 77 bool psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe); 78 bool psphotFake(pmReadout *readout, const pmPSF *psf, const psMetadata *recipe, const psArray *realSources); 78 79 79 80 // thread-related: -
branches/pap/psphot/src/psphotFake.c
r25230 r25246 20 20 float smoothNsigma, // Smoothing limit 21 21 psImageMaskType maskVal // Value to mask 22 ) ;22 ) 23 23 { 24 24 PM_ASSERT_READOUT_NON_NULL(ro, false); 25 25 PM_ASSERT_READOUT_VARIANCE(ro, false); 26 PS_ASSERT_METADATA_NON_NULL(recipe, false); 27 28 float smoothSigma = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrtf(2.0*log(2.0))); 26 27 float smoothSigma = 0.5*(xFWHM + yFWHM) / (2.0*sqrtf(2.0*log(2.0))); 29 28 psKernel *kernel = psImageSmoothKernel(smoothSigma, smoothNsigma); // Kernel used for smoothing 30 psKernel *newCovar = psImageCovarianceCalculate(kernel, r eadout->covariance); // Covariance matrix29 psKernel *newCovar = psImageCovarianceCalculate(kernel, ro->covariance); // Covariance matrix 31 30 psFree(kernel); 32 31 float factor = psImageCovarianceFactor(newCovar); // Variance factor … … 50 49 } 51 50 if (minFlux) { 52 int fudge = psMetadataLookupF32(NULL, recipe, "FAKE.MINFLUX"); // Fudge factor for minimum flux 53 *minFlux = sqrtf(meanVar) * fudge; 51 *minFlux = sqrtf(meanVar); 54 52 } 55 53 … … 60 58 static bool fakeGenerate(psImage **xSrc, psImage **ySrc, // Positions of sources 61 59 const pmReadout *ro, // Readout of interest 60 const pmPSF *psf, // Point-spread function 62 61 const psVector *magOffsets, // Magnitude offsets for fake sources 63 62 int numSources, // Number of fake sources for each bin … … 68 67 PM_ASSERT_READOUT_NON_NULL(ro, false); 69 68 PM_ASSERT_READOUT_IMAGE(ro, false); 70 PS_ASSERT_METADATA_NON_NULL(recipe, false);71 69 PS_ASSERT_VECTOR_NON_NULL(magOffsets, false); 72 70 PS_ASSERT_VECTOR_TYPE(magOffsets, PS_TYPE_F32, false); 73 71 74 int numBins = magOffset ->n;// Number of bins72 int numBins = magOffsets->n; // Number of bins 75 73 int numCols = ro->image->numCols, numRows = ro->image->numRows; // Size of image 76 74 … … 84 82 85 83 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 86 for (int i = 0; i <= numBins; i++) { 87 psArray *data = psArrayAlloc(3); // Sources for bin 88 89 psVector *x = psVectorAlloc(numSources, PS_TYPE_F32); 90 psVector *y = psVectorAlloc(numSources, PS_TYPE_F32); 91 92 float mag = refMag + magOffset->data.F32[i]; // Instrumental magnitude of sources 93 94 for (int j = 0; j <= numSources; j++) { 95 x->data.F32[j] = psRandomUniform(rng) * numCols; 96 y->data.F32[j] = psRandomUniform(rng) * numRows; 97 magAll->data.F32[i * numSources + j] = mag; 84 for (int i = 0, index = 0; i <= numBins; i++) { 85 float mag = refMag + magOffsets->data.F32[i]; // Instrumental magnitude of sources 86 87 for (int j = 0; j <= numSources; j++, index++) { 88 xAll->data.F32[index] = psRandomUniform(rng) * numCols; 89 yAll->data.F32[index] = psRandomUniform(rng) * numRows; 90 magAll->data.F32[index] = mag; 98 91 } 99 memcpy( xSrc->data.F32[i], x->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));100 memcpy(ySrc->data.F32[i], y->data.F32,numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));101 memcpy( &xAll->data.F32[i * numSources], x->data.F32, numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));102 memcpy(&yAll->data.F32[i * numSources], y->data.F32,numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32));92 memcpy((*xSrc)->data.F32[i], &xAll->data.F32[i * numSources], 93 numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32)); 94 memcpy((*ySrc)->data.F32[i], &yAll->data.F32[i * numSources], 95 numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32)); 103 96 } 104 97 psFree(rng); 105 98 106 pmReadout *fakeRO = pmReadoutAlloc( ); // Fake readout107 if (!pmReadoutFakeFromVectors(fakeRO, xAll, yAll, mag , NULL, NULL, psf, minFlux, NAN, false, false)) {99 pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout 100 if (!pmReadoutFakeFromVectors(fakeRO, xAll, yAll, magAll, NULL, NULL, psf, minFlux, NAN, false, false)) { 108 101 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image"); 109 102 psFree(fakeRO); … … 125 118 126 119 // *** in this section, perform the photometry for fake sources *** 127 bool psphotFake(pmConfig *config, pmReadout *readout, const pmPSF *psf, 128 const psMetadata *recipe, const psArray *realSources) 120 bool psphotFake(pmReadout *readout, const pmPSF *psf, const psMetadata *recipe, const psArray *realSources) 129 121 { 130 PS_ASSERT_PTR_NON_NULL(config, false);131 122 PM_ASSERT_READOUT_NON_NULL(readout, false); 132 123 PM_ASSERT_READOUT_IMAGE(readout, false); … … 138 129 139 130 // Collect recipe information 131 bool mdok; // Status of MD lookup 140 132 float xFWHM = psMetadataLookupF32(NULL, recipe, "FWHM_X"); // PSF size in x 141 133 float yFWHM = psMetadataLookupF32(NULL, recipe, "FWHM_Y"); // PSF size in y … … 155 147 } 156 148 psVector *magOffsets = psMetadataLookupVector(NULL, recipe, "FAKE.MAG"); // Magnitude offsets 157 if (!magOffset || magOffset->type.type != PS_TYPE_F32) {149 if (!magOffsets || magOffsets->type.type != PS_TYPE_F32) { 158 150 psError(PSPHOT_ERR_CONFIG, false, "Unable to find FAKE.MAG F32 vector in recipe"); 159 151 return NULL; … … 164 156 return NULL; 165 157 } 166 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Value to mask 167 158 float minFluxFudge = psMetadataLookupF32(&mdok, recipe, "FAKE.MINFLUX"); // Fudge factor for minimum flux 159 if (!mdok) { 160 minFluxFudge = 1.0; 161 } 162 163 psImageMaskType maskVal = psMetadataLookupImageMask(NULL, recipe, "MASK.PSPHOT"); // Value to mask 168 164 169 165 // remove all sources, adding noise for subtracted sources … … 177 173 return false; 178 174 } 175 minFlux *= minFluxFudge; 179 176 180 177 psImage *xFake = NULL, *yFake = NULL; // Coordinates of sources, each bin in a row 181 if (!fakeGenerate(&xFake, &yFake, readout, magOffsets, numSources, magLim, minFlux)) {178 if (!fakeGenerate(&xFake, &yFake, readout, psf, magOffsets, numSources, magLim, minFlux)) { 182 179 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake sources"); 183 180 psFree(xFake); -
branches/pap/psphot/src/psphotOutput.c
r21366 r25246 228 228 psMetadataItemSupplement (header, recipe, "MSKY_NY"); 229 229 230 // fake source recovery statistics 231 psMetadataItemSupplement(header, recipe, "FAKE.EFF"); 232 psMetadataItemSupplement(header, recipe, "FAKE.MAG"); 233 psMetadataItemSupplement(header, recipe, "FAKE.REF"); 234 230 235 psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout")); 231 236 -
branches/pap/psphot/src/psphotReadout.c
r24890 r25246 61 61 // display the backsub and backgnd images 62 62 psphotVisualShowBackground (config, view, readout); 63 63 64 64 // run a single-model test if desired (exits from here if test is run) 65 65 psphotModelTest (config, view, recipe); … … 224 224 psphotMagnitudes(config, readout, view, sources, psf); 225 225 226 if (!psphotFake(readout, psf, recipe, sources)) { 227 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources"); 228 psErrorClear(); 229 } 230 226 231 // replace failed sources? 227 232 // psphotReplaceUnfitSources (sources);
Note:
See TracChangeset
for help on using the changeset viewer.
