Changeset 14547
- Timestamp:
- Aug 19, 2007, 4:21:10 PM (19 years ago)
- Location:
- branches/eam_branch_20070817/ppSim/src
- Files:
-
- 1 added
- 12 edited
-
Makefile.am (modified) (1 diff)
-
ppSim.h (modified) (3 diffs)
-
ppSimAddNoise.c (modified) (3 diffs)
-
ppSimAddOverscan.c (modified) (1 diff)
-
ppSimCreate.c (modified) (7 diffs)
-
ppSimInsertSource.c (modified) (1 diff)
-
ppSimInsertSources.c (modified) (3 diffs)
-
ppSimLoop.c (modified) (4 diffs)
-
ppSimMakeBias.c (modified) (2 diffs)
-
ppSimMakeDark.c (modified) (1 diff)
-
ppSimMakeSky.c (modified) (1 diff)
-
ppSimMakeSources.c (added)
-
ppSimSaturate.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/ppSim/src/Makefile.am
r14463 r14547 13 13 ppSimMakeDark.c \ 14 14 ppSimMakeSky.c \ 15 ppSimInsertS tars.c\15 ppSimInsertSources.c \ 16 16 ppSimAddOverscan.c \ 17 17 ppSimAddNoise.c \ -
branches/eam_branch_20070817/ppSim/src/ppSim.h
r14463 r14547 89 89 90 90 psVector *ppSimMakeBiassec (pmCell *cell, pmConfig *config); 91 psVector *ppSimMakeBias (p sImage *signal, psImage *variance, pmCell *cell, pmConfig *config, const psRandom *rng) ;92 bool ppSimMakeDark (p sImage *signal, psImage *variance, pmConfig *config);93 bool ppSimMakeSky (p sImage *signal, psImage *variance, psImage *expCorr, ppSimType type, pmConfig *config, pmFPA *fpa, pmChip *chip, pmCell *cell);91 psVector *ppSimMakeBias (pmReadout *readout, pmConfig *config, const psRandom *rng) ; 92 bool ppSimMakeDark (pmReadout *readout, pmConfig *config); 93 bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config); 94 94 bool ppSimInsertStars (psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell); 95 bool ppSimInsertSources (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config); 95 96 96 97 bool ppSimInitHeader(pmConfig *config, … … 99 100 pmCell *cell); 100 101 101 bool ppSimSaturate(psImage *image, // Image to apply saturation 102 const pmConfig *config, 103 const pmCell *cell); // Saturation level 102 bool ppSimSaturate(pmReadout *readout, // Image to apply saturation 103 const pmConfig *config); // Saturation level 104 104 105 105 bool ppSimUpdateConceptsFPA (pmFPA *fpa, pmConfig *config); … … 108 108 bool ppSimAddOverscan (pmReadout *readout, pmConfig *config, psVector *biasCols, psVector *biasRows, psRandom *rng); 109 109 110 psImage *ppSimAddNoise(psImage *signal, // Signal image, modified and returned 111 const psImage *variance, // Variance image112 const pmConfig *config,113 const pmCell *cell,114 const psRandom *rng // Random number generator115 );110 bool ppSimAddNoise(psImage *signal, 111 psImage *variance, 112 const pmCell *cell, 113 const pmConfig *config, 114 const psRandom *rng // Random number generator 115 ); 116 116 117 117 #endif -
branches/eam_branch_20070817/ppSim/src/ppSimAddNoise.c
r14463 r14547 2 2 3 3 // Add noise to an image 4 psImage *ppSimAddNoise(psImage *signal, // Signal image, modified and returned5 const psImage *variance, // Variance image6 const pmConfig *config,7 const pmCell *cell,8 const psRandom *rng // Random number generator4 bool ppSimAddNoise(psImage *signal, // Signal image, modified and returned 5 psImage *variance, 6 const pmCell *cell, 7 const pmConfig *config, 8 const psRandom *rng // Random number generator 9 9 ) 10 10 { … … 22 22 if (!mdok) { 23 23 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find GAIN in recipe."); 24 return NULL;24 return false; 25 25 } 26 26 } … … 38 38 39 39 // XXX why return this?? 40 return signal;40 return true; 41 41 } 42 42 -
branches/eam_branch_20070817/ppSim/src/ppSimAddOverscan.c
r14463 r14547 29 29 psImageInit(variance, PS_SQR(readnoise)); 30 30 31 ppSimAddNoise(signal, variance, config, readout->parent, rng);31 ppSimAddNoise(signal, variance, readout->parent, config, rng); 32 32 psListAdd(readout->bias, PS_LIST_TAIL, signal); 33 33 -
branches/eam_branch_20070817/ppSim/src/ppSimCreate.c
r14531 r14547 12 12 13 13 pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, OUTPUT_FILE); 14 psFree(fpa);15 14 if (!file) { 16 15 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to create output file from %s. " … … 20 19 if (file->type != PM_FPA_FILE_IMAGE) { 21 20 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "%s type is not IMAGE", OUTPUT_FILE); 21 psFree(fpa); 22 22 psFree(file); 23 23 return NULL; … … 31 31 if (!status) { 32 32 psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD"); 33 return status; 33 psFree(fpa); 34 psFree(file); 35 return NULL; 34 36 } 35 37 } … … 44 46 psFree(fpa); 45 47 psFree(view); 48 psFree(file); 46 49 return NULL; 47 50 } … … 55 58 psFree(fpa); 56 59 psFree(view); 60 psFree(file); 57 61 return NULL; 58 62 } … … 66 70 psFree(fpa); 67 71 psFree(view); 72 psFree(file); 68 73 return NULL; 69 74 } … … 71 76 } 72 77 } 78 79 psFree(fpa); 73 80 psFree(view); 74 81 -
branches/eam_branch_20070817/ppSim/src/ppSimInsertSource.c
r14531 r14547 1 1 # include "ppSim.h" 2 2 3 bool ppSimInsertSource s(psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell) {3 bool ppSimInsertSource (psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell) { 4 4 5 5 bool mdok; -
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 } -
branches/eam_branch_20070817/ppSim/src/ppSimLoop.c
r14531 r14547 31 31 // load any needed files (eg, input image, PSF) 32 32 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 33 psError(PS PHOT_ERR_DATA, false, "failed IO for fpa in ppSim\n");33 psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in ppSim\n"); 34 34 psFree(view); 35 35 return false; … … 43 43 // load any needed files (eg, input image, PSF) 44 44 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 45 psError(PS PHOT_ERR_DATA, false, "failed IO for chip %d in ppSim\n", view->chip);45 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip); 46 46 psFree (view); 47 47 return false; 48 48 } 49 49 50 pmPSF *psf = NULL;50 // XXX check for a supplied PSF, otherwise generate a basic one 51 51 if (type == PPSIM_TYPE_OBJECT) { 52 psf = ppSimSetPSF (config);52 // XXX TBD : ppSimSetPSF (chip, config); 53 53 } 54 54 … … 74 74 75 75 // TO DO: Decide if cell is to be windowed, reduce numCols, numRows appropriately 76 psImage *signal= psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels77 psImage *variance= psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels76 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels 77 readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels 78 78 79 79 psImage *expCorr = NULL; // Exposure correction per pixel, for adding objects … … 82 82 } 83 83 84 psVector *biasRows = ppSimMakeBias ( signal, variance, cell, config, rng);84 psVector *biasRows = ppSimMakeBias (readout, config, rng); 85 85 if (type == PPSIM_TYPE_BIAS) goto done; 86 86 87 ppSimMakeDark ( signal, variance, config);87 ppSimMakeDark (readout, config); 88 88 if (type == PPSIM_TYPE_DARK) goto done; 89 89 90 ppSimMakeSky ( signal, variance, expCorr, type, config, fpa, chip, cell);90 ppSimMakeSky (readout, expCorr, type, config); 91 91 if (type == PPSIM_TYPE_FLAT) goto done; 92 92 93 // if (type == PPSIM_TYPE_OBJECT) { 94 // ppSimInsertStars (readout, expCorr, stars, config, chip, cell); 95 // } 96 93 97 if (type == PPSIM_TYPE_OBJECT) { 94 ppSimInsertS tars (signal, variance, expCorr, stars, config, chip, cell);98 ppSimInsertSources (readout, expCorr, stars, config); 95 99 } 96 100 97 101 done: 98 ppSimAddNoise(signal, variance, config, cell, rng); 99 ppSimSaturate(signal, config, cell); 100 101 readout->image = signal; 102 psFree(variance); 103 psFree(expCorr); 102 ppSimAddNoise(readout->image, readout->weight, cell, config, rng); 103 ppSimSaturate(readout, config); 104 104 105 105 ppSimAddOverscan (readout, config, biasCols, biasRows, rng); -
branches/eam_branch_20070817/ppSim/src/ppSimMakeBias.c
r14463 r14547 1 1 # include "ppSim.h" 2 2 3 psVector *ppSimMakeBias (p sImage *signal, psImage *variance, pmCell *cell, pmConfig *config, const psRandom *rng) {3 psVector *ppSimMakeBias (pmReadout *readout, pmConfig *config, const psRandom *rng) { 4 4 5 5 bool mdok; 6 7 pmCell *cell = readout->parent; 6 8 7 9 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe … … 20 22 } 21 23 } 24 25 psImage *signal = readout->image; 26 psImage *variance = readout->weight; 22 27 23 28 int numRows = signal->numRows; -
branches/eam_branch_20070817/ppSim/src/ppSimMakeDark.c
r14463 r14547 2 2 3 3 // XXX add bounds to the inputs? 4 bool ppSimMakeDark (psImage *signal, psImage *variance, pmConfig *config) { 4 bool ppSimMakeDark (pmReadout *readout, pmConfig *config) { 5 6 psImage *signal = readout->image; 7 psImage *variance = readout->weight; 5 8 6 9 float darkRate = psMetadataLookupF32(NULL, config->arguments, "DARK.RATE"); // Dark rate -
branches/eam_branch_20070817/ppSim/src/ppSimMakeSky.c
r14463 r14547 2 2 3 3 // XXX add bounds to the inputs? 4 bool ppSimMakeSky (psImage *signal, psImage *variance, psImage *expCorr, ppSimType type, pmConfig *config, pmFPA *fpa, pmChip *chip, pmCell *cell) { 4 bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config) { 5 6 psImage *signal = readout->image; 7 psImage *variance = readout->weight; 8 9 pmCell *cell = readout->parent; 10 pmChip *chip = cell->parent; 11 pmFPA *fpa = chip->parent; 5 12 6 13 float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time -
branches/eam_branch_20070817/ppSim/src/ppSimSaturate.c
r14463 r14547 2 2 3 3 // Apply saturation limit to image 4 bool ppSimSaturate(psImage *image, // Image to apply saturation 5 const pmConfig *config, 6 const pmCell *cell // Saturation level 4 bool ppSimSaturate(pmReadout *readout, // Image to apply saturation 5 const pmConfig *config // configuration data 7 6 ) 8 7 { 9 8 bool mdok; 9 10 psImage *image = readout->image; 11 pmCell *cell = readout->parent; 10 12 11 13 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
Note:
See TracChangeset
for help on using the changeset viewer.
