- Timestamp:
- Oct 18, 2009, 10:23:28 AM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psModules/src/objects/pmPSFtryModel.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
-
branches/eam_branches/20090820/psModules/src/objects/pmPSFtryModel.c
r25766 r25870 70 70 psFree(psfTry); 71 71 return NULL; 72 } 73 74 int orderMin = (options->psfTrendMode == PM_TREND_MAP) ? 1 : 0;72 } 73 74 // XXX set the min number of needed source more carefully (depends on psfTrendMode?) 75 75 int orderMax = PS_MAX (options->psfTrendNx, options->psfTrendNy); 76 77 // XXX set the min number of needed source more carefully (depends on psfTrendMode?)78 76 if ((sources->n < 15) && (orderMax >= 3)) orderMax = 2; 79 77 if ((sources->n < 11) && (orderMax >= 2)) orderMax = 1; 80 78 if ((sources->n < 8) && (orderMax >= 1)) orderMax = 0; 81 79 if ((sources->n < 3)) { 82 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 83 return NULL; 80 psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters"); 81 return NULL; 82 } 83 84 int orderMin; 85 if (options->psfTrendMode == PM_TREND_MAP) { 86 orderMin = 1; 87 orderMax = PS_MAX(orderMax, 1); 88 } else { 89 orderMin = 0; 84 90 } 85 91 … … 87 93 psVector *srcMask = psVectorCopy (NULL, psfTry->mask, PS_TYPE_VECTOR_MASK); 88 94 89 // we will save the PSF with the best fit (min systematic error) 95 // we will save the PSF with the best fit (min systematic error) 90 96 pmPSF *minPSF = NULL; 91 97 psVector *minMask = NULL; … … 96 102 int Ny = options->psfTrendNy; 97 103 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 }104 105 if (Nx > Ny) { 106 options->psfTrendNx = i; 107 options->psfTrendNy = PS_MAX (orderMin, (int)(i * (Ny / Nx) + 0.5)); 108 } else { 109 options->psfTrendNy = i; 110 options->psfTrendNx = PS_MAX (orderMin, (int)(i * (Nx / Ny) + 0.5)); 111 } 112 113 // free existing data, if any 114 psFree(psfTry->psf); 115 psFree(psfTry->mask); 116 117 // allocate a mask and a psf model using the current Nx,Ny order values; 118 psfTry->psf = pmPSFAlloc (options); 119 psfTry->mask = psVectorCopy (NULL, srcMask, PS_TYPE_VECTOR_MASK); 120 121 // stage 2: construct a psf (pmPSF) from this collection of model fits, including the 2D variation 122 if (!pmPSFtryMakePSF (psfTry)) { 123 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 124 psFree(psfTry); 125 return NULL; 126 } 127 128 // stage 3: refit with fixed shape parameters, measure pmPSFtry->metric 129 if (!pmPSFtryFitPSF (psfTry, options, maskVal, markVal)) { 130 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 131 psFree(psfTry); 132 return NULL; 133 } 134 135 // stage 4: measure systematic error in pmPSFtry->metric 136 if (!pmPSFtryMetric (psfTry)) { 137 psError(PS_ERR_UNKNOWN, false, "failed to measure systematic error of metric"); 138 psFree(psfTry); 139 return NULL; 140 } 141 142 if (!minPSF) { 143 minPSF = psMemIncrRefCounter(psfTry->psf); 144 minMask = psMemIncrRefCounter(psfTry->mask); 145 } 146 147 if (psfTry->psf->dApResid < minPSF->dApResid) { 148 psFree (minPSF); 149 psFree (minMask); 150 minPSF = psMemIncrRefCounter(psfTry->psf); 151 minMask = psMemIncrRefCounter(psfTry->mask); 152 } 147 153 } 148 154 psFree (srcMask); … … 153 159 psfTry->psf = minPSF; 154 160 psfTry->mask = minMask; 155 161 156 162 // XXXXX this is probably not used any more. Are the chisq of the fits so bad? can we 157 163 // fix them by softening the errors on the brightest pixels?
Note:
See TracChangeset
for help on using the changeset viewer.
