IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14668


Ignore:
Timestamp:
Aug 25, 2007, 12:02:59 PM (19 years ago)
Author:
eugene
Message:

drop deprecated files, move ppSimInsertSources to ppSimInsertStars

Location:
trunk/ppSim/src
Files:
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/Makefile.am

    r14667 r14668  
    1414        ppSimMakeDark.c         \
    1515        ppSimMakeSky.c          \
    16         ppSimInsertSources.c    \
     16        ppSimInsertStars.c      \
    1717        ppSimInsertGalaxies.c   \
    1818        ppSimAddOverscan.c      \
  • trunk/ppSim/src/ppSim.h

    r14667 r14668  
    9090                 );
    9191
    92 // Add a star into the signal and variance images
    93 bool ppSimInsertStar(psImage *signal,       // Signal image, to which to add star
    94                      psImage *variance,     // Variance image, to which to add star
    95                      float x0, float y0,    // Position of star
    96                      float peak,            // Peak flux of star
    97                      float noise,           // Rough noise estimate
    98                      float seeing,          // Seeing for star
    99                      const psImage *correction // Exposure correction as a function of position
    100                      );
    101 
    102 bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config);
    103 bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
    104 
    10592psVector *ppSimMakeBiassec (pmCell *cell, pmConfig *config);
    10693psVector *ppSimMakeBias (pmReadout *readout, pmConfig *config, const psRandom *rng) ;
    10794bool ppSimMakeDark (pmReadout *readout, pmConfig *config);
    10895bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config);
    109 bool ppSimInsertStars (psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell);
    110 bool ppSimInsertSources (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config);
     96
     97bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config);
     98bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
     99bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config);
    111100
    112101bool ppSimInitHeader(pmConfig *config,
  • trunk/ppSim/src/ppSimInsertStars.c

    r14463 r14668  
    11# include "ppSim.h"
    22
    3 bool ppSimInsertStars (psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell) {
     3bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config) {
    44
    55    bool mdok;
    66
     7    assert (readout);
    78    assert (stars);
    8    
     9
     10    if (!stars->n) { return true; }
     11
     12    // XXX is this needed?
     13    // pmFPAfile *simSources = psMetadataLookupPtr(NULL, config->files, "PPSIM.SOURCES"); // Output sources
     14
     15    pmCell *cell = readout->parent;
     16    pmChip *chip = cell->parent;
     17
     18    // XXX this is an estimate of the sky noise based on the inputs to the image simulation.
     19    // XXX update this to allow the estimate based on the measured sky background
     20    // XXX this is missing the gain.
    921    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
    1022
    11     float seeing = psMetadataLookupF32(NULL, config->arguments, "SEEING"); // Seeing sigma (pix)
    1223    float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time
    1324    float skyRate = psMetadataLookupF32(NULL, config->arguments, "SKY.RATE"); // Sky rate
     
    2334    }
    2435
     36    // Rough noise estimate, appropriate for entire cell (use for source radius?)
     37    float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
     38
    2539    int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
    2640    int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
     
    3549    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
    3650
    37     // Rough noise estimate, appropriate for entire cell
    38     float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
     51    pmPSF *psf = psMetadataLookupPtr (&mdok, chip->analysis, "PSPHOT.PSF");
     52    assert (psf);
    3953
     54    int dX = PM_CELL_TO_CHIP (0.0, x0Cell, xParityCell, binning);
     55    int dY = PM_CELL_TO_CHIP (0.0, y0Cell, yParityCell, binning);
     56
     57    psArray *sources = psArrayAllocEmpty (stars->n);
     58
     59    // add sources to the readout image & weight
    4060    for (long i = 0; i < stars->n; i++) {
    4161        ppSimStar *star = stars->data[i];
    4262
     63        // star->x,y are in fpa coordinates
     64
    4365        // Position on the cell and peak flux
    44         float x = PPSIM_FPA_TO_CELL(star->x, x0Cell, xParityCell, binning, x0Chip, xParityChip);
    45         float y = PPSIM_FPA_TO_CELL(star->y, y0Cell, yParityCell, binning, y0Chip, yParityChip);
    46         ppSimInsertStar(signal, variance, x, y, star->flux, roughNoise, seeing, expCorr);
     66        float xChip = PM_FPA_TO_CHIP(star->x, x0Chip, xParityChip);
     67        float yChip = PM_FPA_TO_CHIP(star->y, y0Chip, yParityChip);
     68
     69        // Position on the cell and peak flux
     70        float xCell = PM_CHIP_TO_CELL(xChip, x0Cell, xParityCell, binning);
     71        float yCell = PM_CHIP_TO_CELL(yChip, y0Cell, yParityCell, binning);
     72
     73        if (xCell < 0) continue;
     74        if (yCell < 0) continue;
     75        if (xCell > readout->image->numCols) continue;
     76        if (yCell > readout->image->numRows) continue;
     77        // XXX need to apply col0, row0 if readout is a subarray
     78
     79        // XXX apply the expCorr to the star->flux before setting the model flux
     80
     81        // instantiate a model for the PSF at this location, set desired flux
     82        pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
     83        pmModelSetFlux (model, star->flux);
     84
     85        // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
     86        float radius = model->modelRadius (model->params, roughNoise);
     87        radius = PS_MAX (radius, 1.0);
     88
     89        // construct a source, with model flux pixels set, based on the model
     90        pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
     91
     92        // XXX set the mag & err values (should this be done in pmSourceFromModel?)
     93        // XXX i should be applying the gain and the correct effective area
     94        psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
     95        psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
     96
     97        source->psfMag = -2.5*log10(star->flux);
     98        source->errMag = sqrt(Area*PS_SQR(roughNoise) + star->flux) / star->flux;       
     99       
     100        // XXX add the sources to a source array
     101
     102        // insert the source flux in the image
     103        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
     104        psArrayAdd (sources, 100,source);
    47105    }
     106
     107    // NOTE: readout must be part of the pmFPAfile named "PPSIM.OUTPUT"
     108    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);
     109
     110    // XXX many leaks in here, i think
    48111    return true;
    49112}
     113
  • trunk/ppSim/src/ppSimLoop.c

    r14667 r14668  
    125125
    126126                if (type == PPSIM_TYPE_OBJECT) {
    127                     ppSimInsertSources (readout, expCorr, stars, config);
     127                    ppSimInsertStars (readout, expCorr, stars, config);
    128128                }
    129129
Note: See TracChangeset for help on using the changeset viewer.