IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2008, 1:52:32 PM (18 years ago)
Author:
eugene
Message:

significant work on the I/O pmFPAfiles, especially to get the format / metaCamera correct for the input psf vs the input image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080511/ppSim/src/ppSimPhotomReadout.c

    r17851 r17901  
    11# include "ppSim.h"
     2
     3psArray *ppSimSelectSources (pmConfig *config, const pmFPAview *view, const char *filename) {
     4
     5    pmReadout *readout = pmFPAfileThisReadout (config->files, view, filename);
     6    PS_ASSERT_PTR_NON_NULL (readout, NULL);
     7
     8    psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
     9    return sources;
     10}
     11
     12bool ppSimDefinePixels (psArray *sources, pmReadout *readout, psMetadata *recipe) {
     13
     14    bool status;
     15
     16    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     17    if (!status) return NULL;
     18
     19    for (int i = 0; i < sources->n; i++) {
     20        pmSource *source = sources->data[i];
     21
     22        // allocate image, weight, mask arrays for each peak (square of radius OUTER)
     23        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
     24    }
     25    return true;
     26}
    227
    328bool ppSimPhotomReadout(pmConfig *config, const pmFPAview *view) {
     
    1338
    1439    // set the photcode for this image
    15     if (!psphotAddPhotcode (recipe, config, view)) {
     40    if (!psphotAddPhotcode (recipe, config, view, "PPSIM.CHIP")) {
    1641        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    1742        return false;
     
    2348    PS_ASSERT_PTR_NON_NULL (readout, false);
    2449
    25     pmReadout *realSourceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.REAL.SOURCES");
    26     PS_ASSERT_PTR_NON_NULL (realSourceReadout, false);
     50    // the previously measured real sources are loaded into the PPSIM.REAL.SOURCES pmFPAfile
     51    psArray *realSources = ppSimSelectSources (config, view, "PPSIM.REAL.SOURCES");
     52    PS_ASSERT_PTR_NON_NULL (realSources, false);
     53
     54    // the newly injected fake sources are saved on the PPSIM.OUTPUT pmFPAfile
     55    psArray *injectedSources = ppSimSelectSources (config, view, "PPSIM.OUTPUT");
     56    PS_ASSERT_PTR_NON_NULL (injectedSources, false);
     57
     58    // XXX need to define the source pixels
     59    ppSimDefinePixels (realSources, readout, recipe);
     60    ppSimDefinePixels (injectedSources, readout, recipe);
     61
     62    // make a copy of the fake-source parameters so these can be saved independently from the
     63    // measured fake-source parameters
     64    psArray *fakeSources = psArrayAlloc (injectedSources->n);
     65    for (int i = 0; i < injectedSources->n; i++) {
     66      fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);
     67    }
     68
     69    // load the forced source lists
     70    psArray *forceSources = ppSimLoadForceSources (config, view);
     71    psAssert (forceSources, "failed to load force photometry sources");
    2772
    2873    // Generate the mask and weight images, including the user-defined analysis region of interest
     
    3378    pmPSF *psf = psphotLoadPSF (config, view, recipe);
    3479    assert (psf);
    35 
    36     // load the source lists
    37     // PPSIM.REAL.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)
    38     psArray *realSources = psMetadataLookupPtr (NULL, realSourceReadout->analysis, "PSPHOT.SOURCES");
    39     psArray *forceSources = ppSimLoadForceSources (config, view);
    40 
    41     // XXX make a copy of the fake-source parameters so these can be saved independently
    42     // from the measured fake-source parameters
    43     psArray *injectedSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
    44     psArray *fakeSources = psArrayAlloc (injectedSources->n);
    45     for (int i = 0; i < injectedSources->n; i++) {
    46       fakeSources->data[i] = pmSourceCopy (injectedSources->data[i]);
    47     }
    4880
    4981    // remove all sources
     
    97129    // XXX for the fake sources, these must be identically zero
    98130    // XXX for the force sources, need the apresid to put the mags on the correct system
    99     if (!psphotApResid (readout, forceSources, recipe, psf)) {
    100         psLogMsg ("psphot", 3, "failed on psphotApResid");
    101         return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL);
     131    if (0) {
     132        if (!psphotApResid (readout, forceSources, recipe, psf)) {
     133            psLogMsg ("psphot", 3, "failed on psphotApResid");
     134            return psphotReadoutCleanup (config, readout, recipe, NULL, psf, NULL);
     135        }
    102136    }
    103137
     
    119153    // add forceSources to the readout (real and fake already there)
    120154    // these are outputs: we need to generate the fpa structure
    121     // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FAKE.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources);
     155   
     156    pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES");
     157    psMetadataAdd (fakeReadout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "fake photometry ", fakeSources);
     158
    122159    // psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PPSIM.FORCE.SOURCES", PS_DATA_ARRAY, "forced photometry ", forceSources);
    123160    psFree (forceSources);
Note: See TracChangeset for help on using the changeset viewer.