Changeset 28125 for trunk/ppSim/src/ppSimInsertStars.c
- Timestamp:
- May 26, 2010, 4:31:49 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimInsertStars.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.
