Changeset 17705
- Timestamp:
- May 15, 2008, 4:44:46 PM (18 years ago)
- Location:
- branches/eam_branch_20080511/ppSim/src
- Files:
-
- 1 added
- 11 edited
-
Makefile.am (modified) (1 diff)
-
ppSim.c (modified) (2 diffs)
-
ppSim.h (modified) (1 diff)
-
ppSimAddNoise.c (modified) (2 diffs)
-
ppSimAddOverscan.c (modified) (1 diff)
-
ppSimArguments.c (modified) (5 diffs)
-
ppSimCreate.c (modified) (2 diffs)
-
ppSimInsertStars.c (modified) (1 diff)
-
ppSimLoop.c (modified) (1 diff)
-
ppSimMakeBiassec.c (modified) (1 diff)
-
ppSimMakeSky.c (modified) (4 diffs)
-
ppSimRandomGaussian.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/Makefile.am
r17702 r17705 28 28 ppSimMergeReadouts.c \ 29 29 ppSimMosaicChip.c \ 30 ppSimRandomGaussian.c \ 30 31 ppSimBadPixels.c 31 32 -
branches/eam_branch_20080511/ppSim/src/ppSim.c
r17672 r17705 2 2 3 3 int failure (pmConfig *config, psExit status, char *message) { 4 ppSimRandomGaussianFree (); 4 5 psErrorStackPrint(stderr, message); 5 6 psFree(config); … … 31 32 } 32 33 34 ppSimRandomGaussianFree (); 33 35 psFree(config); 34 36 pmModelClassCleanup(); -
branches/eam_branch_20080511/ppSim/src/ppSim.h
r17702 r17705 176 176 bool ppSimMergeReadouts (pmReadout *outReadout, pmReadout *inReadout); 177 177 178 double ppSimRandomGaussian (const psRandom *rnd, double mean, double sigma); 179 double ppSimRandomGaussianNorm (const psRandom *rnd); 180 void ppSimRandomGaussianFree(); 181 178 182 #endif -
branches/eam_branch_20080511/ppSim/src/ppSimAddNoise.c
r17702 r17705 32 32 // (generate a static array with the cumulative distribution, use the 33 33 // random number to select a bin from the histogram) 34 signal->data.F32[y][x] += sqrtf(variance->data.F32[y][x]) * p sRandomGaussian(rng);34 signal->data.F32[y][x] += sqrtf(variance->data.F32[y][x]) * ppSimRandomGaussianNorm(rng); 35 35 signal->data.F32[y][x] /= gain; // Converting to ADU 36 36 } … … 40 40 return true; 41 41 } 42 -
branches/eam_branch_20080511/ppSim/src/ppSimAddOverscan.c
r17702 r17705 7 7 // skip this step if we did not generate a bias level 8 8 if (biasCols == NULL) return true; 9 if (biasRows == NULL) return true; 9 10 10 11 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe -
branches/eam_branch_20080511/ppSim/src/ppSimArguments.c
r17702 r17705 22 22 { 23 23 bool status; 24 bool mdok; // Status of MD lookup25 24 26 25 assert(config); … … 154 153 ppSimType type = ppSimTypeFromString (typeStr); 155 154 156 char *filter =ppSimArgToRecipeStr(&status, options, "FILTER", arguments, "-filter"); // Filter name155 ppSimArgToRecipeStr(&status, options, "FILTER", arguments, "-filter"); // Filter name 157 156 158 157 // set the exposure time … … 178 177 ppSimArgToRecipeS32(&status, options, "BINNING", arguments, "-bin"); 179 178 180 // XX don't do this: recipe is not yet fully realized (camera options not interpolated)181 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe182 183 179 if (type == PPSIM_TYPE_OBJECT) { 184 180 // Load values required for adding stars … … 195 191 } 196 192 197 float scale = ppSimArgToRecipeF32(&status, options, "PIXEL.SCALE", arguments, "-scale"); // Plate scale193 ppSimArgToRecipeF32(&status, options, "PIXEL.SCALE", arguments, "-scale"); // Plate scale (arcsec / pixel) 198 194 ppSimArgToRecipeF32(&status, options, "SKY.MAGS", arguments, "-skymags"); // Plate scale 199 195 ppSimArgToRecipeStr(&status, options, "PSF.MODEL", arguments, "-psfclass"); // PSF model class … … 201 197 202 198 // the user supplies FWHM in arcsec; here we convert to Sigma in pixels 203 psMetadataAddF32(options, PS_LIST_TAIL, "SEEING", 0, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale);199 psMetadataAddF32(options, PS_LIST_TAIL, "SEEING", 0, "Seeing FWHM (arcsec)", seeing); 204 200 psMetadataAddF32(options, PS_LIST_TAIL, "RA", 0, "Boresight RA (radians)", ra0 * M_PI / 180.0); 205 201 psMetadataAddF32(options, PS_LIST_TAIL, "DEC", 0, "Boresight Declination (radians)", dec0 * M_PI / 180.0); 206 202 psMetadataAddF32(options, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0); 207 203 208 assert (filter != NULL);209 210 204 ppSimArgToRecipeF32(&status, options, "ZEROPOINT", arguments, "-zp"); // Zero point 211 if (!status) {212 float zp = ppSimGetZeroPoint (recipe, filter);213 psMetadataAddF32(options, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp);214 }215 205 } 216 206 -
branches/eam_branch_20080511/ppSim/src/ppSimCreate.c
r17702 r17705 53 53 config->formatName = psStringCopy (output->formatName); 54 54 55 // the recipe is now fully realized for the desired camera 55 56 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 57 58 char *typeStr = psMetadataLookupStr(NULL, recipe, "IMAGE.TYPE"); // Type of image to simulate 59 ppSimType type = ppSimTypeFromString (typeStr); // Type of image to simulate 60 61 if (type == PPSIM_TYPE_OBJECT) { 62 // adjust the seeing by the scale 63 float seeing = psMetadataLookupF32(&status, recipe, "SEEING"); 64 if (isnan(seeing)) { 65 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "seeing is not defined"); 66 psFree(fpa); 67 return NULL; 68 } 69 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); 70 if (isnan(scale)) { 71 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "pixel scale is not defined"); 72 psFree(fpa); 73 return NULL; 74 } 75 psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 76 } 77 78 if ((type == PPSIM_TYPE_OBJECT) || (type == PPSIM_TYPE_FLAT)) { 79 // determine the zeropoint from the filter 80 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); 81 if (isnan(zp)) { 82 char *filter = psMetadataLookupStr(&status, recipe, "FILTER"); 83 float zp = ppSimGetZeroPoint (recipe, filter); 84 psMetadataAddF32(recipe, PS_LIST_TAIL, "ZEROPOINT", PS_META_REPLACE, "Photometric zeropoint", zp); 85 } 86 } 56 87 57 88 // For photometry, we operate on the chip-mosaicked image. we create a copy of the mosaicked … … 115 146 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 116 147 117 ppSimArgToRecipeF32(&status, recipe, "EXPTIME", fpa->concepts, "FPA.EXPOSURE");118 char *filter = ppSimArgToRecipeStr(&status, recipe, "FILTER", fpa->concepts, "FPA.FILTER");148 ppSimArgToRecipeF32(&status, recipe, "EXPTIME", input->fpa->concepts, "FPA.EXPOSURE"); 149 char *filter = ppSimArgToRecipeStr(&status, recipe, "FILTER", input->fpa->concepts, "FPA.FILTER"); 119 150 120 151 float zp = ppSimGetZeroPoint (recipe, filter); -
branches/eam_branch_20080511/ppSim/src/ppSimInsertStars.c
r17672 r17705 121 121 // insert the source flux in the image 122 122 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY); 123 pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY); 123 124 psArrayAdd (sources, 100,source); 124 125 psFree(source); // Drop reference -
branches/eam_branch_20080511/ppSim/src/ppSimLoop.c
r17702 r17705 170 170 171 171 if (inputCell && inputCell->readouts->data[i]) { 172 if (!ppSimMergeReadouts (readout, inputCell->readouts->data[i])) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image"); 172 pmReadout *inReadout = inputCell->readouts->data[i]; 173 if (!inReadout->weight) { 174 if (!pmReadoutGenerateWeight(inReadout, true)) { 175 psError (PS_ERR_UNKNOWN, false, "trouble creating weight"); 176 return false; 177 } 178 } 179 if (!ppSimMergeReadouts (readout, inReadout)) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image"); 173 180 } 174 181 } -
branches/eam_branch_20080511/ppSim/src/ppSimMakeBiassec.c
r14463 r17705 6 6 7 7 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe 8 9 bool bias = psMetadataLookupBool(&mdok, recipe, "BIAS"); // Generate a Bias? 10 if (!bias) return NULL; 8 11 9 12 psList *biassec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); // Bias regions -
branches/eam_branch_20080511/ppSim/src/ppSimMakeSky.c
r17702 r17705 17 17 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 18 18 19 bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux? 19 bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux? 20 bool flat = psMetadataLookupBool(&status, recipe, "FLAT"); // Apply flat-field term? 20 21 21 22 float expTime = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time … … 24 25 float flatRate = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate 25 26 float shutterTime = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time 26 float scatter Scale = psMetadataLookupF32(&status, recipe, "SCATTER.SCALE"); // scattered light term27 float scatterFrac = psMetadataLookupF32(&status, recipe, "SCATTER.FRAC"); // scattered light fraction (max) 27 28 float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate 28 if (isnan(skyRate)) { 29 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status); 30 if (!isnan(skyMags)) { 29 31 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status); 30 32 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status); 31 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status);32 33 skyRate = scale * scale * ppSimMagToFlux (skyMags, zp); 33 34 } … … 69 70 float realExpTime = expTime + shutterTime * (xFPA + yFPA + 2.0) / 4.0; 70 71 71 // Gaussian flat-field over the FPA 72 float flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))) / flatSigma / sqrtf(2.0 * M_PI); 72 // Gaussian flat-field over the FPA with flatValue = 1.0 at the field center 73 float flatValue = 1.0; 74 if (flat) { 75 // we make the flat-field have a response of 1.0 at the field center (like a vignetting) 76 flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))); 77 } 73 78 74 79 float scatterRate = 0.0; … … 78 83 if (type == PPSIM_TYPE_FLAT) { 79 84 float xF = 2.0*(xFPA / dXfpa) - 1.0; 80 scatterRate = scatter Scale* PS_SQR(xF);85 scatterRate = scatterFrac * PS_SQR(xF); 81 86 } 82 87 83 88 // Sky background 84 float skyFlux = (skyRate * flatValue + scatterRate) * realExpTime; // Flux from sky89 float skyFlux = (skyRate * (flatValue + scatterRate)) * realExpTime; // Flux from sky 85 90 signal->data.F32[y][x] += skyFlux; 86 91 variance->data.F32[y][x] += skyFlux;
Note:
See TracChangeset
for help on using the changeset viewer.
