Changeset 18011 for trunk/ppSim/src/ppSimMakeSky.c
- Timestamp:
- Jun 8, 2008, 4:03:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimMakeSky.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimMakeSky.c
r17557 r18011 1 1 # include "ppSim.h" 2 2 3 // XXX add bounds to the inputs? 3 // this function sets the skyRate to a value for the night sky (SKY.RATE or SKY.MAGS) or for a 4 // flat-field image (FLAT.RATE). Include a shutter correction and a scattered light source 5 4 6 bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config) { 5 7 … … 15 17 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 16 18 17 float expTime = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time 18 float flatSigma = psMetadataLookupF32(&status, recipe, "FLAT.SIGMA"); // Flat-field coefficient 19 float flatRate = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate 20 float shutterTime = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time 21 float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate 22 if (isnan(skyRate)) { 23 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status); 24 float scale = psMetadataLookupF32(&status, recipe, "SCALE"); assert (status); 25 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status); 19 bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux? 20 bool flat = psMetadataLookupBool(&status, recipe, "FLAT"); // Apply flat-field term? 21 22 float expTime = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time 23 24 float flatSigma = psMetadataLookupF32(&status, recipe, "FLAT.SIGMA"); // Flat-field coefficient 25 float flatRate = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate 26 float shutterTime = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time 27 float scatterFrac = psMetadataLookupF32(&status, recipe, "SCATTER.FRAC"); // scattered light fraction (max) 28 float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate 29 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status); 30 if (!isnan(skyMags)) { 31 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status); 32 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status); 26 33 skyRate = scale * scale * ppSimMagToFlux (skyMags, zp); 34 } 35 if (type == PPSIM_TYPE_FLAT) { 36 skyRate = flatRate; 27 37 } 28 38 … … 37 47 int yParityCell = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 38 48 39 int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y49 int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y 40 50 41 51 // Size of FPA 42 52 psRegion *bounds = ppSimFPABounds (fpa); 53 int dXfpa = bounds->x1 - bounds->x0; 54 int dYfpa = bounds->y1 - bounds->y0; 43 55 44 56 // Correct chip offsets so that boresight is in the middle of the FPA 45 x0Chip -= 0.5 * (bounds->x1 - bounds->x0);46 y0Chip -= 0.5 * (bounds->y1 - bounds->y0);57 x0Chip -= 0.5 * dXfpa; 58 y0Chip -= 0.5 * dYfpa; 47 59 48 60 for (int y = 0; y < signal->numRows; y++) { … … 58 70 float realExpTime = expTime + shutterTime * (xFPA + yFPA + 2.0) / 4.0; 59 71 60 // Gaussian flat-field over the FPA 61 float flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))) / 62 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 } 63 78 64 if (type == PPSIM_TYPE_FLAT) { 65 float flatFlux = flatRate * flatValue * realExpTime; // Flux from flat-field 66 signal->data.F32[y][x] += flatFlux; 67 variance->data.F32[y][x] += flatFlux; 68 continue; 69 } 79 float scatterRate = 0.0; 70 80 71 expCorr->data.F32[y][x] = realExpTime / expTime; 81 if (sky) { 82 // add a scattered light term to the flat-field images (no 83 if (type == PPSIM_TYPE_FLAT) { 84 float xF = 2.0*(xFPA / dXfpa) - 1.0; 85 scatterRate = scatterFrac * PS_SQR(xF); 86 } 72 87 73 // Sky background 74 float skyFlux = skyRate * flatValue * realExpTime; // Flux from sky 75 signal->data.F32[y][x] += skyFlux; 76 variance->data.F32[y][x] += skyFlux; 88 // Sky background 89 float skyFlux = (skyRate * (flatValue + scatterRate)) * realExpTime; // Flux from sky 90 signal->data.F32[y][x] += skyFlux; 91 variance->data.F32[y][x] += skyFlux; 92 } 93 94 // used later to modify the star and galaxy photometry 95 if (expCorr) { 96 expCorr->data.F32[y][x] = realExpTime / expTime; 97 } 77 98 78 99 // TO DO: Add fringes
Note:
See TracChangeset
for help on using the changeset viewer.
