IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14614


Ignore:
Timestamp:
Aug 22, 2007, 3:05:47 PM (19 years ago)
Author:
eugene
Message:

load / apply psf model from external source

Location:
branches/eam_branch_20070817/ppSim/src
Files:
1 added
7 edited

Legend:

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

    r14547 r14614  
    1919        ppSimBounds.c           \
    2020        ppSimStars.c            \
     21        ppSimSetPSF.c           \
    2122        ppSimUtils.c            \
    2223        ppSimLoop.c
  • branches/eam_branch_20070817/ppSim/src/ppSim.c

    r14463 r14614  
    44{
    55    psLibInit(NULL);
     6    if (!pmModelClassInit ()) abort();
     7
    68    pmConfig *config = pmConfigRead(&argc, argv, NULL); // Configuration
    79    if (!config) {
     
    1820    }
    1921
    20     psExit loopError;
    21     if ((loopError = ppSimLoop(config))) {
     22    if (!ppSimLoop(config)) {
    2223        psErrorStackPrint(stderr, "Unable to generate data.");
    2324        psFree(config);
    24         exit(loopError);
     25        exit(PS_EXIT_SYS_ERROR);
    2526    }
    2627
  • branches/eam_branch_20070817/ppSim/src/ppSim.h

    r14547 r14614  
    7272
    7373/// Loop over the output file, generating simulated data
    74 psExit ppSimLoop(pmConfig *config ///< Configuration
     74bool ppSimLoop(pmConfig *config ///< Configuration
    7575                 );
    7676
     
    115115    );
    116116
     117bool ppSimSetPSF (pmChip *chip, pmConfig *config);
     118
    117119#endif
  • branches/eam_branch_20070817/ppSim/src/ppSimArguments.c

    r14531 r14614  
    6666    psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsmag", 0, "Brightest magnitude for fake stars", NAN);
    6767    psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsdensity", 0, "Density of fake stars at magnitude", NAN);
     68    psMetadataAddStr(arguments, PS_LIST_TAIL, "-psfclass", 0, "Type of PSF model", NULL);
    6869    psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1);
    6970
     
    194195        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",
    195196                         pa * M_PI / 180.0);
     197
     198
     199        const char *psfClass = psMetadataLookupStr(NULL, arguments, "-psfclass"); // Filter name
     200        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "PSF.MODEL", 0, "PSF model class", psfClass);
    196201    }
    197202
  • branches/eam_branch_20070817/ppSim/src/ppSimCreate.c

    r14547 r14614  
    11# include "ppSim.h"
     2
     3// XXX this function forces us to define the camera (on the command line) and format (via the
     4// PPSIM.OUTPUT entry).  In this case, we need to set config->format,formatName based on these
     5// values.  This will be a problem when we want to load an input image (in order to add fake
     6// stars).  We will need to add some logic in ppSimArguments to distinguish the cases of 1)
     7// input image and 2) specified camera
    28
    39pmFPAfile *ppSimCreate(pmConfig *config)
     
    2531    file->save = true;
    2632
     33    config->format = psMemIncrRefCounter (file->format);
     34    config->formatName = psStringCopy (file->formatName);
     35
    2736    // have we supplied a psf model?
    2837    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
    2938        bool status = false;
     39
     40        // tie the psf file to the chipMosaic
    3041        pmFPAfileBindFromArgs(&status, file, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
    3142        if (!status) {
  • branches/eam_branch_20070817/ppSim/src/ppSimInsertSources.c

    r14547 r14614  
    33bool ppSimInsertSources (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config) {
    44
     5    bool mdok;
    56
    67    assert (stars);
     8    assert (readout);
    79   
    810    pmCell *cell = readout->parent;
    911    pmChip *chip = cell->parent;
    1012
    11     // XXX we probably need this to get the size right
    12 # if (0)
    13     bool mdok;
     13    // XXX this is an estimate of the sky noise based on the inputs to the image simulation.
     14    // XXX update this to allow the estimate based on the measured sky background
     15    // XXX this is missing the gain.
    1416    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
    1517
     
    2931    // Rough noise estimate, appropriate for entire cell (use for source radius?)
    3032    float roughNoise = sqrtf(PS_SQR(readnoise) + (darkRate + skyRate) * expTime);
    31 # endif
    3233
    3334    int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
     
    4344    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
    4445
    45     pmPSF *psf = psMetadataLookupPtr (NULL, chip->analysis, "PSF");
     46    pmPSF *psf = psMetadataLookupPtr (&mdok, chip->analysis, "PSPHOT.PSF");
     47    assert (psf);
    4648
    4749    int dX = PM_CELL_TO_CHIP (0.0, x0Cell, xParityCell, binning);
     
    7476        pmModelSetFlux (model, star->flux);
    7577
     78        // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
     79        float radius = model->modelRadius (model->params, roughNoise);
     80        radius = PS_MAX (radius, 1.0);
     81
    7682        // construct a source, with model flux pixels set, based on the model
    77         pmSource *source = pmSourceFromModel (model, readout, PM_SOURCE_TYPE_STAR);
     83        pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
    7884
    7985        // XXX add the sources to a source array
    8086
     87        // insert the source flux in the image
    8188        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
    8289    }
  • branches/eam_branch_20070817/ppSim/src/ppSimLoop.c

    r14547 r14614  
    11#include "ppSim.h"
    22
    3 psExit ppSimLoop(pmConfig *config)
     3bool ppSimLoop(pmConfig *config)
    44{
    55    PS_ASSERT_PTR_NON_NULL(config, PS_EXIT_PROG_ERROR);
     
    4848        }
    4949
    50         // XXX check for a supplied PSF, otherwise generate a basic one
    5150        if (type == PPSIM_TYPE_OBJECT) {
    52             // XXX TBD : ppSimSetPSF (chip, config);
     51            if (!ppSimSetPSF (chip, config)) {
     52                psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip);
     53                psFree (view);
     54                return false;
     55            }
    5356        }
    5457
     
    6467                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "CELL.READDIR = 1 is the only supported mode.");
    6568                psFree(rng);
    66                 return PS_EXIT_CONFIG_ERROR;
     69                return false;
    6770            }
    6871
     
    9093                ppSimMakeSky (readout, expCorr, type, config);
    9194                if (type == PPSIM_TYPE_FLAT) goto done;
    92 
    93                 // if (type == PPSIM_TYPE_OBJECT) {
    94                 // ppSimInsertStars (readout, expCorr, stars, config, chip, cell);
    95                 // }
    9695
    9796                if (type == PPSIM_TYPE_OBJECT) {
     
    123122                psFree(rng);
    124123                psFree(view);
    125                 return PS_EXIT_SYS_ERROR;
     124                // return PS_EXIT_SYS_ERROR;
     125                return false;
    126126            }
    127127        }
     
    135135            psFree(rng);
    136136            psFree(view);
    137             return PS_EXIT_SYS_ERROR;
     137            // return PS_EXIT_SYS_ERROR;
     138            return false;
    138139        }
    139140
     
    148149        psFree(rng);
    149150        psFree(view);
    150         return PS_EXIT_SYS_ERROR;
     151        // return PS_EXIT_SYS_ERROR;
     152        return false;
    151153    }
    152154
     
    154156    psFree(view);
    155157
    156     return 0;
     158    return true;
    157159}
Note: See TracChangeset for help on using the changeset viewer.