IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 15, 2008, 12:01:36 PM (18 years ago)
Author:
eugene
Message:

working on getting the input image options right

File:
1 edited

Legend:

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

    r17672 r17702  
    88bool ppSimLoop(pmConfig *config)
    99{
     10    bool status;
     11
    1012    PS_ASSERT_PTR_NON_NULL(config, PS_EXIT_PROG_ERROR);
    1113
     
    1315    pmFPAfile *file = psMetadataLookupPtr(NULL, config->files, OUTPUT_FILE); // Output file
    1416    assert(file);
     17
     18    // if we have an input image, we need to add the synthetic data on top of it below
     19    // XXX we may potentially use this input file to skip missing elements
     20    pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.INPUT");
    1521
    1622    pmFPA *fpa = file->fpa;             // FPA for file
     
    105111
    106112            psVector *biasCols = ppSimMakeBiassec (cell, config);
     113
     114            pmCell *inputCell = NULL;
     115            if (input) {
     116                inputCell = pmFPAviewThisCell (view, input->fpa);
     117            }
    107118
    108119            for (int i = 0; i < cell->readouts->n; i++) {
     
    125136                }
    126137
    127                 psVector *biasRows = ppSimMakeBias (readout, config, rng);
     138                psVector *biasRows = ppSimMakeBias (&status, readout, config, rng);
     139                if (!status) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
    128140                if (type == PPSIM_TYPE_BIAS) goto done;
    129141
    130                 ppSimMakeDark (readout, config);
     142                if (!ppSimMakeDark (readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
    131143                if (type == PPSIM_TYPE_DARK) goto done;
    132144
    133                 ppSimMakeSky (readout, expCorr, type, config);
     145                if (!ppSimMakeSky (readout, expCorr, type, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating sky background");
    134146                if (type == PPSIM_TYPE_FLAT) goto done;
    135147
    136148                if (type == PPSIM_TYPE_OBJECT) {
    137                     ppSimInsertStars (readout, expCorr, stars, config);
     149                    if (!ppSimInsertStars (readout, expCorr, stars, config)) ESCAPE (PS_ERR_UNKNOWN, "problem inserting stars");
    138150                }
    139151
    140152                if (type == PPSIM_TYPE_OBJECT) {
    141                     ppSimInsertGalaxies (readout, expCorr, galaxies, config);
     153                    if (!ppSimInsertGalaxies (readout, expCorr, galaxies, config)) ESCAPE (PS_ERR_UNKNOWN, "problem inserting galaxies");
    142154                }
    143155
     
    145157
    146158            done:
    147                 ppSimAddNoise(readout->image, readout->weight, cell, config, rng);
    148                 ppSimSaturate(readout, config);
    149 
    150                 ppSimBadPixels(readout, config, rng);
    151 
    152                 ppSimAddOverscan (readout, config, biasCols, biasRows, rng);
     159                if (!ppSimAddNoise(readout->image, readout->weight, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
     160                if (!ppSimSaturate(readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem setting saturation levels");
     161
     162                if (!ppSimBadPixels(readout, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding bad pixels");
     163
     164                if (!ppSimAddOverscan (readout, config, biasCols, biasRows, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding overscan region");
    153165                psFree(biasRows);
    154166
     
    156168                readout->parent->data_exists = true;
    157169                readout->parent->parent->data_exists = true;
     170
     171                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");
     173                }
    158174            }
    159175            psFree(biasCols);
    160176
    161             ppSimUpdateConceptsCell (cell, config);
     177            if (!ppSimUpdateConceptsCell (cell, config)) ESCAPE (PS_ERR_UNKNOWN, "problem updating cell concepts");
    162178
    163179            if (cell->hdu) {
    164                 ppSimInitHeader(config, NULL, NULL, cell);
     180                // XXX only do this if there is no INPUT image?
     181                if (!ppSimInitHeader(config, NULL, NULL, cell)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
    165182            }
    166183
     
    175192
    176193        if (chip->hdu) {
    177             ppSimInitHeader(config, NULL, chip, NULL);
     194            // XXX only do this if there is no INPUT image
     195            if (!ppSimInitHeader(config, NULL, chip, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
    178196        }
    179197
    180198        // we perform photometry on the readouts of this chip in the output
    181         ppSimPhotom (config, view);
     199        if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
    182200
    183201        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     
    185203            psFree(rng);
    186204            psFree(view);
    187             // return PS_EXIT_SYS_ERROR;
    188205            return false;
    189206        }
     
    195212
    196213    if (fpa->hdu) {
    197         ppSimInitHeader(config, fpa, NULL, NULL);
     214        // XXX only do this if there is no INPUT image
     215        if (!ppSimInitHeader(config, fpa, NULL, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
    198216    }
    199217
     
    202220        psFree(rng);
    203221        psFree(view);
    204         // return PS_EXIT_SYS_ERROR;
    205222        return false;
    206223    }
Note: See TracChangeset for help on using the changeset viewer.