IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2007, 4:21:10 PM (19 years ago)
Author:
eugene
Message:

convert ppSimLoop to use pmReadout, loading psf model, add sources based on psf model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c

    r14531 r14547  
    11# include "ppSim.h"
    22
    3 bool ppSimInsertSources (psImage *signal, psImage *variance, psImage *expCorr, psArray *stars, pmConfig *config, pmChip *chip, pmCell *cell) {
     3bool ppSimInsertSources (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config) {
    44
    5     bool mdok;
    65
    76    assert (stars);
    87   
     8    pmCell *cell = readout->parent;
     9    pmChip *chip = cell->parent;
     10
     11    // XXX we probably need this to get the size right
     12# if (0)
     13    bool mdok;
    914    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
    1015
    11     float seeing = psMetadataLookupF32(NULL, config->arguments, "SEEING"); // Seeing sigma (pix)
    1216    float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time
    1317    float skyRate = psMetadataLookupF32(NULL, config->arguments, "SKY.RATE"); // Sky rate
     
    2327    }
    2428
     29    // Rough noise estimate, appropriate for entire cell (use for source radius?)
     30    float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
     31# endif
     32
    2533    int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
    2634    int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
     
    3543    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
    3644
    37     // Rough noise estimate, appropriate for entire cell
    38     float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
    39 
    4045    pmPSF *psf = psMetadataLookupPtr (NULL, chip->analysis, "PSF");
    4146
     47    int dX = PM_CELL_TO_CHIP (0.0, x0Cell, xParityCell, binning);
     48    int dY = PM_CELL_TO_CHIP (0.0, y0Cell, yParityCell, binning);
     49
     50    // add sources to the readout image & weight
    4251    for (long i = 0; i < stars->n; i++) {
    4352        ppSimStar *star = stars->data[i];
    4453
     54        // star->x,y are in fpa coordinates
     55
    4556        // Position on the cell and peak flux
    46         float x = PPSIM_FPA_TO_CELL(star->x, x0Cell, xParityCell, binning, x0Chip, xParityChip);
    47         float y = PPSIM_FPA_TO_CELL(star->y, y0Cell, yParityCell, binning, y0Chip, yParityChip);
     57        float xChip = PM_FPA_TO_CHIP(star->x, x0Chip, xParityChip);
     58        float yChip = PM_FPA_TO_CHIP(star->y, y0Chip, yParityChip);
    4859
    49         // instantiate a model for the PSF at this location (normalized or not?)
    50         // XXX
    51         pmModel *model = pmModelFromPSFforXY (psf, star->x, star->y, star->flux);
     60        // Position on the cell and peak flux
     61        float xCell = PM_CHIP_TO_CELL(xChip, x0Cell, xParityCell, binning);
     62        float yCell = PM_CHIP_TO_CELL(yChip, y0Cell, yParityCell, binning);
     63
     64        if (xCell < 0) continue;
     65        if (yCell < 0) continue;
     66        if (xCell > readout->image->numCols) continue;
     67        if (yCell > readout->image->numRows) continue;
     68        // XXX need to apply col0, row0 if readout is a subarray
     69
     70        // XXX apply the expCorr to the star->flux before setting the model flux
     71
     72        // instantiate a model for the PSF at this location, set desired flux
     73        pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
     74        pmModelSetFlux (model, star->flux);
    5275
    5376        // construct a source, with model flux pixels set, based on the model
    54         pmSource *source = pmSourceFromModel (model);
     77        pmSource *source = pmSourceFromModel (model, readout, PM_SOURCE_TYPE_STAR);
    5578
    56         ppSimInsertSource(signal, variance, x, y, star->flux, roughNoise, seeing, expCorr);
     79        // XXX add the sources to a source array
     80
     81        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
    5782    }
     83
     84    // XXX add the source array to the readout analysis
     85
    5886    return true;
    5987}
Note: See TracChangeset for help on using the changeset viewer.