IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28125


Ignore:
Timestamp:
May 26, 2010, 4:31:49 PM (16 years ago)
Author:
eugene
Message:

add ppSim option to convolve to a PSF rather than generating stars with the specified PSF

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippconfig/recipes/ppSim.config

    r27925 r28125  
    6060PSF.ARATIO      F32     1.0             # minor / major (0.0 - 1.0)
    6161PSF.THETA       F32     0.0
     62PSF.CONVOLVE    BOOL    FALSE           # generate fake stars with PSF (F), or smooth with PSF (T)?
    6263
    6364STARS.GRID      BOOL    FALSE           # Add grid of fake stars with constant flux
  • trunk/ppSim/src/Makefile.am

    r26900 r28125  
    4343        ppSimBounds.c             \
    4444        ppSimStars.c              \
     45        ppSimSmoothReadout.c      \
    4546        ppSimSetPSF.c             \
    4647        ppSimUtils.c              \
  • trunk/ppSim/src/ppSim.h

    r26900 r28125  
    106106bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config);
    107107
     108bool ppSimSmoothReadout(pmReadout *input, psMetadata *recipe);
     109
    108110bool ppSimInitHeader(pmConfig *config,
    109111                     pmFPA *fpa,
  • trunk/ppSim/src/ppSimInsertStars.c

    r27657 r28125  
    2323    // XXX this is missing the gain.
    2424    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
     25
     26    bool psfConvolve = psMetadataLookupBool(NULL, recipe, "PSF.CONVOLVE"); // smooth the image with the PSF?
    2527
    2628    float expTime   = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time
     
    103105        float flux = star->flux * expCorr->data.F32[(int)yCell][(int)xCell];
    104106
    105         // instantiate a model for the PSF at this location, set desired flux
    106         pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
    107         pmModelSetFlux (model, flux);
     107        // if psfConvolve is TRUE, we will (elsewhere) convolve the image we a PSF
     108        // in this case, simply place delta functions in the image
     109        if (psfConvolve) {
     110            readout->image->data.F32[(int)(yCell)][(int)(xCell)] = flux;
     111            continue;
     112        }
    108113
    109         float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
    110         radius = PS_MAX (radius, 1.0);
     114        // instantiate a model for the PSF at this location, set desired flux
     115        pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
     116        pmModelSetFlux (model, flux);
    111117
    112         // construct a source, with model flux pixels set, based on the model
    113         pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
     118        float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
     119        radius = PS_MAX (radius, 1.0);
    114120
    115         // XXX set the mag & err values (should this be done in pmSourceFromModel?)
    116         // XXX i should be applying the gain and the correct effective area
    117         psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
    118         psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
     121        // construct a source, with model flux pixels set, based on the model
     122        pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
    119123
    120         // this value is the pure (input) flux, and is saved in the output source cmf files
    121         source->psfMag = -2.5*log10(star->flux);
    122         source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux;
     124        // XXX set the mag & err values (should this be done in pmSourceFromModel?)
     125        // XXX i should be applying the gain and the correct effective area
     126        psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
     127        psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
    123128
    124         fprintf (outfile, "%8.3f %8.3f  %10.2f  %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag);
     129        // this value is the pure (input) flux, and is saved in the output source cmf files
     130        source->psfMag = -2.5*log10(star->flux);
     131        source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux;
    125132
    126         // insert the source flux in the image
    127         pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
     133        fprintf (outfile, "%8.3f %8.3f  %10.2f  %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag);
    128134
    129         // insert the source flux in the noise image
    130         pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);
     135        // insert the source flux in the image
     136        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
    131137
    132         // Blow away the image parts of the source, which makes the memory explode
    133         RESET(source->pixels);
    134         RESET(source->variance);
    135         RESET(source->maskObj);
    136         RESET(source->maskView);
    137         RESET(source->modelFlux);
    138         RESET(source->psfImage);
    139         RESET(source->blends);
     138        // insert the source flux in the noise image
     139        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);
    140140
    141         // add the sources to the source array
    142         psArrayAdd (sources, 100,source);
    143         psFree(source);                 // Drop reference
     141        // Blow away the image parts of the source, which makes the memory explode
     142        RESET(source->pixels);
     143        RESET(source->variance);
     144        RESET(source->maskObj);
     145        RESET(source->maskView);
     146        RESET(source->modelFlux);
     147        RESET(source->psfImage);
     148        RESET(source->blends);
     149
     150        // add the sources to the source array
     151        psArrayAdd (sources, 100,source);
     152        psFree(source);                 // Drop reference
    144153    }
    145154    fclose (outfile);
  • trunk/ppSim/src/ppSimLoop.c

    r26900 r28125  
    3030    ppSimType type = ppSimTypeFromString (typeStr); // Type of image to simulate
    3131    int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y
     32
     33    bool psfConvolve = psMetadataLookupBool(NULL, recipe, "PSF.CONVOLVE"); // smooth the image with the PSF?
    3234
    3335    ppSimUpdateConceptsFPA (fpa, config);
     
    155157                psFree(expCorr);
    156158
     159                // we have two options for generating images which have a PSF:
     160                // 1) lay down stars with the PSF model applied : in this case, galaxies do NOT have the PSF
     161                // 2) lay down delta functions for stars and smooth the image with a PSF : in this case, the stars land at integer pixel locations
     162                if (psfConvolve) {
     163                    if (!ppSimSmoothReadout(readout, recipe)) ESCAPE (PS_ERR_UNKNOWN, "problem smoothing image");
     164                }
     165
    157166            done:
    158167                if (!ppSimAddNoise(readout->image, readout->variance, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
Note: See TracChangeset for help on using the changeset viewer.