Changeset 17702 for branches/eam_branch_20080511/ppSim/src/ppSimLoop.c
- Timestamp:
- May 15, 2008, 12:01:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimLoop.c
r17672 r17702 8 8 bool ppSimLoop(pmConfig *config) 9 9 { 10 bool status; 11 10 12 PS_ASSERT_PTR_NON_NULL(config, PS_EXIT_PROG_ERROR); 11 13 … … 13 15 pmFPAfile *file = psMetadataLookupPtr(NULL, config->files, OUTPUT_FILE); // Output file 14 16 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"); 15 21 16 22 pmFPA *fpa = file->fpa; // FPA for file … … 105 111 106 112 psVector *biasCols = ppSimMakeBiassec (cell, config); 113 114 pmCell *inputCell = NULL; 115 if (input) { 116 inputCell = pmFPAviewThisCell (view, input->fpa); 117 } 107 118 108 119 for (int i = 0; i < cell->readouts->n; i++) { … … 125 136 } 126 137 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"); 128 140 if (type == PPSIM_TYPE_BIAS) goto done; 129 141 130 ppSimMakeDark (readout, config);142 if (!ppSimMakeDark (readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure"); 131 143 if (type == PPSIM_TYPE_DARK) goto done; 132 144 133 ppSimMakeSky (readout, expCorr, type, config);145 if (!ppSimMakeSky (readout, expCorr, type, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating sky background"); 134 146 if (type == PPSIM_TYPE_FLAT) goto done; 135 147 136 148 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"); 138 150 } 139 151 140 152 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"); 142 154 } 143 155 … … 145 157 146 158 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"); 153 165 psFree(biasRows); 154 166 … … 156 168 readout->parent->data_exists = true; 157 169 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 } 158 174 } 159 175 psFree(biasCols); 160 176 161 ppSimUpdateConceptsCell (cell, config);177 if (!ppSimUpdateConceptsCell (cell, config)) ESCAPE (PS_ERR_UNKNOWN, "problem updating cell concepts"); 162 178 163 179 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"); 165 182 } 166 183 … … 175 192 176 193 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"); 178 196 } 179 197 180 198 // 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"); 182 200 183 201 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { … … 185 203 psFree(rng); 186 204 psFree(view); 187 // return PS_EXIT_SYS_ERROR;188 205 return false; 189 206 } … … 195 212 196 213 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"); 198 216 } 199 217 … … 202 220 psFree(rng); 203 221 psFree(view); 204 // return PS_EXIT_SYS_ERROR;205 222 return false; 206 223 }
Note:
See TracChangeset
for help on using the changeset viewer.
