IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 15, 2008, 12:01:36 PM (18 years ago)
Author:
eugene
Message:

working on getting the input image options right

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080511/ppSim/src/ppSimMakeSky.c

    r17672 r17702  
    11# include "ppSim.h"
    22
    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
    46bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config) {
    57
     
    1618
    1719    bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux?
    18     if (!sky) return true;
    1920 
    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
    2528    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);
    2932        skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     33    }
     34    if (type == PPSIM_TYPE_FLAT) {
     35      skyRate = flatRate;
    3036    }
    3137
     
    4450    // Size of FPA
    4551    psRegion *bounds = ppSimFPABounds (fpa);
     52    int dXfpa = bounds->x1 - bounds->x0;
     53    int dYfpa = bounds->y1 - bounds->y0;
    4654
    4755    // 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;
    5058
    5159    for (int y = 0; y < signal->numRows; y++) {
     
    6270
    6371            // 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);
    6673
    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;
    7375
    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              }
    7582
    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            }
    8093
    8194            // TO DO: Add fringes
Note: See TracChangeset for help on using the changeset viewer.