Changeset 36196
- Timestamp:
- Oct 9, 2013, 4:10:40 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psModules
- Files:
-
- 5 edited
-
. (modified) (1 prop)
-
src/objects/models/pmModel_DEV.c (modified) (4 diffs)
-
src/objects/models/pmModel_EXP.c (modified) (3 diffs)
-
src/objects/pmPSFtryFitPSF.c (modified) (2 diffs)
-
src/objects/pmPSFtryModel.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules
- Property svn:mergeinfo changed
/trunk/psModules (added) merged: 36106,36123
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130904/psModules/src/objects/models/pmModel_DEV.c
r36085 r36196 117 117 118 118 assert (isfinite(q)); 119 assert (isfinite(f0));120 119 121 120 // only worry about the central pixels at most … … 129 128 f0 = pmModelCP_SersicSubpix (X, Y, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], 4.0, Nsub); 130 129 } 130 assert (isfinite(f0)); 131 131 132 132 float f1 = PAR[PM_PAR_I0]*f0; … … 243 243 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 244 244 { 245 // for the moment, we are going to require moments and KronFlux 246 if (!source->moments) return false; 247 pmMoments *moments = source->moments; 248 249 if (!isfinite(moments->KronFlux)) return false; 250 if (!isfinite(moments->Mrf)) return false; 251 if (moments->Mrf < 0.0) return false; 252 245 253 psF32 *PAR = model->params->data.F32; 246 254 … … 248 256 PAR[PM_PAR_SKY] = 0.0; 249 257 250 // set the shape parameters 251 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) { 252 return false; 253 } 254 255 // set the model normalization 256 if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) { 257 return false; 258 } 258 psEllipseMoments emoments; 259 emoments.x2 = moments->Mxx; 260 emoments.xy = moments->Mxy; 261 emoments.y2 = moments->Myy; 262 263 // force the axis ratio to be < 20.0 264 psEllipseAxes axes = psEllipseMomentsToAxes (emoments, 20.0); 265 266 if (!isfinite(axes.major)) return false; 267 if (!isfinite(axes.minor)) return false; 268 if (!isfinite(axes.theta)) return false; 269 270 // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width 271 float scale = moments->Mrf / axes.major; 272 axes.major *= scale; 273 axes.minor *= scale; 274 275 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true); 276 277 // psEllipseAxes axes; 278 // use the code in SetShape here to avoid doing this 2x 279 // pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 280 281 // float norm = pmSersicNorm (4); // hardwire 282 float norm = 0.00168012; 283 float normFlux = 2.0 * M_PI * axes.major * axes.minor * norm; 284 PAR[PM_PAR_I0] = moments->KronFlux / normFlux; 259 285 260 286 // set the model position -
branches/eam_branches/ipp-20130904/psModules/src/objects/models/pmModel_EXP.c
r36085 r36196 237 237 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 238 238 { 239 // for the moment, we are going to require moments and KronFlux 240 if (!source->moments) return false; 241 pmMoments *moments = source->moments; 242 243 if (!isfinite(moments->KronFlux)) return false; 244 if (!isfinite(moments->Mrf)) return false; 245 if (moments->Mrf < 0.0) return false; 246 239 247 psF32 *PAR = model->params->data.F32; 240 248 … … 242 250 PAR[PM_PAR_SKY] = 0.0; 243 251 244 // set the shape parameters 245 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) { 246 return false; 247 } 248 249 // set the model normalization 250 if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) { 251 return false; 252 } 252 psEllipseMoments emoments; 253 emoments.x2 = moments->Mxx; 254 emoments.xy = moments->Mxy; 255 emoments.y2 = moments->Myy; 256 257 // force the axis ratio to be < 20.0 258 psEllipseAxes axes = psEllipseMomentsToAxes (emoments, 20.0); 259 260 if (!isfinite(axes.major)) return false; 261 if (!isfinite(axes.minor)) return false; 262 if (!isfinite(axes.theta)) return false; 263 264 // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width 265 float scale = moments->Mrf / axes.major; 266 axes.major *= scale; 267 axes.minor *= scale; 268 269 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true); 270 271 // psEllipseAxes axes; 272 // use the code in SetShape here to avoid doing this 2x 273 // pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 274 275 // float norm = pmSersicNorm (4); // hardwire 276 float norm = 0.34578; 277 float normFlux = 2.0 * M_PI * axes.major * axes.minor * norm; 278 PAR[PM_PAR_I0] = moments->KronFlux / normFlux; 253 279 254 280 // set the model position … … 259 285 return(true); 260 286 } 261 262 287 // An exponential model is equivalent to a Sersic with index = 1.0 263 288 psF64 PM_MODEL_FLUX (const psVector *params) -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPSFtryFitPSF.c
r35925 r36196 118 118 psfTry->psf->nPSFstars = Npsf; 119 119 120 // DEBUG code: save the PSF model fit data in detail121 # ifdef DEBUG122 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 sources131 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue;132 133 pmSource *source = psfTry->sources->data[i];134 135 fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f\n",136 source->peak->xf, source->peak->yf,137 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS],138 source->psfMag, source->apMag, source->psfMagErr,139 source->modelPSF->params->data.F32[PM_PAR_I0],140 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY],141 source->modelPSF->params->data.F32[PM_PAR_SYY], source->modelPSF->params->data.F32[PM_PAR_7]);142 }143 fclose (f);144 # endif145 146 120 pmSourceVisualShowModelFits (psfTry->psf, psfTry->sources, maskVal); 147 121 … … 150 124 151 125 if (Npsf == 0) { 152 psError(PS_ERR_UNKNOWN, false, "No sources with good PSF fits after model is built."); 153 return false; 126 // DEBUG code: save the PSF model fit data in detail 127 128 char hostname[256]; 129 gethostname (hostname, 256); 130 131 int pid = getpid(); 132 133 char filename[64]; 134 snprintf (filename, 64, "psffit.%s.%d.%dx%d.dat", hostname, pid, psfTry->psf->trendNx, psfTry->psf->trendNy); 135 FILE *f = fopen (filename, "w"); 136 psAssert (f, "failed open"); 137 138 for (int i = 0; i < psfTry->sources->n; i++) { 139 140 // skip masked sources 141 // if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue; 142 143 pmSource *source = psfTry->sources->data[i]; 144 145 float par7 = (source->modelPSF->params->n == 7) ? -100 : source->modelPSF->params->data.F32[PM_PAR_7]; 146 fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f %d\n", 147 source->peak->xf, source->peak->yf, 148 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS], 149 source->psfMag, source->apMag, source->psfMagErr, 150 source->modelPSF->params->data.F32[PM_PAR_I0], 151 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY], 152 source->modelPSF->params->data.F32[PM_PAR_SYY], par7, 153 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 154 } 155 fclose (f); 156 157 psError(PS_ERR_UNKNOWN, false, "No sources with good PSF fits after model is built."); 158 return false; 154 159 } 155 160 -
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPSFtryModel.c
r34403 r36196 236 236 // linear clipped fit of chisq trend vs flux 237 237 if (options->chiFluxTrend) { 238 239 if (0) { 240 FILE *f = fopen ("test.psf.dat", "w"); 241 int fd = fileno (f); 242 p_psVectorPrint (fd, flux, "flux"); 243 p_psVectorPrint (fd, chisq, "chisq"); 244 p_psVectorPrint (fd, mask, "mask"); 245 fclose (f); 246 } 247 238 248 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, 239 249 mask, 0xff, chisq, NULL, flux);
Note:
See TracChangeset
for help on using the changeset viewer.
