IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 25, 2007, 11:57:36 AM (19 years ago)
Author:
eugene
Message:

added galaxies, some tweaks

File:
1 edited

Legend:

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

    r14657 r14667  
    1717
    1818    // Load catalogue stars
    19     psArray *stars = NULL;
     19    psArray *stars = psArrayAllocEmpty (1);
    2020    if (type == PPSIM_TYPE_OBJECT) {
    21         stars = ppSimLoadStars (fpa, config);
     21        ppSimLoadStars (stars, fpa, config);
    2222    }
    2323
     
    2525    if (type == PPSIM_TYPE_OBJECT) {
    2626        ppSimMakeStars (stars, fpa, config, rng);
     27    }
     28
     29    // Add random galaxies
     30    psArray *galaxies = psArrayAllocEmpty (1);
     31    if (type == PPSIM_TYPE_OBJECT) {
     32        ppSimMakeGalaxies (galaxies, fpa, config, rng);
    2733    }
    2834
     
    6268        while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
    6369
    64             // Size, position and orientation of cell
    65             int numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE") / binning;
    66             int numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE") / binning;
    67 
     70            // check that we are able to work with this cell (readdir must be 1)
    6871            int readdir = psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR"); // Read direction
    6972            if (readdir != 1) {
     
    7376            }
    7477
    75             psVector *biasCols = ppSimMakeBiassec (cell, config);
     78            // if no readout exists, generate a single readout (upgrade to allow multiple
     79            // readouts?)
     80            if (cell->readouts->n == 0) {
     81                // Size, position and orientation of cell
     82                int numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE") / binning;
     83                int numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE") / binning;
    7684
    77             int numReadouts = 1;
    78             for (int i = 0; i < numReadouts; i++) {
     85                // generate a new readout for this cell
    7986                pmReadout *readout = pmReadoutAlloc(cell); // Readout within cell
    8087
     
    8390                readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels
    8491
     92                psImageInit (readout->image, 0.0);
     93                psImageInit (readout->weight, 0.0);
     94            }
     95
     96            psVector *biasCols = ppSimMakeBiassec (cell, config);
     97
     98            for (int i = 0; i < cell->readouts->n; i++) {
     99
     100                pmReadout *readout = cell->readouts->data[i];
     101                assert (readout);
     102
     103                // if we have not read in a weight or generated a fake image above, we need to
     104                // build one here
     105                if (!readout->weight) {
     106                    if (!pmReadoutGenerateWeight(readout, true)) {
     107                        psError (PS_ERR_UNKNOWN, false, "trouble creating weight");
     108                        return false;
     109                    }
     110                }
     111
    85112                psImage *expCorr = NULL; // Exposure correction per pixel, for adding objects
    86113                if (type == PPSIM_TYPE_OBJECT) {
    87                     expCorr = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     114                    expCorr = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32);
    88115                }
    89116
    90117                psVector *biasRows = ppSimMakeBias (readout, config, rng);
    91118                if (type == PPSIM_TYPE_BIAS) goto done;
    92                
     119       
    93120                ppSimMakeDark (readout, config);
    94121                if (type == PPSIM_TYPE_DARK) goto done;
     
    99126                if (type == PPSIM_TYPE_OBJECT) {
    100127                    ppSimInsertSources (readout, expCorr, stars, config);
     128                }
     129
     130                if (type == PPSIM_TYPE_OBJECT) {
     131                    ppSimInsertGalaxies (readout, expCorr, galaxies, config);
    101132                }
    102133
     
    111142                readout->parent->data_exists = true;
    112143                readout->parent->parent->data_exists = true;
    113                 psFree(readout);        // Drop reference
    114144            }
    115145            psFree(biasCols);
Note: See TracChangeset for help on using the changeset viewer.