- Timestamp:
- May 7, 2013, 12:01:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419/pswarp/src/pswarpUpdateStatistics.c
r35524 r35527 15 15 // for each readout 16 16 bool pswarpUpdateStatistics (pmFPA *output, psMetadata *fpaStats, pmFPA *input, pmFPA *astrom, pmConfig *config) { 17 18 if (!fpaStats) { 19 psLogMsg("pswarp", PS_LOG_INFO, "stats not requested, skipping"); 20 return true; 21 } 17 22 18 23 // load the recipe … … 95 100 } 96 101 97 // Set covariance matrix for output98 // XXX is this the right place for the covariance calculation?99 # if (0)100 psList *covariances = psMetadataLookupPtr(&mdok, output->analysis, PSWARP_ANALYSIS_COVARIANCES); // Covariance matrices101 psAssert(covariances, "Should be there");102 psArray *covars = psListToArray(covariances); // Array of covariance matrices103 psKernel *covar = psImageCovarianceAverage(covars);104 psFree(covars);105 psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);106 107 // Correct covariance matrix scale for the mean (square root of the) Jacobian108 double jacobian = psMetadataLookupF64(NULL, output->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian109 int goodPixels = psMetadataLookupS32(NULL, output->analysis, PSWARP_ANALYSIS_GOODPIX); // Good pixels110 jacobian /= goodPixels;111 output->covariance = psImageCovarianceScale(covar, jacobian);112 psFree(covar);113 114 if (output->variance) {115 psImageCovarianceTransfer(output->variance, output->covariance);116 }117 # endif118 119 {120 // Add MD5 information for readout121 psString headerName = NULL; ///< Header name for MD5122 psVector *md5 = psImageMD5(readout->image); ///< md5 hash123 psString md5string = psMD5toString(md5); ///< String124 125 pmHDU *hdu = pmHDUFromReadout(readout);126 psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);127 psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE, "Image MD5", md5string);128 psFree(md5);129 psFree(md5string);130 psFree(headerName);131 }132 102 psFree (readoutName); 133 103 } 134 135 psList *inputCells = psMetadataLookupPtr (NULL, cell->analysis, "INPUT.CELLS");136 if (!pmConceptsAverageCells(cell, inputCells, NULL, NULL, false)) {137 psError(psErrorCodeLast(), false, "Unable to average cell concepts.");138 psFree(view);139 return false;140 }141 142 // XXX Is this too ad-hoc?143 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); ///< Trim section144 trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; ///< All pixels145 146 104 } 147 105 } 148 106 149 107 // Perform statistics on the output image (ppStatsFPA loops down the hierarchy) 150 if (fpaStats) { 151 pmFPAviewReset (view); 152 if (!ppStatsFPA(fpaStats, output, view, maskValue, config)) { 108 pmFPAviewReset (view); 109 if (!ppStatsFPA(fpaStats, output, view, maskValue, config)) { 153 110 psWarning("Unable to perform statistics on warped image."); 154 }155 111 } 156 112 psFree(view); 157 158 if (!psMetadataCopy(output->concepts, input->concepts)) {159 psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output.");160 return false;161 }162 113 163 114 if (Nreadout == 0) { … … 168 119 } 169 120 170 // Update ZP from the astrometry171 {172 psMetadataItem *item = psMetadataLookup(output->concepts, "FPA.ZP");173 item->data.F32 = psMetadataLookupF32(NULL, astrom->concepts, "FPA.ZP");174 }175 176 // need to update the chip and fpa level astrometry appropriately, see177 // code in psastro178 179 # if (0)180 if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {181 psError(psErrorCodeLast(), false, "Unable to generate WCS header.");182 return false;183 }184 # endif185 186 121 return true; 187 122 }
Note:
See TracChangeset
for help on using the changeset viewer.
