- Timestamp:
- Aug 19, 2007, 4:21:10 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c
r14531 r14547 1 1 # include "ppSim.h" 2 2 3 bool ppSimInsertSources (p sImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell) {3 bool ppSimInsertSources (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config) { 4 4 5 bool mdok;6 5 7 6 assert (stars); 8 7 8 pmCell *cell = readout->parent; 9 pmChip *chip = cell->parent; 10 11 // XXX we probably need this to get the size right 12 # if (0) 13 bool mdok; 9 14 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe 10 15 11 float seeing = psMetadataLookupF32(NULL, config->arguments, "SEEING"); // Seeing sigma (pix)12 16 float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time 13 17 float skyRate = psMetadataLookupF32(NULL, config->arguments, "SKY.RATE"); // Sky rate … … 23 27 } 24 28 29 // Rough noise estimate, appropriate for entire cell (use for source radius?) 30 float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime); 31 # endif 32 25 33 int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0"); 26 34 int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0"); … … 35 43 int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y 36 44 37 // Rough noise estimate, appropriate for entire cell38 float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);39 40 45 pmPSF *psf = psMetadataLookupPtr (NULL, chip->analysis, "PSF"); 41 46 47 int dX = PM_CELL_TO_CHIP (0.0, x0Cell, xParityCell, binning); 48 int dY = PM_CELL_TO_CHIP (0.0, y0Cell, yParityCell, binning); 49 50 // add sources to the readout image & weight 42 51 for (long i = 0; i < stars->n; i++) { 43 52 ppSimStar *star = stars->data[i]; 44 53 54 // star->x,y are in fpa coordinates 55 45 56 // Position on the cell and peak flux 46 float x = PPSIM_FPA_TO_CELL(star->x, x0Cell, xParityCell, binning, x0Chip, xParityChip);47 float y = PPSIM_FPA_TO_CELL(star->y, y0Cell, yParityCell, binning, y0Chip, yParityChip);57 float xChip = PM_FPA_TO_CHIP(star->x, x0Chip, xParityChip); 58 float yChip = PM_FPA_TO_CHIP(star->y, y0Chip, yParityChip); 48 59 49 // instantiate a model for the PSF at this location (normalized or not?) 50 // XXX 51 pmModel *model = pmModelFromPSFforXY (psf, star->x, star->y, star->flux); 60 // Position on the cell and peak flux 61 float xCell = PM_CHIP_TO_CELL(xChip, x0Cell, xParityCell, binning); 62 float yCell = PM_CHIP_TO_CELL(yChip, y0Cell, yParityCell, binning); 63 64 if (xCell < 0) continue; 65 if (yCell < 0) continue; 66 if (xCell > readout->image->numCols) continue; 67 if (yCell > readout->image->numRows) continue; 68 // XXX need to apply col0, row0 if readout is a subarray 69 70 // XXX apply the expCorr to the star->flux before setting the model flux 71 72 // instantiate a model for the PSF at this location, set desired flux 73 pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0); 74 pmModelSetFlux (model, star->flux); 52 75 53 76 // construct a source, with model flux pixels set, based on the model 54 pmSource *source = pmSourceFromModel (model );77 pmSource *source = pmSourceFromModel (model, readout, PM_SOURCE_TYPE_STAR); 55 78 56 ppSimInsertSource(signal, variance, x, y, star->flux, roughNoise, seeing, expCorr); 79 // XXX add the sources to a source array 80 81 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY); 57 82 } 83 84 // XXX add the source array to the readout analysis 85 58 86 return true; 59 87 }
Note:
See TracChangeset
for help on using the changeset viewer.
