Changeset 30619 for trunk/ppSub
- Timestamp:
- Feb 13, 2011, 11:43:27 AM (15 years ago)
- Location:
- trunk/ppSub/src
- Files:
-
- 14 edited
-
ppSub.c (modified) (1 diff)
-
ppSubFiles.c (modified) (9 diffs)
-
ppSubInputDetections.c (modified) (2 diffs)
-
ppSubLoop.c (modified) (3 diffs)
-
ppSubMakePSF.c (modified) (3 diffs)
-
ppSubMatchPSFs.c (modified) (7 diffs)
-
ppSubReadoutForcedPhot.c (modified) (3 diffs)
-
ppSubReadoutInverse.c (modified) (2 diffs)
-
ppSubReadoutJpeg.c (modified) (1 diff)
-
ppSubReadoutPhotometry.c (modified) (2 diffs)
-
ppSubReadoutSubtract.c (modified) (5 diffs)
-
ppSubSetMasks.c (modified) (4 diffs)
-
ppSubThreshold.c (modified) (3 diffs)
-
ppSubVarianceRescale.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSub.c
r29551 r30619 112 112 psLibFinalize(); 113 113 114 fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppSub"); 114 115 exitValue = ppSubExitCode(exitValue); 115 116 exit(exitValue); -
trunk/ppSub/src/ppSubFiles.c
r27094 r30619 125 125 // FPA 126 126 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 127 psFree (view); 127 128 return false; 128 129 } … … 131 132 view->chip = 0; 132 133 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 134 psFree (view); 133 135 return false; 134 136 } … … 137 139 view->cell = 0; 138 140 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 141 psFree (view); 139 142 return false; 140 143 } … … 143 146 view->readout = 0; 144 147 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 145 return false; 146 } 147 148 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 149 148 psFree (view); 149 return false; 150 } 151 152 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 153 154 psFree (view); 150 155 return true; 151 156 } … … 162 167 // Readout 163 168 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 169 psFree (view); 164 170 return false; 165 171 } … … 168 174 view->readout = -1; 169 175 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 176 psFree (view); 170 177 return false; 171 178 } … … 174 181 view->cell = -1; 175 182 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 183 psFree (view); 176 184 return false; 177 185 } … … 180 188 view->chip = -1; 181 189 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 190 psFree (view); 182 191 return false; 183 192 } … … 222 231 ppSubFilesActivate(config, PPSUB_FILES_ALL, false); 223 232 233 psFree (view); 224 234 return true; 225 235 } -
trunk/ppSub/src/ppSubInputDetections.c
r29937 r30619 118 118 if (!psMetadataCopy(sourcesHDU->header, imageHDU->header)) { 119 119 psError(PPSUB_ERR_PROG, false, "Unable to copy header"); 120 psFree(view); 120 121 return false; 121 122 } … … 130 131 if (!psphotCopyResults (foundDetections, sourcesFile, photFile, view)) { 131 132 psError(PPSUB_ERR_PROG, false, "Unable to copy psphot outputs"); 133 psFree(view); 132 134 return false; 133 135 } 134 136 // if no sources were found here, we report that back and let them handle it 135 137 138 psFree(view); 136 139 return true; 137 140 } -
trunk/ppSub/src/ppSubLoop.c
r30066 r30619 26 26 pmReadout *out = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); 27 27 psphotSaveImage (NULL, out->image, name); 28 psFree(view); 28 29 return true; 29 30 } … … 111 112 goto ESCAPE; 112 113 } 114 113 115 if (data->quality) { 114 116 // Can't do anything at all … … 257 259 psError(psErrorCodeLast(), false, "Unable to generate mask statistics"); 258 260 success = false; 261 psFree(view); 259 262 goto ESCAPE; 260 263 } 264 psFree(view); 261 265 } 262 266 // dumpout(config, "diff.4.fits"); -
trunk/ppSub/src/ppSubMakePSF.c
r29937 r30619 79 79 if (!detections || !detections->allSources) { 80 80 psError(PPSUB_ERR_CONFIG, true, "No sources from which to determine PSF."); 81 psFree(view); 81 82 return false; 82 83 } … … 86 87 // use flags to toss totally bogus entries? 87 88 psArray *goodSources = ppSubSelectPSFSources (sources); 89 88 90 if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", goodSources)) { 89 91 // This is likely a data quality issue … … 126 128 outputRO = pmReadoutAlloc(outputCell); 127 129 outputRO->image = psMemIncrRefCounter(inputRO->image); 130 psFree(outputRO); // I have a copy on the outputCell 128 131 } 129 132 -
trunk/ppSub/src/ppSubMatchPSFs.c
r29937 r30619 78 78 return true; 79 79 } 80 81 80 psFree(view); 82 81 … … 127 126 if (!inSourceRO || !refSourceRO) { 128 127 psError(PPSUB_ERR_DATA, false, "Unable to scale kernel, since no sources were provided."); 128 psFree(view); 129 129 return false; 130 130 } … … 164 164 165 165 // is auto-scaling needed? 166 if (!psMetadataLookupBool(NULL, recipe, "SCALE")) { 167 // No scaling requested 168 psFree(view); 169 return true; 170 } 171 166 bool scale = psMetadataLookupBool(NULL, recipe, "SCALE"); 172 167 float scaleRef = psMetadataLookupF32(NULL, recipe, "SCALE.REF"); // Reference for scaling 173 168 float scaleMin = psMetadataLookupF32(NULL, recipe, "SCALE.MIN"); // Minimum for scaling 174 169 float scaleMax = psMetadataLookupF32(NULL, recipe, "SCALE.MAX"); // Maximum for scaling 175 if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) { 170 171 if (scale && (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax))) { 176 172 psError(PPSUB_ERR_ARGUMENTS, false, 177 " Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in recipe.",173 "auto-scale selected but scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in recipe.", 178 174 scaleRef, scaleMin, scaleMax); 179 175 return false; 180 176 } 181 177 182 if (!pmSubtractionParamsScale(kernelSize, stampSize, kernelWidths, scaleRef, scaleMin, scaleMax)) { 183 psError(PPSUB_ERR_DATA, false, "Unable to scale parameters."); 184 return false; 185 } 178 pmSubtractionParamScaleOptions(scale, scaleRef, scaleMin, scaleMax); 179 180 // if (!pmSubtractionParamsScale(kernelSize, stampSize, kernelWidths)) { 181 // psError(PPSUB_ERR_DATA, false, "Unable to scale parameters."); 182 // return false; 183 // } 186 184 187 185 return true; … … 221 219 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT.CONV"); // Cell for convolved input 222 220 inConv = pmReadoutAlloc(cell); 221 psFree(inConv); 223 222 } 224 223 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference convolved … … 226 225 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.REF.CONV"); // Cell for convolved ref. 227 226 refConv = pmReadoutAlloc(cell); 227 psFree(refConv); 228 228 } 229 229 … … 380 380 381 381 if (inRO->covariance) { 382 psImageCovarianceTruncate(inRO->covariance, COVAR_FRAC); 382 psKernel *truncated = psImageCovarianceTruncate(inRO->covariance, COVAR_FRAC); 383 psFree(inRO->covariance); 384 inRO->covariance = truncated; 383 385 } 384 386 if (refRO->covariance) { 385 psImageCovarianceTruncate(refRO->covariance, COVAR_FRAC); 387 psKernel *truncated = psImageCovarianceTruncate(refRO->covariance, COVAR_FRAC); 388 psFree(refRO->covariance); 389 refRO->covariance = truncated; 386 390 } 387 391 … … 494 498 495 499 if (inConv->covariance) { 496 psImageCovarianceTruncate(inConv->covariance, COVAR_FRAC); 500 psKernel *truncated = psImageCovarianceTruncate(inConv->covariance, COVAR_FRAC); 501 psFree(inConv->covariance); 502 inConv->covariance = truncated; 497 503 } 498 504 if (refConv->covariance) { 499 psImageCovarianceTruncate(refConv->covariance, COVAR_FRAC); 505 psKernel *truncated = psImageCovarianceTruncate(refConv->covariance, COVAR_FRAC); 506 psFree(refConv->covariance); 507 refConv->covariance = truncated; 500 508 } 501 509 -
trunk/ppSub/src/ppSubReadoutForcedPhot.c
r29937 r30619 61 61 // XXX remove the pixels from photFile? 62 62 // XXX other cleanup operations? 63 psFree(view); 63 64 return true; 64 65 } … … 89 90 if (!psphotCopyResults (&foundDetections, outputFile, photFile, view)) { 90 91 psError(PPSUB_ERR_PROG, false, "Unable to copy psphot outputs"); 92 psFree(view); 91 93 return false; 92 94 } … … 97 99 psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_PHOT", PS_META_REPLACE, "Time to do photometry", elapsed); 98 100 101 psFree(view); 99 102 return true; 100 103 } -
trunk/ppSub/src/ppSubReadoutInverse.c
r27789 r30619 36 36 if (!pmAstromWriteWCS(invHDU->header, outFPA, outChip, WCS_TOLERANCE)) { 37 37 psError(psErrorCodeLast(), false, "Unable to write WCS astrometry to PPSUB.INVERSE."); 38 psFree(view); 38 39 return false; 39 40 } … … 41 42 if (!pmAstromReadWCS(invFPA, invChip, invHDU->header, 1.0)) { 42 43 psError(psErrorCodeLast(), false, "Unable to read WCS astrometry."); 44 psFree(view); 43 45 return false; 44 46 } 45 47 48 psFree(view); 46 49 return true; 47 50 } -
trunk/ppSub/src/ppSubReadoutJpeg.c
r26982 r30619 139 139 } 140 140 141 psFree(view); 141 142 return true; 142 143 } -
trunk/ppSub/src/ppSubReadoutPhotometry.c
r29937 r30619 109 109 if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.DETECTIONS")) { 110 110 psError(PPSUB_ERR_PROG, false, "Unable to copy PSPHOT.DETECTIONS"); 111 psFree(view); 111 112 return false; 112 113 } 113 114 if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.HEADER")) { 114 115 psError(PPSUB_ERR_PROG, false, "Unable to copy PSPHOT.HEADER"); 116 psFree(view); 115 117 return false; 116 118 } 117 119 if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, PM_DETEFF_ANALYSIS)) { 118 120 psError(PPSUB_ERR_PROG, false, "Unable to copy Detection Efficiency"); 121 psFree(view); 119 122 return false; 120 123 } … … 128 131 } 129 132 133 psFree(view); 130 134 return true; 131 135 } 132 136 133 137 #ifdef TESTING 134 // Record data about sources: not everything gets into the output CMF files138 // Record data about sources: not everything gets into the output CMF files 135 139 { 136 140 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources -
trunk/ppSub/src/ppSubReadoutSubtract.c
r29003 r30619 31 31 32 32 bool reverse = psMetadataLookupBool(&mdok, config->arguments, "REVERSE"); // Reverse sense of subtraction? 33 bool addPair = psMetadataLookupBool(&mdok, recipe, "ADD.NOT.SUBTRACT"); // add instead of subtracting 33 34 34 35 pmFPAview *view = ppSubViewReadout(); // View to readout … … 47 48 // Do the actual subtraction 48 49 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); 49 outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image); 50 51 if (addPair) { 52 outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "+", subtrahend->image); 53 } else { 54 outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image); 55 } 50 56 outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask); 51 57 outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance); … … 70 76 psFree(rng); 71 77 78 // XXX EAM : I suspect that the weighted averaging is giving the wrong answer for 79 // single-direction PSF matching (and maybe DUAL as well). I am testing the difference by 80 // generating A+B images instead of A-B images and then checking the significance of the 81 // sources in the image 82 72 83 // Combine the covariances 73 84 // These are weighted by the appropriate mean variance. This is probably not perfectly correct, but it … … 79 90 covarWeights->data.F32[0] = minuendVar; 80 91 covarWeights->data.F32[1] = subtrahendVar; 92 # if (0) 81 93 outRO->covariance = psImageCovarianceAverageWeighted(covars, covarWeights); 94 # else 95 outRO->covariance = psImageCovarianceAverage(covars); 96 # endif 82 97 psFree(covars); 83 98 psFree(covarWeights); … … 109 124 pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT"); // Output chip 110 125 psFree(view); 126 111 127 if (!outHDU || !inHDU) { 112 128 psError(PPSUB_ERR_PROG, true, "Unable to find HDU at FPA level to copy astrometry."); -
trunk/ppSub/src/ppSubSetMasks.c
r29551 r30619 80 80 if (!pmReadoutMaskInvalid(inRO, maskValue, satValue)) { 81 81 psError(PPSUB_ERR_DATA, false, "Unable to mask non-finite pixels in input."); 82 psFree(view); 82 83 return false; 83 84 } 84 85 if (!pmReadoutMaskInvalid(refRO, maskValue, satValue)) { 85 86 psError(PPSUB_ERR_DATA, false, "Unable to mask non-finite pixels in reference."); 87 psFree(view); 86 88 return false; 87 89 } … … 94 96 if (interpMode == PS_INTERPOLATE_NONE) { 95 97 psError(PPSUB_ERR_CONFIG, false, "Unknown interpolation mode: %s", interpModeStr); 98 psFree(view); 96 99 return false; 97 100 } … … 104 107 if (!pmReadoutInterpolateBadPixels(inRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) { 105 108 psError(PPSUB_ERR_DATA, false, "Unable to interpolate bad pixels for input image."); 109 psFree(view); 106 110 return false; 107 111 } 108 112 if (!pmReadoutInterpolateBadPixels(refRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) { 109 113 psError(PPSUB_ERR_DATA, false, "Unable to interpolate bad pixels for reference image."); 114 psFree(view); 110 115 return false; 111 116 } … … 113 118 #endif 114 119 120 psFree(view); 115 121 return true; 116 122 } -
trunk/ppSub/src/ppSubThreshold.c
r26982 r30619 98 98 if (!in) { 99 99 psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout."); 100 psFree(view); 100 101 return false; 101 102 } … … 104 105 if (!ref) { 105 106 psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout."); 107 psFree(view); 106 108 return false; 107 109 } … … 115 117 if (!lowThreshold(in, thresh, maskVal, maskThresh, region, "input convolved image")) { 116 118 psError(psErrorCodeLast(), false, "Unable to threshold input image."); 119 psFree(view); 117 120 return false; 118 121 } 119 122 if (!lowThreshold(ref, thresh, maskVal, maskThresh, region, "reference convolved image")) { 120 123 psError(psErrorCodeLast(), false, "Unable to threshold input image."); 124 psFree(view); 121 125 return false; 122 126 } -
trunk/ppSub/src/ppSubVarianceRescale.c
r28121 r30619 57 57 // Nothing to renormalise 58 58 psWarning("Renormalisation of the variance requested, but no variance provided."); 59 psFree(view); 59 60 return true; 60 61 } … … 69 70 } 70 71 72 psFree(view); 71 73 return true; 72 74 }
Note:
See TracChangeset
for help on using the changeset viewer.
