- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppSub
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppSub/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppSubKernel 12 ppSubErrorCodes.h 13 ppSubErrorCodes.c 14 ppSubVersionDefinitions.h
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMakePSF.c
r23352 r24244 22 22 #include "ppSub.h" 23 23 24 bool ppSubMakePSF(p mConfig *config, const pmFPAview *view)24 bool ppSubMakePSF(ppSubData *data) 25 25 { 26 psAssert(data, "Require processing data"); 27 pmConfig *config = data->config; // Configuration 26 28 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 29 30 if (!data->photometry) { 31 return true; 32 } 28 33 29 34 psTimerStart("PPSUB_PHOT"); … … 36 41 } 37 42 38 psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE);// psphot recipe39 psAssert(recipe, "We checked this earlier, so it should be here.");40 41 43 bool reverse = psMetadataLookupBool(NULL, config->arguments, "REVERSE"); // Reverse sense of subtraction? 42 44 … … 44 46 pmReadout *minuend = NULL; // Image that will be positive following subtraction 45 47 pmFPAfile *minuendFile = NULL; // File for minuend image 48 pmFPAview *view = ppSubViewReadout(); // View to readout 46 49 if (reverse) { 47 50 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); … … 52 55 } 53 56 54 #if 155 pmReadout *template = minuend;56 57 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 58 if (!pmFPACopy(photFile->fpa, minuendFile->fpa)) { 59 psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA for photometry"); 60 psFree(view); 61 return false; 62 } 57 63 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 58 if (!photRO) { 59 pmCell *cell = pmFPAviewThisCell(view, photFile->fpa); // Cell to photometer 60 photRO = pmReadoutAlloc(cell); // Output readout: subtraction 64 if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) { 65 psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES"); 61 66 } 62 photRO->image = psImageCopy(photRO->image, template->image, PS_TYPE_F32);63 if (template->variance) {64 photRO->variance = psImageCopy(photRO->variance, template->variance, PS_TYPE_F32);65 } else {66 psFree(photRO->variance);67 photRO->variance = NULL;68 }69 if (template->mask) {70 photRO->mask = psImageCopy(photRO->mask, template->mask, PS_TYPE_IMAGE_MASK);71 } else {72 psFree(photRO->mask);73 photRO->mask = NULL;74 }75 #else76 // Supply the minuend pmFPAfile to psphot as PSPHOT.INPUT:77 psMetadataAddPtr(config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE,78 "psphot input: view on another pmFPAfile", minuendFile);79 #endif80 67 81 68 // Extract the loaded sources from the associated readout, and generate PSF … … 83 70 psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES"); 84 71 if (!psphotReadoutFindPSF(config, view, sources)) { 85 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image."); 86 return false; 72 // This is likely a data quality issue 73 // XXX Split into multiple cases using error codes? 74 psErrorStackPrint(stderr, "Unable to determine PSF"); 75 psWarning("Unable to determine PSF --- suspect bad data quality."); 76 ppSubDataQuality(data, PSPHOT_ERR_PSF, PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV); 77 psFree(view); 78 return true; 87 79 } 88 89 // Record the FWHM in the output header90 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output readout91 pmHDU *hdu = pmHDUFromCell(outRO->parent); // HDU with header92 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MAJ");93 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MIN");94 80 95 81 // Get rid of the generated header; it will be regenerated by the real photometry run 96 82 psMetadataRemoveKey(photRO->analysis, "PSPHOT.HEADER"); 97 83 84 if (!data->quality) { 85 data->psf = psMemIncrRefCounter(psMetadataLookupPtr(NULL, photRO->parent->parent->analysis, 86 "PSPHOT.PSF")); 87 } 88 89 psFree(view); 90 98 91 return true; 99 92 } 100 101 // XXX we used to need this, is it still needed?102 103 // pmCell *photCell = pmFPAfileThisCell(config->files, view, "PSPHOT.INPUT");104 // pmCellFreeReadouts(photCell);105 106 // if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") ||107 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||108 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {109 // psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");110 // return false;111 // }112 113 // Blow away the sources psphot found --- they're irrelevant for the subtraction114 // XXX is this still needed? These are now probably not being set115 // pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with sources116 // psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");117 // psMetadataRemoveKey(photRO->analysis, "PSPHOT.HEADER");118
Note:
See TracChangeset
for help on using the changeset viewer.
