Changeset 14667 for trunk/ppSim/src/ppSimLoop.c
- Timestamp:
- Aug 25, 2007, 11:57:36 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimLoop.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimLoop.c
r14657 r14667 17 17 18 18 // Load catalogue stars 19 psArray *stars = NULL;19 psArray *stars = psArrayAllocEmpty (1); 20 20 if (type == PPSIM_TYPE_OBJECT) { 21 stars = ppSimLoadStars (fpa, config);21 ppSimLoadStars (stars, fpa, config); 22 22 } 23 23 … … 25 25 if (type == PPSIM_TYPE_OBJECT) { 26 26 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); 27 33 } 28 34 … … 62 68 while ((cell = pmFPAviewNextCell(view, fpa, 1))) { 63 69 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) 68 71 int readdir = psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR"); // Read direction 69 72 if (readdir != 1) { … … 73 76 } 74 77 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; 76 84 77 int numReadouts = 1; 78 for (int i = 0; i < numReadouts; i++) { 85 // generate a new readout for this cell 79 86 pmReadout *readout = pmReadoutAlloc(cell); // Readout within cell 80 87 … … 83 90 readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels 84 91 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 85 112 psImage *expCorr = NULL; // Exposure correction per pixel, for adding objects 86 113 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); 88 115 } 89 116 90 117 psVector *biasRows = ppSimMakeBias (readout, config, rng); 91 118 if (type == PPSIM_TYPE_BIAS) goto done; 92 119 93 120 ppSimMakeDark (readout, config); 94 121 if (type == PPSIM_TYPE_DARK) goto done; … … 99 126 if (type == PPSIM_TYPE_OBJECT) { 100 127 ppSimInsertSources (readout, expCorr, stars, config); 128 } 129 130 if (type == PPSIM_TYPE_OBJECT) { 131 ppSimInsertGalaxies (readout, expCorr, galaxies, config); 101 132 } 102 133 … … 111 142 readout->parent->data_exists = true; 112 143 readout->parent->parent->data_exists = true; 113 psFree(readout); // Drop reference114 144 } 115 145 psFree(biasCols);
Note:
See TracChangeset
for help on using the changeset viewer.
