Changeset 21524 for trunk/ppSub/src/ppSubReadoutSubtract.c
- Timestamp:
- Feb 17, 2009, 2:31:20 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadoutSubtract.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadoutSubtract.c
r21424 r21524 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:26:05$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-18 00:31:20 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 13 21 #include "ppSub.h" 22 14 23 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 15 24 16 bool ppSubReadoutSubtract (pmConfig *config, const pmFPAview *view) { 25 bool ppSubReadoutSubtract(pmConfig *config, const pmFPAview *view) 26 { 27 psAssert(config, "Require configuration"); 28 psAssert(view, "Require view"); 17 29 18 bool mdok = false;19 30 20 31 // Look up recipe values 21 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 32 bool mdok = false; // Status of MD lookup 33 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSub 22 34 psAssert(recipe, "We checked this earlier, so it should be here."); 23 35 … … 25 37 26 38 // Subtraction is: minuend - subtrahend 27 pmReadout *minuend = NULL; 28 pmReadout *subtrahend = NULL; 39 pmReadout *minuend = NULL; // Positive image 40 pmReadout *subtrahend = NULL; // Negative image 29 41 if (reverse) { 30 42 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); … … 59 71 outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask); 60 72 73 psArray *covars = psArrayAlloc(2); // Covariance pseudo-matrices 74 covars->data[0] = psMemIncrRefCounter(minuend->covariance); 75 covars->data[1] = psMemIncrRefCounter(subtrahend->covariance); 76 outRO->covariance = psImageCovarianceSum(covars); 77 psFree(covars); 78 61 79 outRO->data_exists = true; 62 80 outRO->parent->data_exists = true; … … 65 83 pmSubtractionVisualShowSubtraction(minuend->image, subtrahend->image, outRO->image); 66 84 67 // copy concepts from the input to the output (XXX should this always use minuend?) 68 pmFPAfile *inFile = psMetadataLookupPtr (&mdok, config->files, "PPSUB.INPUT"); 69 pmFPA *inFPA = inFile->fpa; 70 71 pmFPAfile *outFile = psMetadataLookupPtr (&mdok, config->files, "PPSUB.OUTPUT"); 72 pmFPA *outFPA = outFile->fpa; 73 85 // Copy concepts from the input to the output 86 pmFPAfile *inFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT"); // Input file 87 pmFPA *inFPA = inFile->fpa; // Input FPA 88 pmFPAfile *outFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file 89 pmFPA *outFPA = outFile->fpa; // Output FPA 74 90 if (!pmFPACopyConcepts(outFPA, inFPA)) { 75 91 psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output."); … … 78 94 } 79 95 80 // get the HDUs and output Chip to copy the astrometry81 pmHDU *inHDU = inFPA->hdu; // input HDU82 pmHDU * outHDU = outFPA->hdu;83 pm Chip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT");84 96 // Copy astrometry over 97 // It should find its way into the output images and photometry 98 pmHDU *inHDU = inFPA->hdu; // Input HDU 99 pmHDU *outHDU = outFPA->hdu; // Output HDU 100 pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT"); // Output chip 85 101 if (!outHDU || !inHDU) { 86 102 psError(PS_ERR_UNKNOWN, false, "Unable to find HDU at FPA level to copy astrometry."); 87 103 return false; 88 104 } 89 90 // Copy astrometry over91 // It should get into the output images and photometry92 105 if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) { 93 106 psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry from input FPA."); 94 107 return false; 95 108 } 96 97 109 if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) { 98 110 psError(PS_ERR_UNKNOWN, false, "Unable to write WCS astrometry to output FPA."); … … 102 114 return true; 103 115 } 104 105 // XXX this test code was in place to check for and squash unexpected NANs106 107 #if 0108 pmReadoutMaskApply(outRO, maskBad);109 110 for (int y = 0; y < outRO->image->numRows; y++) {111 for (int x = 0; x < outRO->image->numCols; x++) {112 if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {113 printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]);114 }115 }116 }117 #endif118
Note:
See TracChangeset
for help on using the changeset viewer.
