IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41331


Ignore:
Timestamp:
Apr 9, 2020, 11:51:42 AM (6 years ago)
Author:
eugene
Message:

consolidate sky flux calculation and report in output cmf

Location:
trunk/ppSim/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSim.h

    r41173 r41331  
    188188
    189189float ppSimGetZeroPoint(psMetadata *recipe, const char *filter);
     190float ppSimGetSkyRate(psMetadata *recipe);
    190191
    191192bool ppSimMergeReadouts (pmConfig *config, pmFPAview *view);
  • trunk/ppSim/src/ppSimInsertStars.c

    r36868 r41331  
    4141    }
    4242
    43     float skyRate = psMetadataLookupF32(NULL, recipe, "SKY.RATE"); // Sky rate
    44     if (isnan(skyRate)) {
    45         float zp      = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); assert (mdok);
    46         float scale   = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE");     assert (mdok);
    47         float skyMags = psMetadataLookupF32(&mdok, recipe, "SKY.MAGS");  assert (mdok);
    48         skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
    49     }
     43    float skyRate = ppSimGetSkyRate (recipe);
    5044
    5145    // Rough noise estimate, appropriate for entire cell (use for source radius?)
    5246    float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
     47    float skyFlux = skyRate*expTime;
    5348
    5449    int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
     
    165160        fprintf (outfile, "%8.3f %8.3f %10.5f  %2d  %7.3f %5.3f  %5.3f %5.3f %5.3f %5.3f  :  %f %f\n", star->x, star->y, starFlux, 0, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8, model->params->data.F32[PM_PAR_I0], radius);
    166161
     162        // save the approx sky (exact if sky is flat) for external comparisons
     163        source->sky = skyFlux;
     164
    167165        // add the sources to the source array
    168166        psArrayAdd (sources, 100,source);
  • trunk/ppSim/src/ppSimMakeSky.c

    r41330 r41331  
    2626    float shutterTime  = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time
    2727    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);
    33         skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
    34     }
    35     if (type == PPSIM_TYPE_FLAT) {
    36       skyRate = flatRate;
    37     }
     28
     29    float skyRate      = (type == PPSIM_TYPE_FLAT) ? flatRate : ppSimGetSkyRate (recipe);
    3830
    3931    int x0Chip        = psMetadataLookupS32(&status, chip->concepts, "CHIP.X0");
  • trunk/ppSim/src/ppSimMakeStars.c

    r41173 r41331  
    3939    if (isnan(scale))    ESCAPE("PIXEL.SCALE is not defined");
    4040
    41     bool flatLum       = psMetadataLookupBool(&status,recipe, "STARS.FLAT.LUM"); // were real stars generated?
    42     float flatNum      = psMetadataLookupS32(&status, recipe, "STARS.FLAT.NUM"); // were real stars generated?
     41    bool flatLum       = psMetadataLookupBool(&status,recipe, "STARS.FLAT.LUM"); // use a flat luminosity function? (dn/dmag = const)
     42    float flatNum      = psMetadataLookupS32(&status, recipe, "STARS.FLAT.NUM"); // amplitude of flat luminosity function
    4343
    44     float skyRate = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate
    45     if (isnan(skyRate)) {
    46         float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
    47         skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
    48         // skyMags is in mags / square arcsec, so scale must be in arcsec / pixel
    49     }
     44    float skyRate = ppSimGetSkyRate (recipe);
    5045
    5146    // Size of FPA
  • trunk/ppSim/src/ppSimUtils.c

    r41173 r41331  
    272272}
    273273
     274float ppSimGetSkyRate (psMetadata *recipe) {
     275
     276  bool status;
     277
     278  float skyRate      = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate
     279  if (!isnan(skyRate)) {
     280    float zp       = psMetadataLookupF32(&status, recipe, "ZEROPOINT");   assert (status);
     281    float scale    = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status);
     282    float skyMags  = psMetadataLookupF32(&status, recipe, "SKY.MAGS");    assert (status);
     283    skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     284  }
     285  return skyRate;
     286}
     287
    274288psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) {
    275289
Note: See TracChangeset for help on using the changeset viewer.