Changeset 14815
- Timestamp:
- Sep 11, 2007, 12:33:52 PM (19 years ago)
- Location:
- trunk/ppSim/src
- Files:
-
- 2 edited
-
ppSim.c (modified) (1 diff)
-
ppSimLoop.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSim.c
r14657 r14815 27 27 28 28 psFree(config); 29 pmModelClassCleanup(); 29 30 pmConfigDone(); 30 31 pmConceptsDone(); -
trunk/ppSim/src/ppSimLoop.c
r14668 r14815 19 19 psArray *stars = psArrayAllocEmpty (1); 20 20 if (type == PPSIM_TYPE_OBJECT) { 21 ppSimLoadStars (stars, fpa, config);21 ppSimLoadStars (stars, fpa, config); 22 22 } 23 23 24 24 // Add random stars 25 25 if (type == PPSIM_TYPE_OBJECT) { 26 ppSimMakeStars (stars, fpa, config, rng);26 ppSimMakeStars (stars, fpa, config, rng); 27 27 } 28 28 … … 30 30 psArray *galaxies = psArrayAllocEmpty (1); 31 31 if (type == PPSIM_TYPE_OBJECT) { 32 ppSimMakeGalaxies (galaxies, fpa, config, rng);32 ppSimMakeGalaxies (galaxies, fpa, config, rng); 33 33 } 34 34 … … 40 40 // load any needed files (eg, input image, PSF) 41 41 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 42 psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in ppSim\n");43 psFree(view);44 return false;42 psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in ppSim\n"); 43 psFree(view); 44 return false; 45 45 } 46 46 … … 50 50 while ((chip = pmFPAviewNextChip(view, fpa, 1))) { 51 51 52 // load any needed files (eg, input image, PSF)53 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {52 // load any needed files (eg, input image, PSF) 53 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 54 54 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip); 55 psFree (view);56 return false;57 }55 psFree (view); 56 return false; 57 } 58 58 59 if (type == PPSIM_TYPE_OBJECT) {60 if (!ppSimSetPSF (chip, config)) {61 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip);62 psFree (view);63 return false;64 }65 }59 if (type == PPSIM_TYPE_OBJECT) { 60 if (!ppSimSetPSF (chip, config)) { 61 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in ppSim\n", view->chip); 62 psFree (view); 63 return false; 64 } 65 } 66 66 67 67 pmCell *cell; // Cell from chip 68 68 while ((cell = pmFPAviewNextCell(view, fpa, 1))) { 69 69 70 // check that we are able to work with this cell (readdir must be 1)70 // check that we are able to work with this cell (readdir must be 1) 71 71 int readdir = psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR"); // Read direction 72 72 if (readdir != 1) { … … 76 76 } 77 77 78 // if no readout exists, generate a single readout (upgrade to allow multiple79 // readouts?)80 if (cell->readouts->n == 0) {81 // Size, position and orientation of cell82 int numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE") / binning;83 int numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE") / binning;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; 84 84 85 // generate a new readout for this cell85 // generate a new readout for this cell 86 86 pmReadout *readout = pmReadoutAlloc(cell); // Readout within cell 87 87 88 // TO DO: Decide if cell is to be windowed, reduce numCols, numRows appropriately88 // TO DO: Decide if cell is to be windowed, reduce numCols, numRows appropriately 89 89 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels 90 90 readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels 91 91 92 psImageInit (readout->image, 0.0); 93 psImageInit (readout->weight, 0.0); 94 } 92 psImageInit (readout->image, 0.0); 93 psImageInit (readout->weight, 0.0); 95 94 96 psVector *biasCols = ppSimMakeBiassec (cell, config); 95 psFree(readout); // Drop reference 96 } 97 98 psVector *biasCols = ppSimMakeBiassec (cell, config); 97 99 98 100 for (int i = 0; i < cell->readouts->n; i++) { 99 101 100 pmReadout *readout = cell->readouts->data[i];101 assert (readout);102 pmReadout *readout = cell->readouts->data[i]; 103 assert (readout); 102 104 103 // if we have not read in a weight or generated a fake image above, we need to104 // build one here105 if (!readout->weight) {106 if (!pmReadoutGenerateWeight(readout, true)) {107 psError (PS_ERR_UNKNOWN, false, "trouble creating weight");108 return false;109 }110 }105 // if we have not read in a weight or generated a fake image above, we need to 106 // build one here 107 if (!readout->weight) { 108 if (!pmReadoutGenerateWeight(readout, true)) { 109 psError (PS_ERR_UNKNOWN, false, "trouble creating weight"); 110 return false; 111 } 112 } 111 113 112 114 psImage *expCorr = NULL; // Exposure correction per pixel, for adding objects … … 115 117 } 116 118 117 psVector *biasRows = ppSimMakeBias (readout, config, rng); 118 if (type == PPSIM_TYPE_BIAS) goto done; 119 120 ppSimMakeDark (readout, config); 121 if (type == PPSIM_TYPE_DARK) goto done; 119 psVector *biasRows = ppSimMakeBias (readout, config, rng); 120 if (type == PPSIM_TYPE_BIAS) goto done; 122 121 123 ppSimMakeSky (readout, expCorr, type, config);124 if (type == PPSIM_TYPE_FLAT) goto done;122 ppSimMakeDark (readout, config); 123 if (type == PPSIM_TYPE_DARK) goto done; 125 124 126 if (type == PPSIM_TYPE_OBJECT) { 127 ppSimInsertStars (readout, expCorr, stars, config); 128 } 125 ppSimMakeSky (readout, expCorr, type, config); 126 if (type == PPSIM_TYPE_FLAT) goto done; 129 127 130 if (type == PPSIM_TYPE_OBJECT) {131 ppSimInsertGalaxies (readout, expCorr, galaxies, config);132 }128 if (type == PPSIM_TYPE_OBJECT) { 129 ppSimInsertStars (readout, expCorr, stars, config); 130 } 133 131 134 done: 135 ppSimAddNoise(readout->image, readout->weight, cell, config, rng); 132 if (type == PPSIM_TYPE_OBJECT) { 133 ppSimInsertGalaxies (readout, expCorr, galaxies, config); 134 } 135 136 psFree(expCorr); 137 138 done: 139 ppSimAddNoise(readout->image, readout->weight, cell, config, rng); 136 140 ppSimSaturate(readout, config); 137 141 138 ppSimAddOverscan (readout, config, biasCols, biasRows, rng);142 ppSimAddOverscan (readout, config, biasCols, biasRows, rng); 139 143 psFree(biasRows); 140 144 … … 145 149 psFree(biasCols); 146 150 147 ppSimUpdateConceptsCell (cell, config);151 ppSimUpdateConceptsCell (cell, config); 148 152 149 153 if (cell->hdu) { … … 174 178 } 175 179 180 psFree(stars); 181 psFree(galaxies); 182 176 183 if (fpa->hdu) { 177 184 ppSimInitHeader(config, fpa, NULL, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
