Changeset 37932 for trunk/psphot/src/psphotReadoutCleanup.c
- Timestamp:
- Feb 24, 2015, 5:52:57 PM (11 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/psphotReadoutCleanup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:mergeinfo set to
-
trunk/psphot/src/psphotReadoutCleanup.c
r37767 r37932 111 111 return true; 112 112 } 113 114 // for now, let's store the detections on the readout->analysis for each readout 115 bool psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule) 116 { 117 bool status = true; 118 119 // remove internal pmFPAfiles, if created 120 if (psErrorCodeLast() == (psErrorCode) PSPHOT_ERR_DATA) { 121 psErrorStackPrint(stderr, "Error in the psphot readout analysis"); 122 psErrorClear(); 123 } 124 if (psErrorCodeLast() != PS_ERR_NONE) { 125 return false; 126 } 127 128 // select the appropriate recipe information 129 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 130 psAssert (recipe, "missing recipe?"); 131 132 int num = psphotFileruleCount(config, filerule); 133 134 // loop over the available readouts 135 for (int i = 0; i < num; i++) { 136 if (!psphotReadoutCleanupReadoutMinimal (config, view, filerule, i, recipe)) { 137 psError (PSPHOT_ERR_CONFIG, false, "failed on psphotReadoutCleanupMinimal for %s entry %d", filerule, i); 138 return false; 139 } 140 } 141 142 // XXX move this to top of loop? 143 pmKapaClose (); 144 145 return true; 146 } 147 148 // psphotReadoutCleanupMinimal is called on exit from psphotReadoutMinimal. If the last raised error is 149 // not a DATA error, then there was a serious problem. Only in this case, or if the fail 150 // on the stats measurement, do we return false 151 bool psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe) { 152 153 bool status = true; 154 155 // find the currently selected readout 156 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 157 psAssert (file, "missing file?"); 158 159 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 160 psAssert (readout, "missing readout?"); 161 162 // when psphotReadoutCleanupMinimal is called, these are not necessarily defined 163 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 164 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 165 psArray *sources = detections ? detections->allSources : NULL; 166 // XXX where do we free these, in here (psMetadataRemove?) 167 168 // create an output header with stats results currently saved on readout->analysis 169 psMetadata *header = psphotDefineHeader (readout->analysis); 170 171 // write NSTARS to the image header 172 psphotSetHeaderNstars (header, sources); 173 174 // save the results of the analysis 175 // this should happen way up stream (when needed?) 176 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA | PS_META_REPLACE, "header stats", header); 177 178 if (psf) { 179 // XXX this seems a little silly : we saved the psf on readout->analysis above, but now 180 // we are moving it to chip->analysis. 181 // save the psf for possible output. if there was already an entry, it was loaded from external sources 182 // the new one may have been updated or modified, so replace the existing entry. We 183 // are required to save it on the chip, but this will cause problems if we ever want to 184 // run psphot on an unmosaiced image 185 pmCell *cell = readout->parent; 186 pmChip *chip = cell->parent; 187 psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot psf", psf); 188 } 189 190 if (psErrorCodeLast() != PS_ERR_NONE) { 191 psErrorStackPrint(stderr, "unexpected remaining errors"); 192 abort(); 193 } 194 195 psFree (header); 196 return true; 197 }
Note:
See TracChangeset
for help on using the changeset viewer.
