Changeset 23711
- Timestamp:
- Apr 3, 2009, 6:25:39 PM (17 years ago)
- Location:
- branches/pap/ppSub/src
- Files:
-
- 2 added
- 6 edited
-
ppSub.h (modified) (1 diff)
-
ppSubCamera.c (modified) (3 diffs)
-
ppSubDefineOutput.c (modified) (3 diffs)
-
ppSubFiles.c (modified) (4 diffs)
-
ppSubLoop.c (modified) (6 diffs)
-
ppSubReadoutJpeg.c (added)
-
ppSubReadoutStats.c (added)
-
ppSubReadoutUpdate.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/ppSub/src/ppSub.h
r23704 r23711 24 24 // Output files, for activation/deactivation 25 25 typedef enum { 26 PPSUB_FILES_INPUT = 0x01, // Input files 27 PPSUB_FILES_CONV = 0x02, // Convolved files (output) 28 PPSUB_FILES_SUB = 0x04, // Subtracted files (output) 29 PPSUB_FILES_INV = 0x08, // Inverse subtracted files (output) 30 PPSUB_FILES_PHOT_SUB = 0x10, // Photometry files (output) 31 PPSUB_FILES_PHOT_INV = 0x20, // Photometry files ( 32 PPSUB_FILES_ALL = 0xFF, // All files 26 PPSUB_FILES_INPUT = 0x01, // Input files 27 PPSUB_FILES_CONV = 0x02, // Convolved files (output) 28 PPSUB_FILES_SUB = 0x04, // Subtracted files (output) 29 PPSUB_FILES_INV = 0x08, // Inverse subtracted files (output) 30 PPSUB_FILES_PHOT = 0x10, // psphot photometry files 31 PPSUB_FILES_PHOT_SUB = 0x20, // Subtraction photometry files (output) 32 PPSUB_FILES_PHOT_INV = 0x40, // Inverse subtraction photometry files (output) 33 PPSUB_FILES_ALL = 0xFF, // All files 33 34 } ppSubFiles; 34 35 -
branches/pap/ppSub/src/ppSubCamera.c
r23704 r23711 167 167 return false; 168 168 } 169 data->inver t= psMetadataLookupBool(NULL, recipe, "INVERSE");169 data->inverse = psMetadataLookupBool(NULL, recipe, "INVERSE"); 170 170 data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY"); 171 171 … … 192 192 if (data->inverse) { 193 193 // Inverse output image 194 pmFPAfile * outinv = defineOutputFile(config, input, true, "PPSUB.OUTINV", PM_FPA_FILE_IMAGE);195 pmFPAfile * outinvMask = defineOutputFile(config, outinv, false, "PPSUB.OUTINV.MASK",196 PM_FPA_FILE_MASK);197 if (! outinv || !outinvMask) {194 pmFPAfile *inverse = defineOutputFile(config, input, true, "PPSUB.INV", PM_FPA_FILE_IMAGE); 195 pmFPAfile *invMask = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.MASK", 196 PM_FPA_FILE_MASK); 197 if (!inv || !invMask) { 198 198 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 199 199 return false; 200 200 } 201 outinv->save = true;202 outinvMask->save = true;201 inverse->save = true; 202 invMask->save = true; 203 203 if (inVar && refVar) { 204 pmFPAfile * outinvVar = defineOutputFile(config, outinv, false, "PPSUB.OUTINV.VARIANCE",205 PM_FPA_FILE_VARIANCE);206 if (! outinvVar) {204 pmFPAfile *invVar = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.VARIANCE", 205 PM_FPA_FILE_VARIANCE); 206 if (!invVar) { 207 207 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 208 208 return false; 209 209 } 210 outinvVar->save = true;210 invVar->save = true; 211 211 } 212 212 } … … 312 312 return false; 313 313 } 314 315 // Deactivate psphot output sources --- we want to define output source files of our own 316 pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0); 317 psphotOutput->save = false; 318 319 pmFPAfile *outSources = defineOutputFile(config, output, false, "PPSUB.OUTPUT.SOURCES", 320 PM_FPA_FILE_CMF); 321 if (!outSources) { 322 psError(PS_ERR_UNKNOWN, false, "Unable to set up output source file."); 323 return false; 324 } 325 outSources->save = true; 326 327 if (data->inverse) { 328 pmFPAfile *invSources = defineOutputFile(config, inverse, false, "PPSUB.OUTPUT.SOURCES", 329 PM_FPA_FILE_CMF); 330 if (!invSources) { 331 psError(PS_ERR_UNKNOWN, false, "Unable to set up inverse source file."); 332 return false; 333 } 334 } 335 invSources->save = true; 314 336 } 315 337 -
branches/pap/ppSub/src/ppSubDefineOutput.c
r23704 r23711 29 29 pmCell *outCell = pmFPAfileThisCell(config->files, view, name); // Output cell 30 30 pmFPA *outFPA = outCell->parent->parent; // Output FPA 31 pmHDU *outHDU = outFPA->hdu; // Output HDU31 pmHDU *outHDU = outFPA->hdu; // Output HDU 32 32 if (!outHDU->header) { 33 33 outHDU->header = psMetadataAlloc(); 34 34 } 35 35 36 // The output readout may already be present if we read in the convolution kernel 36 37 pmReadout *outRO = NULL; // Output readout 37 38 if (outCell->readouts && outCell->readouts->n > 0 && outCell->readouts->data[0]) { … … 41 42 } 42 43 43 // convolved input images44 // Convolved input images 44 45 pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input readout 45 46 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference readout … … 63 64 kernels->description); 64 65 66 // Add additional data to the header 67 pmFPAfile *refFile = psMetadataLookupPtr(NULL, config->files, "PPSUB.REF"); // Reference file 68 pmFPAfile *inFile = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file 69 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.REFERENCE", 0, 70 "Subtraction reference", refFile->filename); 71 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.INPUT", 0, 72 "Subtraction input", inFile->filename); 73 ppSubVersionHeader(outHDU->header); 74 75 65 76 outRO->analysis = psMetadataCopy(outRO->analysis, analysis); 66 77 -
branches/pap/ppSub/src/ppSubFiles.c
r23704 r23711 26 26 NULL }; 27 27 28 // Subtraction photometry 29 static const char *subPhotFiles[] = { "PPSUB.OUTPUT.SOURCES", NULL }; 30 28 31 // Inverse subtraction files 29 32 static const char *invFiles[] = { "PPSUB.OUTINV", "PPSUB.OUTINV.MASK", "PPSUB.OUTINV.VARIANCE", 30 33 "PPSUB.OUTINV.KERNELS", "PPSUB.OUTINV.JPEG1", "PPSUB.OUTINV.JPEG2", 31 34 NULL }; 35 36 // Inverse subtraction photometry 37 static const char *subPhotFiles[] = { "PPSUB.OUTINV.SOURCES", NULL }; 32 38 33 39 // Calculation (may be either input or output) files … … 36 42 37 43 // Activate/deactivate a list of files 38 static void filesActivate(const char **files, // List of files 44 static void filesActivate(pmConfig *config, // Configuration 45 const char **files, // List of files 39 46 bool state // Activation status to set 40 47 ) … … 49 56 // This is so we can activate/deactivate the 'calculation' files, which may be either input or output, which 50 57 // is indicated by their 'save' boolean. 51 static void filesActivateSave(const char **files, // List of files 58 static void filesActivateSave(pmConfig *config, // Configuration 59 const char **files, // List of files 52 60 bool save, // Activate when this save state is set 53 61 bool state // Activation status to set … … 69 77 if (files & PPSUB_FILES_INPUT) { 70 78 filesActivate(inputFiles, state); 71 filesActivateSave(c alcFiles, false, state);79 filesActivateSave(config, calcFiles, false, state); 72 80 } 73 81 if (files & PPSUB_FILES_CONV) { 74 filesActivate(con vFiles, state);82 filesActivate(config, convFiles, state); 75 83 } 76 84 if (files & PPSUB_FILES_SUB) { 77 filesActivate( subFiles, state);78 filesActivateSave(c alcFiles, true, state);85 filesActivate(config, subFiles, state); 86 filesActivateSave(config, calcFiles, true, state); 79 87 } 80 88 if (files & PPSUB_FILES_INV) { 81 filesActivate(invFiles, state); 89 filesActivate(config, invFiles, state); 90 } 91 if (files & PPSUB_FILES_PHOT_SUB) { 92 filesActivate(config, subPhotFiles, state); 93 } 94 if (files & PPSUB_FILES_PHOT_INV) { 95 filesActivate(config, invPhotFiles, state); 82 96 } 83 97 if (files & PPSUB_FILES_PHOT) { 84 psphotFilesActivate(config, state);98 psphotFilesActivate(config, false); 85 99 } 86 100 -
branches/pap/ppSub/src/ppSubLoop.c
r23704 r23711 55 55 } 56 56 57 psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs", 58 psTimerClear("PPSUB_MATCH")); 59 57 60 // Close input files 58 61 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) { … … 72 75 } 73 76 74 if ( data->inverse && !ppSubDefineOutput("PPSUB.OUTINV", config, data, view)) {75 psError(PS_ERR_UNKNOWN, false, "Unable to define inverse.");77 if (!data->quality && !ppSubMakePSF("PPSUB.OUTPUT", "PPSUB.INVERSE", config, data, view)) { 78 psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF."); 76 79 return false; 77 80 } 78 81 79 if (! data->quality && !ppSubMakePSF("PPSUB.OUTPUT", "PPSUB.OUTINV", config, data, view)) {80 psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF.");82 if (!ppSubReadoutSubtract("PPSUB.OUTPUT", config, view)) { 83 psError(PS_ERR_UNKNOWN, false, "Unable to subtract images."); 81 84 return false; 82 85 } … … 88 91 } 89 92 90 if (!ppSubReadoutSubtract("PPSUB.OUTPUT", config, view)) {91 psError(PS_ERR_UNKNOWN, false, "Unable to subtract images.");92 return false;93 }94 95 93 // Higher order background subtraction using psphot 96 if (!ppSubBackground( "PPSUB.OUTPUT",config, view)) {94 if (!ppSubBackground(config, view)) { 97 95 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background."); 98 96 return false; 99 97 } 100 98 101 if (!data->quality && data->!ppSubReadoutPhotometry("PPSUB.OUTPUT", config, data, view)) {99 if (!data->quality && ppSubReadoutPhotometry("PPSUB.OUTPUT", PPSUB_FILES_PHOT_SUB, config, data, view)) { 102 100 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 103 101 return false; 104 102 } 105 103 106 if (!ppSubReadoutUpdate("PPSUB.OUTPUT", config, data, view)) { 107 psError(PS_ERR_UNKNOWN, false, "Unable to update."); 104 // Perform statistics on the cell 105 if (!ppSubReadoutStats(config, data, view)) { 106 psError(PS_ERR_UNKNOWN, false, "Unable to collect statistics"); 108 107 return false; 109 108 } 110 109 111 // Perform statistics on the cell 112 if (statsFile) { 113 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PPSUB.OUTPUT"); // Output file 114 if (!output) { 115 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PPSUB.OUTPUT.\n"); 116 goto ERROR; 117 } 118 psImageMaskType maskValue = pmConfigMaskGet("MASK.VALUE", config); 119 ppStatsFPA(data->stats, output->fpa, view, maskValue, config); 110 if (!ppSubReadoutJpeg("PPSUB.OUTPUT", config, data, view)) { 111 psError(PS_ERR_UNKNOWN, false, "Unable to update."); 112 return false; 120 113 } 121 114 … … 127 120 } 128 121 129 if (!ppSubReadoutInverse("PPSUB.OUTINV", "PPSUB.OUTPUT", config, view)) { 122 if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config, data, view)) { 123 psError(PS_ERR_UNKNOWN, false, "Unable to define inverse."); 124 return false; 125 } 126 127 if (!ppSubReadoutInverse("PPSUB.INVERSE", "PPSUB.OUTPUT", config, view)) { 130 128 psError(PS_ERR_UNKNOWN, false, "Unable to invert images."); 131 129 return false; … … 138 136 } 139 137 140 if (!data->quality && data->!ppSubReadoutPhotometry("PPSUB.OUTINV", config, data, view)) { 141 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 142 return false; 138 if (!data->quality && data->!ppSubReadoutPhotometry("PPSUB.INVERSE", PPSUB_FILES_PHOT_INV, 139 config, data, view)) { 140 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 141 return false; 142 } 143 144 // Close inverse subtraction files 145 if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV)) { 146 psError(PPSUB_ERR_IO, false, "Unable to close subtraction files."); 147 return false; 143 148 } 144 149 } else { … … 149 154 } 150 155 } 151 152 153 if (!ppSubReadoutUpdate("PPSUB.OUTPUT", config, data, view)) {154 psError(PS_ERR_UNKNOWN, false, "Unable to update.");155 return false;156 }157 158 156 159 157 psFree(view); -
branches/pap/ppSub/src/ppSubReadoutUpdate.c
r23688 r23711 32 32 psAssert(recipe, "We checked this earlier, so it should be here."); 33 33 34 pmFPAfile *outFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file35 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image36 pmFPA *outFPA = outFile->fpa; // Output FPA37 pmHDU *outHDU = outFPA->hdu; // Output HDU38 39 // Add additional data to the header40 pmFPAfile *refFile = psMetadataLookupPtr(NULL, config->files, "PPSUB.REF"); // Reference file41 pmFPAfile *inFile = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file42 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.REFERENCE", 0,43 "Subtraction reference", refFile->filename);44 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.INPUT", 0,45 "Subtraction input", inFile->filename);46 ppSubVersionHeader(outHDU->header);47 48 // Statistics on the matching49 if (data->stats) {50 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MODE);51 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_STAMPS);52 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_MEAN);53 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_RMS);54 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_NORM);55 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_BGDIFF);56 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MX);57 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MY);58 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXX);59 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXY);60 psMetadataCopySingle(data->stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MYY);61 62 psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",63 psTimerClear("PPSUB_MATCH"));64 }65 66 34 // Generate binned JPEGs 67 35 { … … 92 60 } 93 61 94 #ifdef TESTING95 // Significance image96 {97 psImage *sig = (psImage*)psBinaryOp(NULL, outRO->image, "*", outRO->image);98 psBinaryOp(sig, sig, "/", outRO->variance);99 psFits *fits = psFitsOpen("significance.fits", "w");100 psFitsWriteImage(fits, NULL, sig, 0, NULL);101 psFitsClose(fits);102 psFree(sig);103 }104 #endif105 106 62 return true; 107 63 }
Note:
See TracChangeset
for help on using the changeset viewer.
