Changeset 35639
- Timestamp:
- Jun 9, 2013, 3:30:23 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130509/psModules/src
- Files:
-
- 10 edited
-
objects/models/pmModel_PS1_V1.c (modified) (1 diff)
-
objects/models/pmModel_QGAUSS.c (modified) (6 diffs)
-
objects/models/pmModel_TRAIL.c (modified) (1 diff)
-
objects/pmPSFtry.h (modified) (1 diff)
-
objects/pmPSFtryFitEXT.c (modified) (3 diffs)
-
objects/pmPSFtryFitPSF.c (modified) (5 diffs)
-
objects/pmSourceFitModel.c (modified) (3 diffs)
-
objects/pmSourceFitModel.h (modified) (1 diff)
-
objects/pmSourceFitSet.c (modified) (1 diff)
-
psmodules.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_PS1_V1.c
r35560 r35639 1 1 /****************************************************************************** 2 * this file defines the PS1_V1 source shape model. Note that these model functions are loaded 3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own. The 4 * models use a psVector to represent the set of parameters, with the sequence used to specify 5 * the meaning of the parameter. The meaning of the parameters may thus vary depending on the 6 * specifics of the model. All models which are used as a PSF representations share a few 7 * parameters, for which # define names are listed in pmModel.h: 2 * this file defines the PS1_V1 source shape model. Note that these model functions are 3 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of 4 * their own. The models use a psVector to represent the set of parameters, with the 5 * sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used as a 7 * PSF representations share a few parameters, for which # define names are listed in 8 * pmModel.h: 8 9 9 10 power-law with fitted linear term -
branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_QGAUSS.c
r35560 r35639 1 1 /****************************************************************************** 2 * this file defines the QGAUSS source shape model (XXX need a better name!). Note that these 3 * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include' 4 * statements of their own. The models use a psVector to represent the set of parameters, with 5 * the sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used a PSF 7 * representations share a few parameters, for which # define names are listed in pmModel.h: 2 * this file defines the QGAUSS source shape model. Note that these model functions are 3 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of 4 * their own. The models use a psVector to represent the set of parameters, with the 5 * sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used as a 7 * PSF representations share a few parameters, for which # define names are listed in 8 * pmModel.h: 8 9 9 10 power-law with fitted linear term … … 14 15 * PM_PAR_XPOS 2 - X center of object 15 16 * PM_PAR_YPOS 3 - Y center of object 16 * PM_PAR_SXX 4 - X^2 term of elliptical contour ( sqrt(2) / SigmaX)17 * PM_PAR_SYY 5 - Y^2 term of elliptical contour ( sqrt(2) / SigmaY)17 * PM_PAR_SXX 4 - X^2 term of elliptical contour (SigmaX / sqrt(2)) 18 * PM_PAR_SYY 5 - Y^2 term of elliptical contour (SigmaY / sqrt(2)) 18 19 * PM_PAR_SXY 6 - X*Y term of elliptical contour 19 20 * PM_PAR_7 7 - amplitude of the linear component (k) … … 138 139 # define AR_MAX 20.0 139 140 # define AR_RATIO 0.99 140 141 141 bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta) 142 142 { … … 203 203 return true; 204 204 } 205 default:205 default: 206 206 psAbort("invalid choice for limits"); 207 207 } … … 293 293 if (flux >= PAR[PM_PAR_I0]) return 1.0; 294 294 295 // if (PAR[PM_PAR_7] == 0.0) return powf(PAR[PM_PAR_I0] / flux - 1.0, 1.0 / ALPHA);296 297 295 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 298 296 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; … … 307 305 return ( sigma * sqrt (2.0 * z) ); 308 306 } 309 310 307 psF64 limit = flux / PAR[PM_PAR_I0]; 311 308 -
branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_TRAIL.c
r35594 r35639 369 369 if (!isfinite(axes.theta)) return false; 370 370 371 float size = (axes.major > sqrt(source->moments->Mrf)) ? axes.major : sqrt(source->moments->Mrf); 372 // if (size > psfAxes.major) { size -= psfAxes.major; } 373 //else { size = psfAxes.major; } 371 float size = NAN; 372 if (!isfinite(source->moments->Mrf)) { 373 size = axes.major; 374 } else { 375 size = (axes.major > sqrt(source->moments->Mrf)) ? axes.major : sqrt(source->moments->Mrf); 376 } 374 377 375 378 float theta, peak; -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmPSFtry.h
r30044 r35639 99 99 /** fit EXT models to all possible psf sources */ 100 100 bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); 101 bool pmPSFtryFitEXT_Threaded (psThreadJob *job); 101 102 102 103 bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry); 103 104 104 105 bool pmPSFtryFitPSF (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); 106 bool pmPSFtryFitPSF_Threaded (psThreadJob *job); 107 108 bool pmPSFThreads (void); 105 109 106 110 /** pmPSFtryMetric() -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmPSFtryFitEXT.c
r35560 r35639 46 46 #include "pmSourceVisual.h" 47 47 48 bool pmPSFThreads (void) { 49 50 psThreadTask *task = NULL; 51 52 task = psThreadTaskAlloc("PSF_TRY_FIT_EXT", 6); 53 task->function = &pmPSFtryFitEXT_Threaded; 54 psThreadTaskAdd(task); 55 psFree(task); 56 57 task = psThreadTaskAlloc("PSF_TRY_FIT_PSF", 6); 58 task->function = &pmPSFtryFitPSF_Threaded; 59 psThreadTaskAdd(task); 60 psFree(task); 61 62 return true; 63 } 64 65 static int Next = 0; 66 48 67 // Fit an EXT model to all candidates PSF sources. 49 68 // Note: this is independent of the modeled 2D variations in the PSF. 50 69 bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal) { 51 52 bool status;53 70 54 71 psTimerStart ("psf.fit"); … … 60 77 maskVal |= markVal; 61 78 62 intNext = 0;79 Next = 0; 63 80 for (int i = 0; i < psfTry->sources->n; i++) { 64 81 65 82 pmSource *source = psfTry->sources->data[i]; 66 if (!source->moments) {67 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;68 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no moments\n", i, source->peak->x, source->peak->y);69 continue;70 }71 if (!source->moments->nPixels) {72 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no pixels\n", i, source->peak->x, source->peak->y);73 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;74 continue;75 }76 // If mask object does not exist, mark the source as bad.77 // We cannot proceed with it because psImageMaskPixels leaves an uncleared error code last which causes78 // psphot to exit with a fault.79 if (source->maskObj == NULL) {80 psTrace ("psModules.objects", 4, "source %d (%d,%d) : null maskObj\n", i, source->peak->x, source->peak->y);81 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;82 continue;83 }84 83 85 source->modelEXT = pmSourceModelGuess (source, options->type, maskVal, markVal); 86 if (source->modelEXT == NULL) { 87 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 88 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 89 continue; 90 } 84 if (!source->moments) { 85 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 86 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no moments\n", i, source->peak->x, source->peak->y); 87 continue; 88 } 89 if (!source->moments->nPixels) { 90 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : no pixels\n", i, source->peak->x, source->peak->y); 91 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 92 continue; 93 } 94 // If mask object does not exist, mark the source as bad. 95 // We cannot proceed with it because psImageMaskPixels leaves an uncleared error code last which causes 96 // psphot to exit with a fault. 97 if (source->maskObj == NULL) { 98 psTrace ("psModules.objects", 4, "source %d (%d,%d) : null maskObj\n", i, source->peak->x, source->peak->y); 99 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 100 continue; 101 } 91 102 92 // set object mask to define valid pixels 93 // XXX 0.5 PIX: is the circle symmetric about the peak coordinate (given 0.5,0.5 center)? 94 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 103 source->modelEXT = pmSourceModelGuess (source, options->type, maskVal, markVal); 104 if (source->modelEXT == NULL) { 105 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 106 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 107 continue; 108 } 95 109 96 // fit model as EXT, not PSF 97 status = pmSourceFitModel (source, source->modelEXT, options->fitOptions, maskVal); 110 // do some actual work on this source 111 psThreadJob *job = psThreadJobAlloc ("PSF_TRY_FIT_EXT"); 112 psArrayAdd(job->args, 1, source); 113 psArrayAdd(job->args, 1, psfTry); 114 psArrayAdd(job->args, 1, options); 115 116 PS_ARRAY_ADD_SCALAR(job->args, i, PS_TYPE_S32); 98 117 99 // clear object mask to define valid pixels 100 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 118 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 119 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 101 120 102 // exclude the poor fits 103 if (!status) { 104 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 105 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 106 continue; 107 } 108 Next ++; 121 # if (1) 122 if (!psThreadJobAddPending(job)) { 123 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 124 return false; 125 } 126 # else 127 if (!pmPSFtryFitEXT_Threaded(job)) { 128 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 129 return false; 130 } 131 psFree(job); 132 # endif 109 133 } 134 135 // wait for the threads to finish and manage results 136 if (!psThreadPoolWait (false, true)) { 137 psError(PS_ERR_UNKNOWN, false, "failure to model psf"); 138 return false; 139 } 140 141 // we have only supplied one type of job, so we can assume the types here 142 psThreadJob *job = NULL; 143 while ((job = psThreadJobGetDone()) != NULL) { 144 // we have no returned data from this operation 145 if (job->args->n < 1) fprintf (stderr, "error with job\n"); 146 psFree(job); 147 } 148 110 149 psLogMsg ("psphot.psftry", PS_LOG_MINUTIA, "fit ext: %f sec for %d of %ld sources\n", psTimerMark ("psf.fit"), Next, psfTry->sources->n); 111 150 psTrace ("psModules.object", 3, "keeping %d of %ld PSF candidates (EXT)\n", Next, psfTry->sources->n); … … 118 157 return true; 119 158 } 159 160 bool pmPSFtryFitEXT_Threaded (psThreadJob *job) { 161 162 pmSource *source = job->args->data[0]; 163 pmPSFtry *psfTry = job->args->data[1]; 164 pmPSFOptions *options = job->args->data[2]; 165 166 int i = PS_SCALAR_VALUE(job->args->data[3], S32); 167 168 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 169 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 170 171 // set object mask to define valid pixels 172 // XXX 0.5 PIX: is the circle symmetric about the peak coordinate (given 0.5,0.5 center)? 173 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 174 175 // fit model as EXT, not PSF 176 bool status = pmSourceFitModel (source, source->modelEXT, options->fitOptions, maskVal); 177 178 // clear object mask to define valid pixels 179 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 180 181 // exclude the poor fits 182 if (!status) { 183 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 184 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 185 return true; 186 } 187 Next ++; 188 189 return true; 190 } -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmPSFtryFitPSF.c
r34403 r35639 43 43 #include "pmSourceVisual.h" 44 44 45 static int Npsf = 0; 46 45 47 // stage 3: Refit with fixed shape parameters. This function uses the LMM fitting, but could 46 48 // be re-written to use the simultaneous linear fitting (see psphotFitSourcesLinear.c) 47 49 bool pmPSFtryFitPSF (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal) { 48 50 49 bool status;50 51 51 psTimerStart ("psf.fit"); 52 52 … … 57 57 maskVal |= markVal; 58 58 59 // DEBUG code: save the PSF model fit data in detail 60 # ifdef DEBUG 61 char filename[64]; 62 snprintf (filename, 64, "psffit.%dx%d.dat", psfTry->psf->trendNx, psfTry->psf->trendNy); 63 FILE *f = fopen (filename, "w"); 64 psAssert (f, "failed open"); 65 # endif 66 67 int Npsf = 0; 59 Npsf = 0; 68 60 for (int i = 0; i < psfTry->sources->n; i++) { 69 61 … … 77 69 } 78 70 79 // set shape for this model based on PSF71 // set shape for this model based on PSF 80 72 psFree (source->modelPSF); 81 source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf); 82 if (source->modelPSF == NULL) { 83 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL; 84 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : bad PSF fit\n", i, source->peak->x, source->peak->y); 85 continue; 86 } 87 // PSF fit and aperture mags use different radii 88 source->modelPSF->fitRadius = options->fitRadius; 89 source->apRadius = options->apRadius; 90 91 // set object mask to define valid pixels for PSF model fit 92 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 93 94 // fit the PSF model to the source 95 status = pmSourceFitModel (source, source->modelPSF, options->fitOptions, maskVal); 96 97 // skip poor fits 98 if (!status) { 99 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 100 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 101 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); 102 continue; 103 } 104 105 // set object mask to define valid pixels for APERTURE magnitude 106 if (options->fitRadius != options->apRadius) { 107 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 108 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 73 source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf); 74 if (source->modelPSF == NULL) { 75 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL; 76 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : bad PSF fit\n", i, source->peak->x, source->peak->y); 77 return false; 109 78 } 110 79 111 // This function calculates the psf and aperture magnitudes 112 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, markVal, options->apRadius); // raw PSF mag, AP mag 113 if (!status || isnan(source->apMag)) { 114 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 115 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 116 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); 117 continue; 118 } 119 120 // clear object mask to define valid pixels 121 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 122 123 psfTry->fitMag->data.F32[i] = source->psfMag; 124 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 125 psfTry->metricErr->data.F32[i] = source->psfMagErr; 126 127 // XXX this did not work: modifies shape of psf too much 128 // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag; 129 80 // do some actual work on this source 81 psThreadJob *job = psThreadJobAlloc ("PSF_TRY_FIT_PSF"); 82 psArrayAdd(job->args, 1, source); 83 psArrayAdd(job->args, 1, psfTry); 84 psArrayAdd(job->args, 1, options); 85 86 PS_ARRAY_ADD_SCALAR(job->args, i, PS_TYPE_S32); 87 88 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 89 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 90 91 # if (1) 92 if (!psThreadJobAddPending(job)) { 93 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 94 return false; 95 } 96 # else 97 if (!pmPSFtryFitPSF_Threaded(job)) { 98 psError(PS_ERR_UNKNOWN, false, "Unable to create psf model."); 99 return false; 100 } 101 psFree(job); 102 # endif 103 } 104 105 // wait for the threads to finish and manage results 106 if (!psThreadPoolWait (false, true)) { 107 psError(PS_ERR_UNKNOWN, false, "failure to model psf"); 108 return false; 109 } 110 111 // we have only supplied one type of job, so we can assume the types here 112 psThreadJob *job = NULL; 113 while ((job = psThreadJobGetDone()) != NULL) { 114 // we have no returned data from this operation 115 if (job->args->n < 1) fprintf (stderr, "error with job\n"); 116 psFree(job); 117 } 118 psfTry->psf->nPSFstars = Npsf; 119 120 // DEBUG code: save the PSF model fit data in detail 130 121 # ifdef DEBUG 122 123 char filename[64]; 124 snprintf (filename, 64, "psffit.%dx%d.dat", psfTry->psf->trendNx, psfTry->psf->trendNy); 125 FILE *f = fopen (filename, "w"); 126 psAssert (f, "failed open"); 127 128 for (int i = 0; i < psfTry->sources->n; i++) { 129 130 // skip masked sources 131 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue; 132 133 pmSource *source = psfTry->sources->data[i]; 134 131 135 fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f\n", 132 136 source->peak->xf, source->peak->yf, … … 136 140 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY], 137 141 source->modelPSF->params->data.F32[PM_PAR_SYY], source->modelPSF->params->data.F32[PM_PAR_7]); 138 # endif 139 140 psTrace ("psModules.object", 6, "keeping source %d (%d) of %ld\n", i, Npsf, psfTry->sources->n); 141 Npsf ++; 142 } 143 psfTry->psf->nPSFstars = Npsf; 144 145 # ifdef DEBUG 142 } 146 143 fclose (f); 147 144 # endif … … 159 156 return true; 160 157 } 158 159 bool pmPSFtryFitPSF_Threaded (psThreadJob *job) { 160 161 pmSource *source = job->args->data[0]; 162 pmPSFtry *psfTry = job->args->data[1]; 163 pmPSFOptions *options = job->args->data[2]; 164 165 int i = PS_SCALAR_VALUE(job->args->data[3], S32); 166 167 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 168 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 169 170 // PSF fit and aperture mags use different radii 171 source->modelPSF->fitRadius = options->fitRadius; 172 source->apRadius = options->apRadius; 173 174 // set object mask to define valid pixels for PSF model fit 175 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 176 177 // fit the PSF model to the source 178 bool status = pmSourceFitModel (source, source->modelPSF, options->fitOptions, maskVal); 179 180 // skip poor fits 181 if (!status) { 182 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 183 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 184 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); 185 return true; 186 } 187 188 // set object mask to define valid pixels for APERTURE magnitude 189 if (options->fitRadius != options->apRadius) { 190 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 191 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 192 } 193 194 // This function calculates the psf and aperture magnitudes 195 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, markVal, options->apRadius); // raw PSF mag, AP mag 196 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 197 198 if (!status || isnan(source->apMag)) { 199 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 200 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); 201 return true; 202 } 203 204 psfTry->fitMag->data.F32[i] = source->psfMag; 205 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 206 psfTry->metricErr->data.F32[i] = source->psfMagErr; 207 208 psTrace ("psModules.object", 6, "keeping source %d (%d) of %ld\n", i, Npsf, psfTry->sources->n); 209 Npsf ++; 210 return true; 211 } -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmSourceFitModel.c
r35628 r35639 62 62 opt->poissonErrors = true; 63 63 opt->saveCovariance = false; 64 65 // we default to the old algorithm 66 opt->gainFactorMode = 0; 67 opt->chisqConvergence = true; 64 68 65 69 return opt; … … 241 245 242 246 psMinimization *myMin = psMinimizationAlloc (options->nIter, options->minTol, options->maxTol); 247 myMin->gainFactorMode = options->gainFactorMode; 248 myMin->chisqConvergence = options->chisqConvergence; 243 249 244 250 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); … … 274 280 model->flags |= PM_MODEL_STATUS_FITTED; 275 281 if (!fitStatus) model->flags |= PM_MODEL_STATUS_NONCONVERGE; 276 if (myMin->lastDelta > myMin->minTol) model->flags |= PM_MODEL_STATUS_WEAK_FIT; 282 283 if (myMin->chisqConvergence) { 284 if (myMin->lastDelta > myMin->minTol) model->flags |= PM_MODEL_STATUS_WEAK_FIT; 285 } else { 286 if (myMin->rParSigma > myMin->minTol*nParams) model->flags |= PM_MODEL_STATUS_WEAK_FIT; 287 } 277 288 278 289 // get the Gauss-Newton distance for fixed model parameters -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmSourceFitModel.h
r34259 r35639 35 35 bool poissonErrors; ///< use poisson errors for fits? 36 36 bool saveCovariance; 37 int gainFactorMode; 38 bool chisqConvergence; 37 39 } pmSourceFitOptions; 38 40 -
branches/eam_branches/ipp-20130509/psModules/src/objects/pmSourceFitSet.c
r34403 r35639 568 568 569 569 psMinimization *myMin = psMinimizationAlloc (options->nIter, options->minTol, options->maxTol); 570 myMin->gainFactorMode = options->gainFactorMode; 571 myMin->chisqConvergence = options->chisqConvergence; 570 572 571 573 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); -
branches/eam_branches/ipp-20130509/psModules/src/psmodules.h
r34403 r35639 158 158 #include <pmReadoutFake.h> 159 159 #include <pmPSFEnvelope.h> 160 #include <pmThreadTools.h> 160 161 161 162 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
