IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17630


Ignore:
Timestamp:
May 11, 2008, 10:10:06 AM (18 years ago)
Author:
eugene
Message:

working on injecting fake sources in real images (also forced photometry)

Location:
branches/eam_branch_20080511/ppSim/src
Files:
4 edited

Legend:

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

    r16500 r17630  
    2424        ppSimUtils.c            \
    2525        ppSimLoop.c             \
     26        ppSimLoadSpots.c        \
     27        ppSimPhotom.c           \
     28        ppSimMosaicChip.c       \
    2629        ppSimBadPixels.c
    2730
  • branches/eam_branch_20080511/ppSim/src/ppSim.h

    r17557 r17630  
    9898bool ppSimMakeSky (pmReadout *readout, psImage *expCorr, ppSimType type, pmConfig *config);
    9999
     100psArray *ppSimLoadSpots (pmFPA *fpa, pmConfig *config);
     101
    100102bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config);
    101103bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
     
    127129bool ppSimInsertGalaxies (pmReadout *readout, psImage *expCorr, psArray *galaxies, pmConfig *config);
    128130
     131bool ppSimMosaicChip(pmConfig *config, const psMaskType blankMask, const pmFPAview *view,
     132                     const char *outFile, const char *inFile);
     133
     134bool ppSimPhotom (pmConfig *config, pmFPAview *view);
     135
     136
    129137/// Add bad pixels to an image
    130138bool ppSimBadPixels(pmReadout *readout, ///< Readout for which to generate bad pixels
  • branches/eam_branch_20080511/ppSim/src/ppSimCreate.c

    r17557 r17630  
    4040    }
    4141
    42     // define the output image file
     42    // define the output image file -- this is the basis for the ppSimLoop
    4343    pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, OUTPUT_FILE);
    4444    if (!file) {
     
    5353        return NULL;
    5454    }
     55    // XXX we should not require the output image to be written
    5556    file->save = true;
    5657
     
    5859    config->formatName = psStringCopy (file->formatName);
    5960
    60     // have we supplied a psf model?
    61     if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
    62         bool status = false;
     61    // For photometry, we operate on the chip-mosaicked image.  we create a copy of the mosaicked
     62    // image for psphot so we can write out a clean image
     63    if (options->doPhotom) {
    6364
    64         // tie the psf file to the chipMosaic
    65         pmFPAfileBindFromArgs(&status, file, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
    66         if (!status) {
    67             psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
    68             psFree(fpa);
    69             psFree(file);
    70             return NULL;
     65        // we need a chip image if we perform photometry (is it necessary to build it if we don't use it?)
     66        pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, output->fpa, "PPSIM.CHIP");
     67        if (!chipImage) {
     68            psError(PS_ERR_IO, false, _("Unable to generate new file from PPSIM.CHIP"));
     69            psFree(options);
     70            return NULL;
     71        }
     72        if (chipImage->type != PM_FPA_FILE_IMAGE) {
     73            psError(PS_ERR_IO, true, "PPSIM.CHIP is not of type IMAGE");
     74            psFree(options);
     75            return NULL;
     76        }
     77
     78        // this file is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by
     79        // psphotDefineFiles
     80        pmFPAfile *psphotInput = pmFPAfileDefineFromFile (config, chipImage, 1, 1, "PSPHOT.INPUT");
     81        PS_ASSERT (psphotInput, false);
     82
     83        // define associated psphot input/output files
     84        if (!psphotDefineFiles (config, psphotInput)) {
     85            psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
     86            return false;
    7187        }
     88    } else {
     89        // have we supplied a psf model?  this happens in psphotDefineFiles if we request a photometry
     90        // analysis.  however, even if we do not, a psf model may be used to generate the fake
     91        // sources.
     92        if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
     93            // tie the psf file to the chipMosaic
     94            pmFPAfileBindFromArgs(&status, file, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
     95            if (!status) {
     96                psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
     97                psFree(fpa);
     98                psFree(file);
     99                return NULL;
     100            }
     101        }
    72102    }
    73103
     104    // PPSIM.SOURCES carries the constructed, fake sources with their true parameters
    74105    // XXX only invoke this code for OBJECT types of images
    75     // PPSIM.SOURCES carries the constructed, fake sources with their true parameters
    76106    pmFPAfile *simSources = pmFPAfileDefineOutput (config, file->fpa, "PPSIM.SOURCES");
    77107    if (!simSources) {
  • branches/eam_branch_20080511/ppSim/src/ppSimLoop.c

    r15482 r17630  
    55    PS_ASSERT_PTR_NON_NULL(config, PS_EXIT_PROG_ERROR);
    66
     7    // in this program, we are looping over the output image, rather than the input as in ppImage
    78    pmFPAfile *file = psMetadataLookupPtr(NULL, config->files, OUTPUT_FILE); // Output file
    89    assert(file);
     
    1516
    1617    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
     18
     19    // Load forced-photometry positions
     20    if (type == PPSIM_TYPE_OBJECT) {
     21      psArray *spots = ppSimLoadSpots (fpa, config);
     22    }
    1723
    1824    // Load catalogue stars
     
    170176        }
    171177
     178        ppSimMosaicChip(config, blankMask, view, "PPSIM.CHIP", "PPSIM.OUTPUT");
     179
     180        // we perform photometry on the readouts of this chip in the output
     181        ppSimPhotom (config, view);
     182
    172183        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    173184            psError(PS_ERR_IO, false, "Unable to write file.");
Note: See TracChangeset for help on using the changeset viewer.