Changeset 26405
- Timestamp:
- Dec 15, 2009, 1:45:56 AM (16 years ago)
- Location:
- trunk/ppViz/src/ppVizPSF
- Files:
-
- 4 edited
-
ppVizPSF.h (modified) (1 diff)
-
ppVizPSFArguments.c (modified) (2 diffs)
-
ppVizPSFData.c (modified) (1 diff)
-
ppVizPSFLoop.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppVizPSF/ppVizPSF.h
r26367 r26405 11 11 psString psfName; // Filename with PSF 12 12 psString sourcesName; // Filename with sources 13 int fakeNum; // Number of fake sources 14 float fakeMag; // Magnitude of fake sources 13 15 psString outRoot; // Output root name 14 16 float minFlux; // Minimum flux for sources -
trunk/ppViz/src/ppVizPSF/ppVizPSFArguments.c
r26367 r26405 49 49 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments 50 50 psMetadataAddStr(arguments, PS_LIST_TAIL, "-psf", 0, "Filename of PSF", NULL); 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-sources", 0, "Filename of sources", NULL); 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-sources", 0, "Filename of CMF sources", NULL); 52 psMetadataAddS32(arguments, PS_LIST_TAIL, "-fake-num", 0, "Number of fake sources", 0); 53 psMetadataAddF32(arguments, PS_LIST_TAIL, "-fake-mag", 0, "Magnitude of fake sources", NAN); 52 54 psMetadataAddF32(arguments, PS_LIST_TAIL, "-x", 0, "x position of fake source [0..1]", NAN); 53 55 psMetadataAddF32(arguments, PS_LIST_TAIL, "-y", 0, "y position of fake source [0..1]", NAN); … … 59 61 data->psfName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-psf")); 60 62 data->sourcesName = psMemIncrRefCounter(psMetadataLookupStr(&mdok, arguments, "-sources")); 63 data->fakeNum = psMetadataLookupS32(NULL, arguments, "-fake-num"); 64 data->fakeMag = psMetadataLookupF32(NULL, arguments, "-fake-mag"); 61 65 data->outRoot = psStringCopy(argv[1]); 62 66 data->x = psMetadataLookupF32(NULL, arguments, "-x"); -
trunk/ppViz/src/ppVizPSF/ppVizPSFData.c
r26367 r26405 28 28 data->psfName = NULL; 29 29 data->sourcesName = NULL; 30 data->fakeNum = 0; 31 data->fakeMag = NAN; 30 32 data->outRoot = NULL; 31 33 data->config = NULL; -
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.
