Changeset 28125 for trunk/ppSim
- Timestamp:
- May 26, 2010, 4:31:49 PM (16 years ago)
- Location:
- trunk/ppSim/src
- Files:
-
- 1 added
- 4 edited
-
Makefile.am (modified) (1 diff)
-
ppSim.h (modified) (1 diff)
-
ppSimInsertStars.c (modified) (2 diffs)
-
ppSimLoop.c (modified) (2 diffs)
-
ppSimSmoothReadout.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/Makefile.am
r26900 r28125 43 43 ppSimBounds.c \ 44 44 ppSimStars.c \ 45 ppSimSmoothReadout.c \ 45 46 ppSimSetPSF.c \ 46 47 ppSimUtils.c \ -
trunk/ppSim/src/ppSim.h
r26900 r28125 106 106 bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config); 107 107 108 bool ppSimSmoothReadout(pmReadout *input, psMetadata *recipe); 109 108 110 bool ppSimInitHeader(pmConfig *config, 109 111 pmFPA *fpa, -
trunk/ppSim/src/ppSimInsertStars.c
r27657 r28125 23 23 // XXX this is missing the gain. 24 24 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe 25 26 bool psfConvolve = psMetadataLookupBool(NULL, recipe, "PSF.CONVOLVE"); // smooth the image with the PSF? 25 27 26 28 float expTime = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time … … 103 105 float flux = star->flux * expCorr->data.F32[(int)yCell][(int)xCell]; 104 106 105 // instantiate a model for the PSF at this location, set desired flux 106 pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0); 107 pmModelSetFlux (model, flux); 107 // if psfConvolve is TRUE, we will (elsewhere) convolve the image we a PSF 108 // in this case, simply place delta functions in the image 109 if (psfConvolve) { 110 readout->image->data.F32[(int)(yCell)][(int)(xCell)] = flux; 111 continue; 112 } 108 113 109 float radius = model->modelRadius (model->params, nSigmaLim * roughNoise); 110 radius = PS_MAX (radius, 1.0); 114 // instantiate a model for the PSF at this location, set desired flux 115 pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0); 116 pmModelSetFlux (model, flux); 111 117 112 // construct a source, with model flux pixels set, based on the model 113 pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);118 float radius = model->modelRadius (model->params, nSigmaLim * roughNoise); 119 radius = PS_MAX (radius, 1.0); 114 120 115 // XXX set the mag & err values (should this be done in pmSourceFromModel?) 116 // XXX i should be applying the gain and the correct effective area 117 psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0); 118 psF64 Area = 2.0 * M_PI * axes.major * axes.minor; 121 // construct a source, with model flux pixels set, based on the model 122 pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR); 119 123 120 // this value is the pure (input) flux, and is saved in the output source cmf files 121 source->psfMag = -2.5*log10(star->flux); 122 source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux; 124 // XXX set the mag & err values (should this be done in pmSourceFromModel?) 125 // XXX i should be applying the gain and the correct effective area 126 psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0); 127 psF64 Area = 2.0 * M_PI * axes.major * axes.minor; 123 128 124 fprintf (outfile, "%8.3f %8.3f %10.2f %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag); 129 // this value is the pure (input) flux, and is saved in the output source cmf files 130 source->psfMag = -2.5*log10(star->flux); 131 source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux; 125 132 126 // insert the source flux in the image 127 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY); 133 fprintf (outfile, "%8.3f %8.3f %10.2f %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag); 128 134 129 // insert the source flux in the noise image130 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);135 // insert the source flux in the image 136 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY); 131 137 132 // Blow away the image parts of the source, which makes the memory explode 133 RESET(source->pixels); 134 RESET(source->variance); 135 RESET(source->maskObj); 136 RESET(source->maskView); 137 RESET(source->modelFlux); 138 RESET(source->psfImage); 139 RESET(source->blends); 138 // insert the source flux in the noise image 139 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY); 140 140 141 // add the sources to the source array 142 psArrayAdd (sources, 100,source); 143 psFree(source); // Drop reference 141 // Blow away the image parts of the source, which makes the memory explode 142 RESET(source->pixels); 143 RESET(source->variance); 144 RESET(source->maskObj); 145 RESET(source->maskView); 146 RESET(source->modelFlux); 147 RESET(source->psfImage); 148 RESET(source->blends); 149 150 // add the sources to the source array 151 psArrayAdd (sources, 100,source); 152 psFree(source); // Drop reference 144 153 } 145 154 fclose (outfile); -
trunk/ppSim/src/ppSimLoop.c
r26900 r28125 30 30 ppSimType type = ppSimTypeFromString (typeStr); // Type of image to simulate 31 31 int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y 32 33 bool psfConvolve = psMetadataLookupBool(NULL, recipe, "PSF.CONVOLVE"); // smooth the image with the PSF? 32 34 33 35 ppSimUpdateConceptsFPA (fpa, config); … … 155 157 psFree(expCorr); 156 158 159 // we have two options for generating images which have a PSF: 160 // 1) lay down stars with the PSF model applied : in this case, galaxies do NOT have the PSF 161 // 2) lay down delta functions for stars and smooth the image with a PSF : in this case, the stars land at integer pixel locations 162 if (psfConvolve) { 163 if (!ppSimSmoothReadout(readout, recipe)) ESCAPE (PS_ERR_UNKNOWN, "problem smoothing image"); 164 } 165 157 166 done: 158 167 if (!ppSimAddNoise(readout->image, readout->variance, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
Note:
See TracChangeset
for help on using the changeset viewer.
