Changeset 25818 for trunk/psModules/src/objects/pmPSFtryModel.c
- Timestamp:
- Oct 9, 2009, 9:29:40 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtryModel.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtryModel.c
r25754 r25818 70 70 psFree(psfTry); 71 71 return NULL; 72 } 72 } 73 73 74 74 int orderMin = (options->psfTrendMode == PM_TREND_MAP) ? 1 : 0; … … 80 80 if ((sources->n < 8) && (orderMax >= 1)) orderMax = 0; 81 81 if ((sources->n < 3)) { 82 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 83 return NULL; 84 } 82 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 83 return NULL; 84 } 85 orderMin = PS_MIN(orderMin, orderMax); 85 86 86 87 // save the raw source mask (generated by pmPSFtryFitEXT) 87 88 psVector *srcMask = psVectorCopy (NULL, psfTry->mask, PS_TYPE_VECTOR_MASK); 88 89 89 // we will save the PSF with the best fit (min systematic error) 90 // we will save the PSF with the best fit (min systematic error) 90 91 pmPSF *minPSF = NULL; 91 92 psVector *minMask = NULL; … … 96 97 int Ny = options->psfTrendNy; 97 98 for (int i = orderMin; i <= orderMax; i++) { 98 99 if (Nx > Ny) {100 options->psfTrendNx = i;101 options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5));102 } else {103 options->psfTrendNy = i;104 options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5));105 }106 107 // free existing data, if any108 psFree(psfTry->psf);109 psFree(psfTry->mask);110 111 // allocate a mask and a psf model using the current Nx,Ny order values;112 psfTry->psf = pmPSFAlloc (options);113 psfTry->mask = psVectorCopy (NULL, srcMask, PS_TYPE_VECTOR_MASK);114 115 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation116 if (!pmPSFtryMakePSF (psfTry)) {117 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources");118 psFree(psfTry);119 return NULL;120 }121 122 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric123 if (!pmPSFtryFitPSF (psfTry, options, maskVal, markVal)) {124 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources");125 psFree(psfTry);126 return NULL;127 }128 129 // stage 4: measure systematic error in pmPSFtry->metric130 if (!pmPSFtryMetric (psfTry)) {131 psError(PS_ERR_UNKNOWN, false, "failed to measure systematic error of metric");132 psFree(psfTry);133 return NULL;134 }135 136 if (!minPSF) {137 minPSF = psMemIncrRefCounter(psfTry->psf);138 minMask = psMemIncrRefCounter(psfTry->mask);139 }140 141 if (psfTry->psf->dApResid < minPSF->dApResid) {142 psFree (minPSF);143 psFree (minMask);144 minPSF = psMemIncrRefCounter(psfTry->psf);145 minMask = psMemIncrRefCounter(psfTry->mask);146 }99 100 if (Nx > Ny) { 101 options->psfTrendNx = i; 102 options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5)); 103 } else { 104 options->psfTrendNy = i; 105 options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5)); 106 } 107 108 // free existing data, if any 109 psFree(psfTry->psf); 110 psFree(psfTry->mask); 111 112 // allocate a mask and a psf model using the current Nx,Ny order values; 113 psfTry->psf = pmPSFAlloc (options); 114 psfTry->mask = psVectorCopy (NULL, srcMask, PS_TYPE_VECTOR_MASK); 115 116 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation 117 if (!pmPSFtryMakePSF (psfTry)) { 118 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 119 psFree(psfTry); 120 return NULL; 121 } 122 123 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric 124 if (!pmPSFtryFitPSF (psfTry, options, maskVal, markVal)) { 125 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 126 psFree(psfTry); 127 return NULL; 128 } 129 130 // stage 4: measure systematic error in pmPSFtry->metric 131 if (!pmPSFtryMetric (psfTry)) { 132 psError(PS_ERR_UNKNOWN, false, "failed to measure systematic error of metric"); 133 psFree(psfTry); 134 return NULL; 135 } 136 137 if (!minPSF) { 138 minPSF = psMemIncrRefCounter(psfTry->psf); 139 minMask = psMemIncrRefCounter(psfTry->mask); 140 } 141 142 if (psfTry->psf->dApResid < minPSF->dApResid) { 143 psFree (minPSF); 144 psFree (minMask); 145 minPSF = psMemIncrRefCounter(psfTry->psf); 146 minMask = psMemIncrRefCounter(psfTry->mask); 147 } 147 148 } 148 149 psFree (srcMask); … … 153 154 psfTry->psf = minPSF; 154 155 psfTry->mask = minMask; 155 156 156 157 // XXXXX this is probably not used any more. Are the chisq of the fits so bad? can we 157 158 // fix them by softening the errors on the brightest pixels?
Note:
See TracChangeset
for help on using the changeset viewer.
