Changeset 32319
- Timestamp:
- Sep 5, 2011, 8:58:58 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psphot/src/psphotStackPSF.c
r31154 r32319 1 1 # include "psphotInternal.h" 2 2 3 pmPSF *psphotStackPSF(const pmConfig *config, int numCols, int numRows, const psArray *psfs, const psVector *inputMask) 4 { 3 // determine the 1st target PSF (either AUTO or defined by PSPHOT.STACK.TARGET.PSF.FWHM) 4 bool psphotStackPSF(const pmConfig *config, psphotStackOptions *options) { 5 5 6 bool mdok = false; 6 pmPSF *psf = NULL; 7 8 int numCols = options->numCols; 9 int numRows = options->numRows; 10 psArray *psfs = options->psfs; 11 psVector *inputMask = options->inputMask; 7 12 8 13 // Get the recipe values … … 17 22 18 23 char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF 24 25 options->targetSeeing = psVectorAllocEmpty(4, PS_TYPE_F32); 19 26 20 27 if (autoPSF) { … … 38 45 39 46 // Solve for the target PSF 40 psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal);41 if (! psf) {47 options->psf = pmPSFEnvelope(numCols, numRows, psfs, psfInstances, psfRadius, psfModel, psfOrder, psfOrder, maskVal); 48 if (!options->psf) { 42 49 psError(PSPHOT_ERR_PSF, false, "Unable to determine output PSF."); 43 return NULL;50 return false; 44 51 } 45 52 46 } else { 47 48 // externally-defined PSF 49 // XXX need to test for compatibility of target with inputs 50 51 float targetFWHM = psMetadataLookupF32 (&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.FWHM"); 52 if (!mdok) { 53 psVector *fwhmValues = psMetadataLookupVector(&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.FWHM"); // Magnitude offsets 54 psAssert (mdok, "missing psphot recipe value PSPHOT.STACK.TARGET.PSF.FWHM"); 55 targetFWHM = fwhmValues->data.F32[0]; 56 } 57 58 // measured scale factors (fwhm = Sxx * 2.35 * scaleFactor / sqrt(2.0)) 59 // GAUSS : 1.000 60 // PGAUSS : 1.006 61 // QGAUSS : 1.151 62 // RGAUSS : 0.883 63 // PS1_V1 : 1.134 64 65 float scaleFactor = NAN; 66 if (!strcmp(psfModel, "PS_MODEL_GAUSS")) { 67 scaleFactor = 1.000; 68 } 69 if (!strcmp(psfModel, "PS_MODEL_PGAUSS")) { 70 scaleFactor = 1.0006; 71 } 72 if (!strcmp(psfModel, "PS_MODEL_QGAUSS")) { 73 scaleFactor = 1.151; 74 } 75 if (!strcmp(psfModel, "PS_MODEL_RGAUSS")) { 76 scaleFactor = 0.883; 77 } 78 if (!strcmp(psfModel, "PS_MODEL_PS1_V1")) { 79 scaleFactor = 1.134; 80 } 81 psAssert (isfinite(scaleFactor), "invalid model for PSF"); 82 83 float Sxx = sqrt(2.0)*targetFWHM / 2.35 / scaleFactor; 84 85 // XXX probably should make the model type (and par 7) optional from recipe 86 // psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 1.0); 87 psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 0.2); 88 if (!psf) { 89 psError(PSPHOT_ERR_PSF, false, "Unable to build dummy PSF."); 90 return NULL; 91 } 53 psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "PSF.TARGET", PS_DATA_UNKNOWN, "Target PSF for stack", options->psf); 54 float targetSeeing = pmPSFtoFWHM(options->psf, 0.5 * options->numCols, 0.5 * options->numRows); // FWHM for target 55 psVectorAppend(options->targetSeeing, targetSeeing); 56 psLogMsg("psphotStack", PS_LOG_INFO, "Target seeing FWHM (auto-scaled): %f\n", targetSeeing); 57 return true; 92 58 } 93 59 94 return psf; 60 // externally-defined PSF 61 // XXX need to test for compatibility of target with inputs 62 63 // is a single target FWHM specified, or a set of values? set up the vector options->targetSeeing and the local 1st value 64 float targetSeeing = psMetadataLookupF32 (&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.FWHM"); 65 if (!mdok) { 66 psVector *fwhmValues = psMetadataLookupVector(&mdok, psphotRecipe, "PSPHOT.STACK.TARGET.PSF.FWHM"); // Magnitude offsets 67 psAssert (mdok, "missing psphot recipe value PSPHOT.STACK.TARGET.PSF.FWHM"); 68 for (int i = 0; i < fwhmValues->n; i++) { 69 psVectorAppend(options->targetSeeing, fwhmValues->data.F32[i]); 70 } 71 targetSeeing = fwhmValues->data.F32[0]; 72 } else { 73 psVectorAppend(options->targetSeeing, targetSeeing); 74 } 75 76 // measured scale factors (fwhm = Sxx * 2.35 * scaleFactor / sqrt(2.0)) 77 // GAUSS : 1.000 78 // PGAUSS : 1.006 79 // QGAUSS : 1.151 80 // RGAUSS : 0.883 81 // PS1_V1 : 1.134 82 83 float scaleFactor = NAN; 84 if (!strcmp(psfModel, "PS_MODEL_GAUSS")) { 85 scaleFactor = 1.000; 86 } 87 if (!strcmp(psfModel, "PS_MODEL_PGAUSS")) { 88 scaleFactor = 1.0006; 89 } 90 if (!strcmp(psfModel, "PS_MODEL_QGAUSS")) { 91 scaleFactor = 1.151; 92 } 93 if (!strcmp(psfModel, "PS_MODEL_RGAUSS")) { 94 scaleFactor = 0.883; 95 } 96 if (!strcmp(psfModel, "PS_MODEL_PS1_V1")) { 97 scaleFactor = 1.134; 98 } 99 psAssert (isfinite(scaleFactor), "invalid model for PSF"); 100 101 float Sxx = sqrt(2.0)*targetSeeing / 2.35 / scaleFactor; 102 103 // XXX probably should make the model type (and par 7) optional from recipe 104 // psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 1.0); 105 options->psf = pmPSFBuildSimple(psfModel, Sxx, Sxx, 0.0, 0.2); 106 if (!options->psf) { 107 psError(PSPHOT_ERR_PSF, false, "Unable to build dummy PSF."); 108 return false; 109 } 110 111 psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "PSF.TARGET", PS_DATA_UNKNOWN, "Target PSF for stack", options->psf); 112 psLogMsg("psphotStack", PS_LOG_INFO, "Target seeing FWHM (1 of %ld): %f\n", options->targetSeeing->n, targetSeeing); 113 return true; 95 114 }
Note:
See TracChangeset
for help on using the changeset viewer.
