Changeset 17702 for branches/eam_branch_20080511/ppSim/src/ppSimMakeSky.c
- Timestamp:
- May 15, 2008, 12:01:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimMakeSky.c
r17672 r17702 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 … … 16 18 17 19 bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux? 18 if (!sky) return true;19 20 20 float expTime = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time 21 float flatSigma = psMetadataLookupF32(&status, recipe, "FLAT.SIGMA"); // Flat-field coefficient 22 float flatRate = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate 23 float shutterTime = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time 24 float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate 21 float expTime = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time 22 23 float flatSigma = psMetadataLookupF32(&status, recipe, "FLAT.SIGMA"); // Flat-field coefficient 24 float flatRate = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate 25 float shutterTime = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time 26 float scatterScale = psMetadataLookupF32(&status, recipe, "SCATTER.SCALE"); // scattered light term 27 float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate 25 28 if (isnan(skyRate)) { 26 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status);27 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status);28 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status);29 float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status); 30 float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status); 31 float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS"); assert (status); 29 32 skyRate = scale * scale * ppSimMagToFlux (skyMags, zp); 33 } 34 if (type == PPSIM_TYPE_FLAT) { 35 skyRate = flatRate; 30 36 } 31 37 … … 44 50 // Size of FPA 45 51 psRegion *bounds = ppSimFPABounds (fpa); 52 int dXfpa = bounds->x1 - bounds->x0; 53 int dYfpa = bounds->y1 - bounds->y0; 46 54 47 55 // Correct chip offsets so that boresight is in the middle of the FPA 48 x0Chip -= 0.5 * (bounds->x1 - bounds->x0);49 y0Chip -= 0.5 * (bounds->y1 - bounds->y0);56 x0Chip -= 0.5 * dXfpa; 57 y0Chip -= 0.5 * dYfpa; 50 58 51 59 for (int y = 0; y < signal->numRows; y++) { … … 62 70 63 71 // Gaussian flat-field over the FPA 64 float flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))) / 65 flatSigma / sqrtf(2.0 * M_PI); 72 float flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))) / flatSigma / sqrtf(2.0 * M_PI); 66 73 67 if (type == PPSIM_TYPE_FLAT) { 68 float flatFlux = flatRate * flatValue * realExpTime; // Flux from flat-field 69 signal->data.F32[y][x] += flatFlux; 70 variance->data.F32[y][x] += flatFlux; 71 continue; 72 } 74 float scatterRate = 0.0; 73 75 74 expCorr->data.F32[y][x] = realExpTime / expTime; 76 if (sky) { 77 // add a scattered light term to the flat-field images (no 78 if (type == PPSIM_TYPE_FLAT) { 79 float xF = 2.0*(xFPA / dXfpa) - 1.0; 80 scatterRate = scatterScale * PS_SQR(xF); 81 } 75 82 76 // Sky background 77 float skyFlux = skyRate * flatValue * realExpTime; // Flux from sky 78 signal->data.F32[y][x] += skyFlux; 79 variance->data.F32[y][x] += skyFlux; 83 // Sky background 84 float skyFlux = (skyRate * flatValue + scatterRate) * realExpTime; // Flux from sky 85 signal->data.F32[y][x] += skyFlux; 86 variance->data.F32[y][x] += skyFlux; 87 } 88 89 // used later to modify the star and galaxy photometry 90 if (expCorr) { 91 expCorr->data.F32[y][x] = realExpTime / expTime; 92 } 80 93 81 94 // TO DO: Add fringes
Note:
See TracChangeset
for help on using the changeset viewer.
