Changeset 21524 for trunk/ppSub/src/ppSubMakePSF.c
- Timestamp:
- Feb 17, 2009, 2:31:20 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubMakePSF.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubMakePSF.c
r21360 r21524 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.3 $ $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 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /** 16 * Photometry stage 1: measure the PSF from the minuend image 17 */18 bool ppSubMakePSF (pmConfig *config, const pmFPAview *view) { 24 bool ppSubMakePSF(pmConfig *config, const pmFPAview *view) 25 { 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 19 28 20 bool mdok = false;21 22 // Photometry is to be performed in two stages:23 // 1. Measure the PSF using the PSF-matched images24 // 2. Find and measure sources on the subtracted image25 29 psTimerStart("PPSUB_PHOT"); 26 30 27 // Look up recipe values28 31 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSub 29 32 psAssert(recipe, "We checked this earlier, so it should be here."); 30 33 31 psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE); // Recipe for psphot 34 if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) { 35 return true; 36 } 37 38 psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE);// psphot recipe 32 39 psAssert(recipe, "We checked this earlier, so it should be here."); 33 34 if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) return true;35 40 36 41 bool reverse = psMetadataLookupBool(NULL, config->arguments, "REVERSE"); // Reverse sense of subtraction? 37 42 38 pmReadout *minuend = NULL; 39 pmFPAfile *minuendFile = NULL; 43 bool mdok = false; // Status of MD lookup 44 pmReadout *minuend = NULL; // Image that will be positive following subtraction 45 pmFPAfile *minuendFile = NULL; // File for minuend image 40 46 if (reverse) { 41 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");42 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV");47 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); 48 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV"); 43 49 } else { 44 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");45 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV");50 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); 51 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV"); 46 52 } 47 53 48 // supply the minuend pmFPAfile to psphot as PSPHOT.INPUT: 49 psMetadataAddPtr (config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot input : view on another pmFPAfile", minuendFile); 54 #if 1 55 pmReadout *template = minuend; 56 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 57 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 61 } 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 #else 76 // 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 #endif 50 80 51 // old-style variance renormalization 52 if (!ppSubReadoutRenormPhot (config, recipe, minuend)) { 53 psError(PS_ERR_UNKNOWN, false, "failure in renormalization"); 54 return false; 55 } 56 57 // extract the loaded sources from the associated readout 81 // Extract the loaded sources from the associated readout, and generate PSF 82 // Here, we assume the image is background-subtracted 58 83 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); 59 84 psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 60 61 // generate PSF from the supplied sources (assumes image is background-subtracted)62 85 if (!psphotReadoutFindPSF(config, view, sources)) { 63 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image.");64 return false;86 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image."); 87 return false; 65 88 } 66 89 … … 70 93 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MAJ"); 71 94 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MIN"); 95 96 // Get rid of the generated header; it will be regenerated by the real photometry run 97 psMetadataRemoveKey(photRO->analysis, "PSPHOT.HEADER"); 72 98 73 99 return true; … … 87 113 88 114 // Blow away the sources psphot found --- they're irrelevant for the subtraction 89 // XXX is this still needed? These are now probably not being set 115 // XXX is this still needed? These are now probably not being set 90 116 // pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with sources 91 117 // psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");
Note:
See TracChangeset
for help on using the changeset viewer.
