IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17705


Ignore:
Timestamp:
May 15, 2008, 4:44:46 PM (18 years ago)
Author:
eugene
Message:

options to turn on and off all of the components

Location:
branches/eam_branch_20080511/ppSim/src
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080511/ppSim/src/Makefile.am

    r17702 r17705  
    2828        ppSimMergeReadouts.c    \
    2929        ppSimMosaicChip.c       \
     30        ppSimRandomGaussian.c   \
    3031        ppSimBadPixels.c
    3132
  • branches/eam_branch_20080511/ppSim/src/ppSim.c

    r17672 r17705  
    22
    33int failure (pmConfig *config, psExit status, char *message) {
     4    ppSimRandomGaussianFree ();
    45    psErrorStackPrint(stderr, message);
    56    psFree(config);
     
    3132    }
    3233
     34    ppSimRandomGaussianFree ();
    3335    psFree(config);
    3436    pmModelClassCleanup();
  • branches/eam_branch_20080511/ppSim/src/ppSim.h

    r17702 r17705  
    176176bool ppSimMergeReadouts (pmReadout *outReadout, pmReadout *inReadout);
    177177
     178double ppSimRandomGaussian (const psRandom *rnd, double mean, double sigma);
     179double ppSimRandomGaussianNorm (const psRandom *rnd);
     180void ppSimRandomGaussianFree();
     181
    178182#endif
  • branches/eam_branch_20080511/ppSim/src/ppSimAddNoise.c

    r17702 r17705  
    3232            // (generate a static array with the cumulative distribution, use the
    3333            // random number to select a bin from the histogram)
    34             signal->data.F32[y][x] += sqrtf(variance->data.F32[y][x]) * psRandomGaussian(rng);
     34            signal->data.F32[y][x] += sqrtf(variance->data.F32[y][x]) * ppSimRandomGaussianNorm(rng);
    3535            signal->data.F32[y][x] /= gain; // Converting to ADU
    3636        }
     
    4040    return true;
    4141}
     42
  • branches/eam_branch_20080511/ppSim/src/ppSimAddOverscan.c

    r17702 r17705  
    77    // skip this step if we did not generate a bias level
    88    if (biasCols == NULL) return true;
     9    if (biasRows == NULL) return true;
    910
    1011    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
  • branches/eam_branch_20080511/ppSim/src/ppSimArguments.c

    r17702 r17705  
    2222{
    2323    bool status;
    24     bool mdok;                          // Status of MD lookup
    2524
    2625    assert(config);
     
    154153    ppSimType type = ppSimTypeFromString (typeStr);
    155154
    156     char *filter = ppSimArgToRecipeStr(&status, options, "FILTER", arguments, "-filter"); // Filter name
     155    ppSimArgToRecipeStr(&status, options, "FILTER", arguments, "-filter"); // Filter name
    157156
    158157    // set the exposure time
     
    178177    ppSimArgToRecipeS32(&status, options, "BINNING",       arguments, "-bin");
    179178
    180     // XX don't do this: recipe is not yet fully realized (camera options not interpolated)
    181     psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe
    182 
    183179    if (type == PPSIM_TYPE_OBJECT) {
    184180        // Load values required for adding stars
     
    195191        }
    196192
    197         float scale = ppSimArgToRecipeF32(&status, options, "PIXEL.SCALE", arguments, "-scale"); // Plate scale
     193        ppSimArgToRecipeF32(&status, options, "PIXEL.SCALE", arguments, "-scale"); // Plate scale (arcsec / pixel)
    198194        ppSimArgToRecipeF32(&status, options, "SKY.MAGS", arguments, "-skymags"); // Plate scale
    199195        ppSimArgToRecipeStr(&status, options, "PSF.MODEL",    arguments, "-psfclass"); // PSF model class
     
    201197
    202198        // the user supplies FWHM in arcsec; here we convert to Sigma in pixels
    203         psMetadataAddF32(options, PS_LIST_TAIL, "SEEING", 0, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale);
     199        psMetadataAddF32(options, PS_LIST_TAIL, "SEEING", 0, "Seeing FWHM (arcsec)", seeing);
    204200        psMetadataAddF32(options, PS_LIST_TAIL, "RA", 0, "Boresight RA (radians)", ra0 * M_PI / 180.0);
    205201        psMetadataAddF32(options, PS_LIST_TAIL, "DEC", 0, "Boresight Declination (radians)", dec0 * M_PI / 180.0);
    206202        psMetadataAddF32(options, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0);
    207203
    208         assert (filter != NULL);
    209 
    210204        ppSimArgToRecipeF32(&status, options, "ZEROPOINT", arguments, "-zp"); // Zero point
    211         if (!status) {
    212             float zp = ppSimGetZeroPoint (recipe, filter);
    213             psMetadataAddF32(options, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp);
    214         }
    215205    }
    216206
  • branches/eam_branch_20080511/ppSim/src/ppSimCreate.c

    r17702 r17705  
    5353    config->formatName = psStringCopy (output->formatName);
    5454
     55    // the recipe is now fully realized for the desired camera
    5556    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
     57
     58    char *typeStr = psMetadataLookupStr(NULL, recipe, "IMAGE.TYPE"); // Type of image to simulate
     59    ppSimType type = ppSimTypeFromString (typeStr); // Type of image to simulate
     60
     61    if (type == PPSIM_TYPE_OBJECT) {
     62        // adjust the seeing by the scale
     63        float seeing = psMetadataLookupF32(&status, recipe, "SEEING");
     64        if (isnan(seeing)) {
     65            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "seeing is not defined");
     66            psFree(fpa);
     67            return NULL;
     68        }
     69        float scale = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE");
     70        if (isnan(scale)) {
     71            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "pixel scale is not defined");
     72            psFree(fpa);
     73            return NULL;
     74        }
     75        psMetadataAddF32(recipe, PS_LIST_TAIL, "SEEING", PS_META_REPLACE, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale);
     76    }
     77
     78    if ((type == PPSIM_TYPE_OBJECT) || (type == PPSIM_TYPE_FLAT)) {
     79        // determine the zeropoint from the filter
     80        float zp = psMetadataLookupF32(&status, recipe, "ZEROPOINT");
     81        if (isnan(zp)) {
     82            char *filter = psMetadataLookupStr(&status, recipe, "FILTER");
     83            float zp = ppSimGetZeroPoint (recipe, filter);
     84            psMetadataAddF32(recipe, PS_LIST_TAIL, "ZEROPOINT", PS_META_REPLACE, "Photometric zeropoint", zp);
     85        }
     86    }
    5687
    5788    // For photometry, we operate on the chip-mosaicked image.  we create a copy of the mosaicked
     
    115146        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
    116147
    117         ppSimArgToRecipeF32(&status, recipe, "EXPTIME", fpa->concepts, "FPA.EXPOSURE");
    118         char *filter = ppSimArgToRecipeStr(&status, recipe, "FILTER", fpa->concepts, "FPA.FILTER");
     148        ppSimArgToRecipeF32(&status, recipe, "EXPTIME", input->fpa->concepts, "FPA.EXPOSURE");
     149        char *filter = ppSimArgToRecipeStr(&status, recipe, "FILTER", input->fpa->concepts, "FPA.FILTER");
    119150
    120151        float zp = ppSimGetZeroPoint (recipe, filter);
  • branches/eam_branch_20080511/ppSim/src/ppSimInsertStars.c

    r17672 r17705  
    121121        // insert the source flux in the image
    122122        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
     123        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);
    123124        psArrayAdd (sources, 100,source);
    124125        psFree(source);                 // Drop reference
  • branches/eam_branch_20080511/ppSim/src/ppSimLoop.c

    r17702 r17705  
    170170
    171171                if (inputCell && inputCell->readouts->data[i]) {
    172                     if (!ppSimMergeReadouts (readout, inputCell->readouts->data[i])) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image");
     172                    pmReadout *inReadout = inputCell->readouts->data[i];
     173                    if (!inReadout->weight) {
     174                        if (!pmReadoutGenerateWeight(inReadout, true)) {
     175                            psError (PS_ERR_UNKNOWN, false, "trouble creating weight");
     176                            return false;
     177                        }
     178                    }
     179                    if (!ppSimMergeReadouts (readout, inReadout)) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image");
    173180                }
    174181            }
  • branches/eam_branch_20080511/ppSim/src/ppSimMakeBiassec.c

    r14463 r17705  
    66
    77    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
     8
     9    bool bias = psMetadataLookupBool(&mdok, recipe, "BIAS"); // Generate a Bias?
     10    if (!bias) return NULL;
    811
    912    psList *biassec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); // Bias regions
  • branches/eam_branch_20080511/ppSim/src/ppSimMakeSky.c

    r17702 r17705  
    1717    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe
    1818
    19     bool sky = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux?
     19    bool sky  = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux?
     20    bool flat = psMetadataLookupBool(&status, recipe, "FLAT"); // Apply flat-field term?
    2021 
    2122    float expTime      = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time
     
    2425    float flatRate     = psMetadataLookupF32(&status, recipe, "FLAT.RATE"); // Flat-field rate
    2526    float shutterTime  = psMetadataLookupF32(&status, recipe, "SHUTTER.TIME"); // Shutter time
    26     float scatterScale = psMetadataLookupF32(&status, recipe, "SCATTER.SCALE"); // scattered light term
     27    float scatterFrac  = psMetadataLookupF32(&status, recipe, "SCATTER.FRAC"); // scattered light fraction (max)
    2728    float skyRate      = psMetadataLookupF32(&status, recipe, "SKY.RATE"); // Sky rate
    28     if (isnan(skyRate)) {
     29    float skyMags      = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
     30    if (!isnan(skyMags)) {
    2931        float zp       = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status);
    3032        float scale    = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status);
    31         float skyMags  = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
    3233        skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
    3334    }
     
    6970            float realExpTime = expTime + shutterTime * (xFPA + yFPA + 2.0) / 4.0;
    7071
    71             // Gaussian flat-field over the FPA
    72             float flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA))) / flatSigma / sqrtf(2.0 * M_PI);
     72            // Gaussian flat-field over the FPA with flatValue = 1.0 at the field center
     73            float flatValue = 1.0;
     74            if (flat) {
     75                // we make the flat-field have a response of 1.0 at the field center (like a vignetting)
     76                flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA)));
     77            }
    7378
    7479            float scatterRate = 0.0;
     
    7883              if (type == PPSIM_TYPE_FLAT) {
    7984                float xF = 2.0*(xFPA / dXfpa) - 1.0;
    80                 scatterRate = scatterScale * PS_SQR(xF);
     85                scatterRate = scatterFrac * PS_SQR(xF);
    8186              }
    8287
    8388              // Sky background
    84               float skyFlux = (skyRate * flatValue + scatterRate) * realExpTime; // Flux from sky
     89              float skyFlux = (skyRate * (flatValue + scatterRate)) * realExpTime; // Flux from sky
    8590              signal->data.F32[y][x] += skyFlux;
    8691              variance->data.F32[y][x] += skyFlux;
Note: See TracChangeset for help on using the changeset viewer.