Changeset 26405 for trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c
- Timestamp:
- Dec 15, 2009, 1:45:56 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c
r26367 r26405 74 74 int numCols = 0, numRows = 0; // Size of image 75 75 psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position 76 77 if (sources || (data->fakeNum > 0 && isfinite(data->fakeMag))) { 78 numCols = psf->fieldNx; 79 numRows = psf->fieldNy; 80 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image", numCols, numRows); 81 } 76 82 if (sources) { 77 83 psMemIncrRefCounter(sources); 78 numCols = psf->fieldNx; 79 numRows = psf->fieldNy; 80 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image from %ld input sources", 81 numCols, numRows, sources->n); 82 } else { 84 psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources", sources->n); 85 } 86 if (data->fakeNum > 0 && isfinite(data->fakeMag)) { 87 long numOld = 0; // Old number of sources 88 long numNew = -1; // New number of sources 89 psLogMsg("ppVizPSF", PS_LOG_INFO, "Adding %d fake sources", data->fakeNum); 90 if (sources) { 91 numOld = sources->n; 92 numNew = numOld + data->fakeNum; 93 sources = psArrayRealloc(sources, numNew); 94 sources->n = numNew; 95 } else { 96 numNew = data->fakeNum; 97 sources = psArrayAlloc(numNew); 98 } 99 100 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 101 102 for (int i = numOld; i < numNew; i++) { 103 pmSource *source = pmSourceAlloc(); // Fake source 104 sources->data[i] = source; 105 float xSrc = psRandomUniform(rng) * numCols, ySrc = psRandomUniform(rng) * numRows; // Position of source 106 107 pmModel *model = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation 108 float fluxNorm = model->modelFlux(model->params); // Flux for peak=1 109 float fluxPeak = powf(10.0, -0.4 * data->fakeMag) / fluxNorm; // Peak flux 110 source->peak = pmPeakAlloc(xSrc, ySrc, fluxPeak, PM_PEAK_LONE); 111 source->psfMag = data->fakeMag; 112 psFree(model); 113 } 114 } 115 if (!sources) { 116 // Generate fake image with only a single realisation of the PSF 83 117 sources = psArrayAlloc(1); 84 118 pmSource *source = pmSourceAlloc(); // Fake source
Note:
See TracChangeset
for help on using the changeset viewer.
