Changeset 27665
- Timestamp:
- Apr 12, 2010, 12:54:19 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c
r26405 r27665 75 75 psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position 76 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 }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 } 82 82 if (sources) { 83 83 psMemIncrRefCounter(sources); 84 84 psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources", sources->n); 85 85 } 86 if (data->fakeNum > 0 && isfinite(data->fakeMag)) {87 long numOld = 0; // Old number of sources88 long numNew = -1; // New number of sources89 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 }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 99 100 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator100 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 101 101 102 for (int i = numOld; i < numNew; i++) {103 pmSource *source = pmSourceAlloc(); // Fake source104 sources->data[i] = source;105 float xSrc = psRandomUniform(rng) * numCols, ySrc = psRandomUniform(rng) * numRows; // Position of source102 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 106 107 pmModel *model = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation108 float fluxNorm = model->modelFlux(model->params); // Flux for peak=1109 float fluxPeak = powf(10.0, -0.4 * data->fakeMag) / fluxNorm; // Peak flux110 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 PSF107 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 117 117 sources = psArrayAlloc(1); 118 118 pmSource *source = pmSourceAlloc(); // Fake source … … 134 134 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image with single PSF", 135 135 numCols, numRows); 136 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); 137 *trimsec = psRegionSet(0, numCols, 0, numRows); 136 138 } 137 139
Note:
See TracChangeset
for help on using the changeset viewer.
