IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2007, 2:52:55 PM (19 years ago)
Author:
eugene
Message:

finish code re-org, add loading of external psf model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimLoop.c

    r14531 r14657  
    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);
     
    2929    pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA
    3030
     31    // XXX if we include the psphot analysis, we will need to activate the correct pmFPAfiles
     32    // at the correct times.  ppSim operates on PPSIM.OUTPUT and PPSIM.SOURCES
     33
    3134    // load any needed files (eg, input image, PSF)
    3235    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    33         psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in ppSim\n");
     36        psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in ppSim\n");
    3437        psFree(view);
    3538        return false;
     
    4346        // load any needed files (eg, input image, PSF)
    4447        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    45             psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in ppSim\n", view->chip);
     48            psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip);
    4649            psFree (view);
    4750            return false;
    4851        }
    4952
    50         pmPSF *psf = NULL;
    5153        if (type == PPSIM_TYPE_OBJECT) {
    52             psf = ppSimSetPSF (config);
     54            if (!ppSimSetPSF (chip, config)) {
     55                psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip);
     56                psFree (view);
     57                return false;
     58            }
    5359        }
    5460
     
    6470                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "CELL.READDIR = 1 is the only supported mode.");
    6571                psFree(rng);
    66                 return PS_EXIT_CONFIG_ERROR;
     72                return false;
    6773            }
    6874
     
    7480
    7581                // TO DO: Decide if cell is to be windowed, reduce numCols, numRows appropriately
    76                 psImage *signal = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels
    77                 psImage *variance = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels
     82                readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels
     83                readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels
    7884
    7985                psImage *expCorr = NULL; // Exposure correction per pixel, for adding objects
     
    8288                }
    8389
    84                 psVector *biasRows = ppSimMakeBias (signal, variance, cell, config, rng);
     90                psVector *biasRows = ppSimMakeBias (readout, config, rng);
    8591                if (type == PPSIM_TYPE_BIAS) goto done;
    8692               
    87                 ppSimMakeDark (signal, variance, config);
     93                ppSimMakeDark (readout, config);
    8894                if (type == PPSIM_TYPE_DARK) goto done;
    8995
    90                 ppSimMakeSky (signal, variance, expCorr, type, config, fpa, chip, cell);
     96                ppSimMakeSky (readout, expCorr, type, config);
    9197                if (type == PPSIM_TYPE_FLAT) goto done;
    9298
    9399                if (type == PPSIM_TYPE_OBJECT) {
    94                     ppSimInsertStars (signal, variance, expCorr, stars, config, chip, cell);
     100                    ppSimInsertSources (readout, expCorr, stars, config);
    95101                }
    96102
    97103            done:
    98                 ppSimAddNoise(signal, variance, config, cell, rng);
    99                 ppSimSaturate(signal, config, cell);
    100 
    101                 readout->image = signal;
    102                 psFree(variance);
    103                 psFree(expCorr);
     104                ppSimAddNoise(readout->image, readout->weight, cell, config, rng);
     105                ppSimSaturate(readout, config);
    104106
    105107                ppSimAddOverscan (readout, config, biasCols, biasRows, rng);
     
    123125                psFree(rng);
    124126                psFree(view);
    125                 return PS_EXIT_SYS_ERROR;
     127                // return PS_EXIT_SYS_ERROR;
     128                return false;
    126129            }
    127130        }
     
    135138            psFree(rng);
    136139            psFree(view);
    137             return PS_EXIT_SYS_ERROR;
     140            // return PS_EXIT_SYS_ERROR;
     141            return false;
    138142        }
    139143
     
    148152        psFree(rng);
    149153        psFree(view);
    150         return PS_EXIT_SYS_ERROR;
     154        // return PS_EXIT_SYS_ERROR;
     155        return false;
    151156    }
    152157
     
    154159    psFree(view);
    155160
    156     return 0;
     161    return true;
    157162}
Note: See TracChangeset for help on using the changeset viewer.