Changeset 25496
- Timestamp:
- Sep 23, 2009, 11:16:52 AM (17 years ago)
- Location:
- branches/eam_branches/20090715/psModules
- Files:
-
- 19 edited
-
src/extras/pmVisual.c (modified) (1 diff)
-
src/imcombine/pmPSFEnvelope.c (modified) (1 diff)
-
src/objects/pmModel.c (modified) (2 diffs)
-
src/objects/pmModel.h (modified) (1 diff)
-
src/objects/pmPSF.h (modified) (1 diff)
-
src/objects/pmPSFtryFitEXT.c (modified) (2 diffs)
-
src/objects/pmPSFtryFitPSF.c (modified) (5 diffs)
-
src/objects/pmPSFtryMakePSF.c (modified) (5 diffs)
-
src/objects/pmSource.h (modified) (1 diff)
-
src/objects/pmSourceIO_CMF_PS1_V1.c (modified) (3 diffs)
-
src/objects/pmSourceIO_CMF_PS1_V2.c (modified) (3 diffs)
-
src/objects/pmSourceIO_RAW.c (modified) (2 diffs)
-
src/objects/pmSourcePhotometry.c (modified) (1 diff)
-
src/objects/pmSourceVisual.c (modified) (9 diffs)
-
src/objects/pmSourceVisual.h (modified) (1 diff)
-
test/objects/tap_pmGrowthCurve.c (modified) (3 diffs)
-
test/objects/tap_pmModel.c (modified) (3 diffs)
-
test/objects/tap_pmModelUtils.c (modified) (2 diffs)
-
test/objects/tap_pmSourcePhotometry.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psModules/src/extras/pmVisual.c
r25476 r25496 24 24 #include "pmPSF.h" 25 25 #include "pmPSFtry.h" 26 #include "pmSource.h" 26 27 #include "pmFPAExtent.h" 27 28 -
branches/eam_branches/20090715/psModules/src/imcombine/pmPSFEnvelope.c
r25407 r25496 320 320 options->poissonErrorsParams = true; 321 321 options->stats = psStatsAlloc(PSF_STATS); 322 options->radius = maxRadius; 322 options->fitRadius = maxRadius; 323 options->apRadius = maxRadius; // XXX need to decide if aperture mags need a different radius 323 324 options->psfTrendMode = PM_TREND_MAP; 324 325 options->psfTrendNx = xOrder; -
branches/eam_branches/20090715/psModules/src/objects/pmModel.c
r25355 r25496 62 62 tmp->nPix = 0; 63 63 tmp->nIter = 0; 64 tmp-> radiusFit= 0;64 tmp->fitRadius = 0; 65 65 tmp->flags = PM_MODEL_STATUS_NONE; 66 66 tmp->residuals = NULL; // XXX should the model own this memory? … … 109 109 new->nIter = model->nIter; 110 110 new->flags = model->flags; 111 new-> radiusFit = model->radiusFit;111 new->fitRadius = model->fitRadius; 112 112 113 113 for (int i = 0; i < new->params->n; i++) { -
branches/eam_branches/20090715/psModules/src/objects/pmModel.h
r21516 r25496 96 96 int nIter; ///< number of iterations to reach min 97 97 pmModelStatus flags; ///< model status flags 98 float radiusFit; ///< fit radius actually used98 float fitRadius; ///< fit radius actually used 99 99 pmResiduals *residuals; ///< normalized PSF residuals 100 100 -
branches/eam_branches/20090715/psModules/src/objects/pmPSF.h
r25476 r25496 79 79 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting 80 80 bool poissonErrorsParams; ///< use poission errors for model parameter fitting 81 float radius; 81 float fitRadius; 82 float apRadius; 82 83 bool chiFluxTrend; // Fit a trend in Chi2 as a function of flux? 83 84 } pmPSFOptions; -
branches/eam_branches/20090715/psModules/src/objects/pmPSFtryFitEXT.c
r25476 r25496 70 70 // set object mask to define valid pixels 71 71 // XXX 0.5 PIX: is the circle symmetric about the peak coordinate (given 0.5,0.5 center)? 72 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "OR", markVal);72 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 73 73 74 74 // fit model as EXT, not PSF … … 76 76 77 77 // clear object mask to define valid pixels 78 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "AND", PS_NOT_IMAGE_MASK(markVal));78 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 79 79 80 80 // exclude the poor fits -
branches/eam_branches/20090715/psModules/src/objects/pmPSFtryFitPSF.c
r25476 r25496 67 67 continue; 68 68 } 69 source->modelPSF->radiusFit = options->radius; 70 // XXXX use a different radius for the aperture magnitude than for the PSF fit? 69 // PSF fit and aperture mags use different radii 70 source->modelPSF->fitRadius = options->fitRadius; 71 source->apRadius = options->apRadius; 71 72 72 // set object mask to define valid pixels 73 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "OR", markVal);73 // set object mask to define valid pixels for PSF model fit 74 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "OR", markVal); 74 75 75 76 // fit the PSF model to the source … … 78 79 // skip poor fits 79 80 if (!status) { 80 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "AND", PS_NOT_IMAGE_MASK(markVal));81 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 81 82 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 82 83 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); … … 84 85 } 85 86 86 // XXX this function calculates the aperture magnitude, but we now use the moments->Sum as the flux 87 // set object mask to define valid pixels for APERTURE magnitude 88 if (options->fitRadius < options->apRadius) { 89 // this is not really a recommended situation... 90 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 91 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 92 } 93 if (options->fitRadius > options->apRadius) { 94 // ensure the aperture is defined 95 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 96 } 97 98 // This function calculates the psf and aperture magnitudes 87 99 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); 88 100 if (!status || isnan(source->apMag)) { 89 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "AND", PS_NOT_IMAGE_MASK(markVal));101 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 90 102 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 91 103 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); … … 94 106 95 107 // clear object mask to define valid pixels 96 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options-> radius, "AND", PS_NOT_IMAGE_MASK(markVal));108 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 97 109 98 110 psfTry->fitMag->data.F32[i] = source->psfMag; 99 psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag; 111 // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag; 112 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 100 113 psfTry->metricErr->data.F32[i] = source->errMag; 101 114 … … 104 117 } 105 118 psfTry->psf->nPSFstars = Npsf; 119 120 // XXX test code: 121 pmSourceVisualShowModelFits (psfTry->psf, psfTry->sources, maskVal); 106 122 107 123 psLogMsg ("psphot.psftry", PS_LOG_MINUTIA, "fit psf: %f sec for %d of %ld sources\n", psTimerMark ("psf.fit"), Npsf, psfTry->sources->n); -
branches/eam_branches/20090715/psModules/src/objects/pmPSFtryMakePSF.c
r25476 r25496 184 184 // we run 'clipIter' cycles clipping in each of x and y, with only one iteration each. 185 185 // This way, the parameters masked by one of the fits will be applied to the others 186 for (int i = 0; i < psf->psfTrendStats->clipIter; i++) { 186 // NOTE : trend->stats (below) points to the same data as psfTrendStats; set the value to 1 187 // to limit the iteration within the loop 188 int nIter = psf->psfTrendStats->clipIter; 189 psf->psfTrendStats->clipIter = 1; 190 for (int i = 0; i < nIter; i++) { 187 191 // XXX we are using the same stats structure on each pass: do we need to re-init it? 188 192 // XXX we hardwire this to SAMPLE stats above (psphotChoosePSF.c), hardwire here instead? … … 203 207 psTrace ("psModules.objects", 4, "clipped E0 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e0->n); 204 208 if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map); 205 //pmSourceVisualPSFModelResid (trend, x, y, e0, srcMask);209 pmSourceVisualPSFModelResid (trend, x, y, e0, srcMask); 206 210 207 211 trend = psf->params->data[PM_PAR_E1]; … … 212 216 psTrace ("psModules.objects", 4, "clipped E1 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e1->n); 213 217 if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map); 214 //pmSourceVisualPSFModelResid (trend, x, y, e1, srcMask);218 pmSourceVisualPSFModelResid (trend, x, y, e1, srcMask); 215 219 216 220 trend = psf->params->data[PM_PAR_E2]; … … 221 225 psTrace ("psModules.objects", 4, "clipped E2 : %f +/- %f keeping %ld of %ld\n", mean, stdev, psf->psfTrendStats->clippedNvalues, e2->n); 222 226 if (psf->psfTrendMode == PM_TREND_MAP) psImageMapCleanup (trend->map); 223 //pmSourceVisualPSFModelResid (trend, x, y, e2, srcMask);227 pmSourceVisualPSFModelResid (trend, x, y, e2, srcMask); 224 228 225 229 if (!status) { … … 228 232 } 229 233 } 234 psf->psfTrendStats->clipIter = nIter; 230 235 231 236 // test dump of the psf parameters -
branches/eam_branches/20090715/psModules/src/objects/pmSource.h
r25385 r25496 82 82 float extNsigma; ///< Nsigma deviation from PSF to EXT 83 83 float sky, skyErr; ///< The sky and its error at the center of the object 84 float apRadius; 84 85 psRegion region; ///< area on image covered by selected pixels 85 86 pmSourceExtendedPars *extpars; ///< extended source parameters -
branches/eam_branches/20090715/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c
r25451 r25496 128 128 nDOF = model->nDOF; 129 129 nPix = model->nPix; 130 apRadius = model->radiusFit; // XXX should we really use the fitRadius for aperture Radius?130 apRadius = source->apRadius; 131 131 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 132 132 } else { … … 308 308 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); 309 309 source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA"); 310 source->apRadius = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS"); 310 311 311 312 // note that some older versions used PSF_PROBABILITY: this was not well defined. … … 313 314 model->nDOF = psMetadataLookupS32 (&status, row, "PSF_NDOF"); 314 315 model->nPix = psMetadataLookupS32 (&status, row, "PSF_NPIX"); 315 model->radiusFit = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS");316 316 317 317 source->moments = pmMomentsAlloc (); -
branches/eam_branches/20090715/psModules/src/objects/pmSourceIO_CMF_PS1_V2.c
r25452 r25496 128 128 nDOF = model->nDOF; 129 129 nPix = model->nPix; 130 apRadius = model->radiusFit; // XXX should we really use the fitRadius for aperture Radius?130 apRadius = source->apRadius; 131 131 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 132 132 } else { … … 308 308 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); 309 309 source->extNsigma = psMetadataLookupF32 (&status, row, "EXT_NSIGMA"); 310 source->apRadius = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS"); 310 311 311 312 // note that some older versions used PSF_PROBABILITY: this was not well defined. … … 313 314 model->nDOF = psMetadataLookupS32 (&status, row, "PSF_NDOF"); 314 315 model->nPix = psMetadataLookupS32 (&status, row, "PSF_NPIX"); 315 model->radiusFit = psMetadataLookupS32 (&status, row, "AP_MAG_RADIUS");316 316 317 317 source->moments = pmMomentsAlloc (); -
branches/eam_branches/20090715/psModules/src/objects/pmSourceIO_RAW.c
r24581 r25496 119 119 logChi, logChiNorm, 120 120 source[0].peak->SN, 121 model[0].radiusFit,121 source[0].apRadius, 122 122 source[0].pixWeight, 123 123 model[0].nDOF, … … 181 181 log10(model[0].chisqNorm/model[0].nDOF), 182 182 source[0].peak->SN, 183 model[0].radiusFit,183 source[0].apRadius, 184 184 source[0].pixWeight, 185 185 model[0].nDOF, -
branches/eam_branches/20090715/psModules/src/objects/pmSourcePhotometry.c
r21511 r25496 201 201 if (isfinite (source->apMag) && isPSF && psf) { 202 202 if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) { 203 source->apMag += pmGrowthCurveCorrect (psf->growth, model->radiusFit);203 source->apMag += pmGrowthCurveCorrect (psf->growth, source->apRadius); 204 204 } 205 205 if (mode & PM_SOURCE_PHOT_APCORR) { 206 // XXX this should be removed -- we no longer fit for the 'sky bias' 206 207 rflux = pow (10.0, 0.4*source->psfMag); 207 source->apMag -= PS_SQR( model->radiusFit)*rflux * psf->skyBias + psf->skySat / rflux;208 source->apMag -= PS_SQR(source->apRadius)*rflux * psf->skyBias + psf->skySat / rflux; 208 209 } 209 210 } -
branches/eam_branches/20090715/psModules/src/objects/pmSourceVisual.c
r25476 r25496 7 7 #include "pmPSF.h" 8 8 #include "pmPSFtry.h" 9 #include "pmSource.h" 9 10 #include "pmSourceVisual.h" 10 11 … … 17 18 18 19 static int kapa1 = -1; 20 static int kapa2 = -1; 19 21 static bool plotPSF = true; 20 // static int kapa2 = -1;21 22 // static int kapa3 = -1; 22 23 … … 33 34 Graphdata graphdata; 34 35 35 if (!pmVisualIsVisual()) return true;36 // if (!pmVisualIsVisual()) return true; 36 37 37 38 if (kapa1 == -1) { … … 44 45 } 45 46 46 KapaClear Plots (kapa1);47 KapaClearSections (kapa1); 47 48 KapaInitGraph (&graphdata); 48 49 … … 112 113 } 113 114 115 // to see the structure of the psf model, place the sources in a fake image 1/10th the size 116 // at their appropriate relative location. later sources stomp on earlier sources 117 bool pmSourceVisualShowModelFits (pmPSF *psf, psArray *sources, psImageMaskType maskVal) { 118 119 // if (!pmVisualIsVisual()) return true; 120 121 if (kapa2 == -1) { 122 kapa2 = KapaOpenNamedSocket ("kapa", "pmSource:images"); 123 if (kapa2 == -1) { 124 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 125 pmVisualSetVisual(false); 126 return false; 127 } 128 } 129 130 // create images 1/10 scale: 131 psImage *image = psImageAlloc (0.1*psf->fieldNx, 0.1*psf->fieldNy, PS_TYPE_F32); 132 psImage *model = psImageAlloc (0.1*psf->fieldNx, 0.1*psf->fieldNy, PS_TYPE_F32); 133 psImage *resid = psImageAlloc (0.1*psf->fieldNx, 0.1*psf->fieldNy, PS_TYPE_F32); 134 psImageInit (image, 0.0); 135 psImageInit (model, 0.0); 136 psImageInit (resid, 0.0); 137 138 FILE *f = fopen ("stats.dat", "w"); 139 for (int i = 0; i < sources->n; i++) { 140 pmSource *source = sources->data[i]; 141 if (!source) continue; 142 if (!source->pixels) continue; 143 144 pmSourceCacheModel (source, maskVal); 145 if (!source->modelFlux) continue; 146 147 pmModel *srcModel = pmSourceGetModel (NULL, source); 148 if (!model) continue; 149 150 float norm = srcModel->params->data.F32[PM_PAR_I0]; 151 152 int Xo = 0.1*srcModel->params->data.F32[PM_PAR_XPOS]; 153 int Yo = 0.1*srcModel->params->data.F32[PM_PAR_YPOS]; 154 155 // insert source pixels in the image at 1/10th offset (XXX ignore centering for now) 156 // XXX calculate the pixel scatter values, chisq 157 for (int iy = 0; iy < source->pixels->numRows; iy++) { 158 int jy = iy + Yo; 159 if (jy >= image->numRows) continue; 160 for (int ix = 0; ix < source->pixels->numCols; ix++) { 161 int jx = ix + Xo; 162 if (jx >= image->numCols) continue; 163 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) continue; 164 if (source->modelFlux->data.F32[iy][ix] < 0.001) continue; 165 image->data.F32[jy][jx] = source->pixels->data.F32[iy][ix]; 166 model->data.F32[jy][jx] = source->modelFlux->data.F32[iy][ix]; 167 resid->data.F32[jy][jx] = source->pixels->data.F32[iy][ix] - norm*source->modelFlux->data.F32[iy][ix]; 168 } 169 } 170 171 fprintf (f, "%d, %d -> %f %f %f %f\n", Xo, Yo, norm, source->psfMag, source->apMag, -2.5*log10(source->moments->Sum)); 172 } 173 fclose (f); 174 175 // KapaClearSections (kapa2); 176 pmVisualScaleImage (kapa2, image, "image", 0, true); 177 pmVisualScaleImage (kapa2, model, "model", 1, true); 178 pmVisualScaleImage (kapa2, resid, "resid", 2, true); 179 180 { 181 psFits *fits = psFitsOpen ("image.fits", "w"); 182 psFitsWriteImage (fits, NULL, image, 0, NULL); 183 psFitsClose (fits); 184 fits = psFitsOpen ("model.fits", "w"); 185 psFitsWriteImage (fits, NULL, model, 0, NULL); 186 psFitsClose (fits); 187 fits = psFitsOpen ("resid.fits", "w"); 188 psFitsWriteImage (fits, NULL, resid, 0, NULL); 189 psFitsClose (fits); 190 } 191 192 psFree (image); 193 psFree (model); 194 psFree (resid); 195 196 // pause and wait for user input: 197 // continue, save (provide name), ?? 198 char key[10]; 199 fprintf (stdout, "[c]ontinue? "); 200 if (!fgets(key, 8, stdin)) { 201 psWarning("Unable to read option"); 202 } 203 return true; 204 } 205 206 bool pmSourceVisualShowModelFit (pmSource *source) { 207 208 // if (!pmVisualIsVisual()) return true; 209 if (!source->pixels) return false; 210 if (!source->modelFlux) return false; 211 212 if (kapa2 == -1) { 213 kapa2 = KapaOpenNamedSocket ("kapa", "pmSource:images"); 214 if (kapa2 == -1) { 215 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 216 pmVisualSetVisual(false); 217 return false; 218 } 219 } 220 221 // KapaClearSections (kapa2); 222 pmVisualScaleImage (kapa2, source->pixels, "source", 0, false); 223 pmVisualScaleImage (kapa2, source->modelFlux, "model", 1, false); 224 225 pmModel *model = pmSourceGetModel (NULL, source); 226 float norm = model->params->data.F32[PM_PAR_I0]; 227 228 psImage *resid = psImageAlloc (source->pixels->numCols, source->pixels->numRows, PS_TYPE_F32); 229 for (int iy = 0; iy < source->pixels->numRows; iy++) { 230 for (int ix = 0; ix < source->pixels->numCols; ix++) { 231 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 232 resid->data.F32[iy][ix] = NAN; 233 continue; 234 } 235 resid->data.F32[iy][ix] = source->pixels->data.F32[iy][ix] - norm*source->modelFlux->data.F32[iy][ix]; 236 } 237 } 238 pmVisualScaleImage (kapa2, resid, "resid", 2, false); 239 240 psFree (resid); 241 242 // pause and wait for user input: 243 // continue, save (provide name), ?? 244 char key[10]; 245 fprintf (stdout, "[c]ontinue? "); 246 if (!fgets(key, 8, stdin)) { 247 psWarning("Unable to read option"); 248 } 249 return true; 250 } 251 114 252 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask) { 115 253 … … 121 259 122 260 // XXX skip for now 123 return true;261 // return true; 124 262 125 263 if (kapa1 == -1) { … … 135 273 KapaInitGraph (&graphdata); 136 274 137 float min = +1e32; 138 float max = -1e32; 139 float Min = +1e32; 140 float Max = -1e32; 275 // float min = +1e32; 276 // float max = -1e32; 277 // float Min = +1e32; 278 // float Max = -1e32; 279 280 float Xmin = +1e32; 281 float Xmax = -1e32; 282 float Ymin = +1e32; 283 float Ymax = -1e32; 284 float Fmin = +1e32; 285 float Fmax = -1e32; 141 286 142 287 psVector *resid = psVectorAlloc (x->n, PS_TYPE_F32); 143 288 psVector *model = psVectorAlloc (x->n, PS_TYPE_F32); 144 289 290 psVector *xm = psVectorAlloc (x->n, PS_TYPE_F32); 291 psVector *ym = psVectorAlloc (x->n, PS_TYPE_F32); 292 psVector *Fm = psVectorAlloc (x->n, PS_TYPE_F32); 293 294 int n = 0; 145 295 for (int i = 0; i < x->n; i++) { 146 296 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 147 297 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i]; 148 298 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 149 min = PS_MIN (min, resid->data.F32[i]); 150 max = PS_MAX (max, resid->data.F32[i]); 151 Min = PS_MIN (min, param->data.F32[i]); 152 Max = PS_MAX (max, param->data.F32[i]); 153 } 154 155 psVector *xn = psVectorAlloc (x->n, PS_TYPE_F32); 156 psVector *yn = psVectorAlloc (x->n, PS_TYPE_F32); 157 psVector *zn = psVectorAlloc (x->n, PS_TYPE_F32); 158 psVector *Zn = psVectorAlloc (x->n, PS_TYPE_F32); 159 psVector *Fn = psVectorAlloc (x->n, PS_TYPE_F32); 160 for (int i = 0; i < x->n; i++) { 161 xn->data.F32[i] = x->data.F32[i] / 5000.0; 162 yn->data.F32[i] = y->data.F32[i] / 5000.0; 163 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min); 164 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min); 165 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min); 166 } 299 Xmin = PS_MIN (Xmin, x->data.F32[i]); 300 Xmax = PS_MAX (Xmax, x->data.F32[i]); 301 Ymin = PS_MIN (Ymin, y->data.F32[i]); 302 Ymax = PS_MAX (Ymax, y->data.F32[i]); 303 Fmin = PS_MIN (Fmin, param->data.F32[i]); 304 Fmax = PS_MAX (Fmax, param->data.F32[i]); 305 xm->data.F32[n] = x->data.F32[i]; 306 ym->data.F32[n] = y->data.F32[i]; 307 Fm->data.F32[n] = param->data.F32[i]; 308 n++; 309 } 310 xm->n = ym->n = Fm->n = n; 311 312 // psVector *xn = psVectorAlloc (x->n, PS_TYPE_F32); 313 // psVector *yn = psVectorAlloc (x->n, PS_TYPE_F32); 314 // psVector *zn = psVectorAlloc (x->n, PS_TYPE_F32); 315 // psVector *Zn = psVectorAlloc (x->n, PS_TYPE_F32); 316 // psVector *Fn = psVectorAlloc (x->n, PS_TYPE_F32); 317 // for (int i = 0; i < x->n; i++) { 318 // xn->data.F32[i] = x->data.F32[i] / 5000.0; 319 // yn->data.F32[i] = y->data.F32[i] / 5000.0; 320 // zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min); 321 // Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min); 322 // Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min); 323 // } 167 324 168 325 // view 1 on resid 169 section.dx = 0.5;170 section.dy = 0. 33;326 section.dx = 1.0; 327 section.dy = 0.5; 171 328 section.x = 0.0; 172 329 section.y = 0.0; … … 175 332 KapaSetSection (kapa1, §ion); 176 333 psFree (section.name); 177 pmSourcePlotPoints3D (kapa1, &graphdata, xn, yn, zn, 30.0*PS_RAD_DEG, -15.0*PS_RAD_DEG); 334 335 graphdata.color = KapaColorByName ("black"); 336 graphdata.xmin = Xmin; 337 graphdata.xmax = Xmax; 338 graphdata.ymin = Fmin; 339 graphdata.ymax = Fmax; 340 341 { 342 float range; 343 range = graphdata.xmax - graphdata.xmin; 344 graphdata.xmax += 0.05*range; 345 graphdata.xmin -= 0.05*range; 346 range = graphdata.ymax - graphdata.ymin; 347 graphdata.ymax += 0.05*range; 348 graphdata.ymin -= 0.05*range; 349 } 350 351 KapaSetLimits (kapa1, &graphdata); 352 KapaSetFont (kapa1, "helvetica", 14); 353 KapaBox (kapa1, &graphdata); 354 KapaSendLabel (kapa1, "X (pixels)", KAPA_LABEL_XM); 355 KapaSendLabel (kapa1, "Model Param", KAPA_LABEL_YM); 356 357 graphdata.ptype = 2; 358 graphdata.size = 1.0; 359 graphdata.style = 2; 360 KapaPrepPlot (kapa1, x->n, &graphdata); 361 KapaPlotVector (kapa1, x->n, x->data.F32, "x"); 362 KapaPlotVector (kapa1, x->n, param->data.F32, "y"); 363 364 graphdata.color = KapaColorByName ("red"); 365 graphdata.ptype = 1; 366 KapaPrepPlot (kapa1, xm->n, &graphdata); 367 KapaPlotVector (kapa1, xm->n, xm->data.F32, "x"); 368 KapaPlotVector (kapa1, xm->n, Fm->data.F32, "y"); 369 370 graphdata.color = KapaColorByName ("blue"); 371 graphdata.ptype = 1; 372 KapaPrepPlot (kapa1, x->n, &graphdata); 373 KapaPlotVector (kapa1, x->n, x->data.F32, "x"); 374 KapaPlotVector (kapa1, x->n, model->data.F32, "y"); 178 375 179 376 // view 2 on resid 180 section.dx = 0.5;181 section.dy = 0. 33;182 section.x = 0. 5;183 section.y = 0. 0;377 section.dx = 1.0; 378 section.dy = 0.5; 379 section.x = 0.0; 380 section.y = 0.5; 184 381 section.name = NULL; 185 382 psStringAppend (§ion.name, "a2"); 186 383 KapaSetSection (kapa1, §ion); 187 384 psFree (section.name); 188 pmSourcePlotPoints3D (kapa1, &graphdata, xn, yn, zn, -60.0*PS_RAD_DEG, -15.0*PS_RAD_DEG); 189 385 386 graphdata.color = KapaColorByName ("black"); 387 graphdata.xmin = Ymin; 388 graphdata.xmax = Ymax; 389 graphdata.ymin = Fmin; 390 graphdata.ymax = Fmax; 391 { 392 float range; 393 range = graphdata.xmax - graphdata.xmin; 394 graphdata.xmax += 0.05*range; 395 graphdata.xmin -= 0.05*range; 396 range = graphdata.ymax - graphdata.ymin; 397 graphdata.ymax += 0.05*range; 398 graphdata.ymin -= 0.05*range; 399 } 400 401 KapaSetLimits (kapa1, &graphdata); 402 KapaSetFont (kapa1, "helvetica", 14); 403 KapaBox (kapa1, &graphdata); 404 KapaSendLabel (kapa1, "Y (pixels)", KAPA_LABEL_XM); 405 KapaSendLabel (kapa1, "Model Param", KAPA_LABEL_YM); 406 407 graphdata.ptype = 2; 408 graphdata.size = 1.0; 409 graphdata.style = 2; 410 KapaPrepPlot (kapa1, y->n, &graphdata); 411 KapaPlotVector (kapa1, y->n, y->data.F32, "x"); 412 KapaPlotVector (kapa1, y->n, param->data.F32, "y"); 413 414 graphdata.color = KapaColorByName ("red"); 415 graphdata.ptype = 1; 416 KapaPrepPlot (kapa1, xm->n, &graphdata); 417 KapaPlotVector (kapa1, xm->n, ym->data.F32, "x"); 418 KapaPlotVector (kapa1, xm->n, Fm->data.F32, "y"); 419 420 graphdata.color = KapaColorByName ("blue"); 421 graphdata.ptype = 1; 422 KapaPrepPlot (kapa1, y->n, &graphdata); 423 KapaPlotVector (kapa1, y->n, y->data.F32, "x"); 424 KapaPlotVector (kapa1, y->n, model->data.F32, "y"); 425 426 # if (0) 190 427 // view 3 on resid 191 428 section.dx = 0.5; … … 231 468 psFree (section.name); 232 469 pmSourcePlotPoints3D (kapa1, &graphdata, xn, yn, Fn, -60.0*PS_RAD_DEG, -15.0*PS_RAD_DEG); 470 # endif 233 471 234 472 psFree (resid); 235 236 psFree (xn); 237 psFree (yn); 238 psFree (zn); 239 psFree (Zn); 473 psFree (model); 240 474 241 475 // pause and wait for user input: -
branches/eam_branches/20090715/psModules/src/objects/pmSourceVisual.h
r25476 r25496 19 19 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask); 20 20 bool pmSourceVisualPlotPSFMetric (pmPSFtry *try); 21 bool pmSourceVisualShowModelFit (pmSource *source); 22 bool pmSourceVisualShowModelFits (pmPSF *psf, psArray *sources, psImageMaskType maskVal); 21 23 22 24 /// @} -
branches/eam_branches/20090715/psModules/test/objects/tap_pmGrowthCurve.c
r25022 r25496 131 131 source->mode = PM_SOURCE_MODE_PSFSTAR; 132 132 133 source-> modelPSF->radiusFit= 15.0;133 source->apRadius = 15.0; 134 134 135 135 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 136 136 double refMag = source->apMag; 137 137 138 source-> modelPSF->radiusFit= 10.0;139 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 140 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 141 142 source-> modelPSF->radiusFit= 8.0;143 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 144 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 145 146 source-> modelPSF->radiusFit= 6.0;138 source->apRadius = 10.0; 139 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 140 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 141 142 source->apRadius = 8.0; 143 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 144 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 145 146 source->apRadius = 6.0; 147 147 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 148 148 ok_float_tol(refMag - source->apMag, +0.0003, 0.0001, "growth offset is is %f", refMag - source->apMag); 149 149 150 source-> modelPSF->radiusFit= 4.0;150 source->apRadius = 4.0; 151 151 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 152 152 ok_float_tol(refMag - source->apMag, +0.0020, 0.0001, "growth offset is is %f", refMag - source->apMag); 153 153 154 source-> modelPSF->radiusFit= 3.0;154 source->apRadius = 3.0; 155 155 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 156 156 ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag); 157 157 158 source-> modelPSF->radiusFit= 2.0;158 source->apRadius = 2.0; 159 159 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 160 160 ok_float_tol(refMag - source->apMag, -0.0075, 0.0001, "growth offset is is %f", refMag - source->apMag); … … 234 234 source->mode = PM_SOURCE_MODE_PSFSTAR; 235 235 236 source-> modelPSF->radiusFit= 15.0;236 source->apRadius = 15.0; 237 237 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 238 238 double refMag = source->apMag; 239 239 240 source-> modelPSF->radiusFit= 10.0;241 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 242 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 243 244 source-> modelPSF->radiusFit= 8.0;245 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 246 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 247 248 source-> modelPSF->radiusFit= 6.0;240 source->apRadius = 10.0; 241 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 242 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 243 244 source->apRadius = 8.0; 245 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 246 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 247 248 source->apRadius = 6.0; 249 249 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 250 250 ok_float_tol(refMag - source->apMag, +0.0004, 0.0001, "growth offset is is %f", refMag - source->apMag); 251 251 252 source-> modelPSF->radiusFit= 4.0;252 source->apRadius = 4.0; 253 253 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 254 254 ok_float_tol(refMag - source->apMag, +0.0026, 0.0001, "growth offset is is %f", refMag - source->apMag); 255 255 256 source-> modelPSF->radiusFit= 3.0;256 source->apRadius = 3.0; 257 257 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 258 258 ok_float_tol(refMag - source->apMag, -0.0001, 0.0001, "growth offset is is %f", refMag - source->apMag); 259 259 260 source-> modelPSF->radiusFit= 2.0;260 source->apRadius = 2.0; 261 261 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 262 262 ok_float_tol(refMag - source->apMag, -0.0103, 0.0001, "growth offset is is %f", refMag - source->apMag); … … 336 336 source->mode = PM_SOURCE_MODE_PSFSTAR; 337 337 338 source-> modelPSF->radiusFit= 15.0;338 source->apRadius = 15.0; 339 339 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 340 340 double refMag = source->apMag; 341 341 342 source-> modelPSF->radiusFit= 10.0;343 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 344 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 345 346 source-> modelPSF->radiusFit= 8.0;347 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 348 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 349 350 source-> modelPSF->radiusFit= 6.0;342 source->apRadius = 10.0; 343 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 344 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 345 346 source->apRadius = 8.0; 347 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 348 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 349 350 source->apRadius = 6.0; 351 351 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 352 352 ok_float_tol(refMag - source->apMag, +0.0006, 0.0001, "growth offset is is %f", refMag - source->apMag); 353 353 354 source-> modelPSF->radiusFit= 4.0;354 source->apRadius = 4.0; 355 355 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 356 356 ok_float_tol(refMag - source->apMag, +0.0038, 0.0001, "growth offset is is %f", refMag - source->apMag); 357 357 358 source-> modelPSF->radiusFit= 3.0;359 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 360 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 361 362 source-> modelPSF->radiusFit= 2.0;358 source->apRadius = 3.0; 359 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 360 ok_float_tol(refMag - source->apMag, +0.0000, 0.0001, "growth offset is is %f", refMag - source->apMag); 361 362 source->apRadius = 2.0; 363 363 pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_INTERP, 0); 364 364 ok_float_tol(refMag - source->apMag, -0.0164, 0.0001, "growth offset is is %f", refMag - source->apMag); -
branches/eam_branches/20090715/psModules/test/objects/tap_pmModel.c
r21471 r25496 77 77 ok(model->nDOF == 0, "pmModelAlloc() set pmModel->nDOF correctly"); 78 78 ok(model->nIter == 0, "pmModelAlloc() set pmModel->nIter correctly"); 79 ok(model-> radiusFit == 0, "pmModelAlloc() set pmModel->radiusFitcorrectly");79 ok(model->fitRadius == 0, "pmModelAlloc() set pmModel->fitRadius correctly"); 80 80 ok(model->flags == PM_MODEL_STATUS_NONE, "pmModelAlloc() set pmModel->flags correctly"); 81 81 ok(model->residuals == NULL, "pmModelAlloc() set pmModel->residuals correctly"); … … 132 132 modelSrc->nIter = 3; 133 133 modelSrc->flags = PM_MODEL_STATUS_NONE; 134 modelSrc-> radiusFit= 4;134 modelSrc->fitRadius = 4; 135 135 pmModel *modelDst = pmModelCopy(modelSrc); 136 136 ok(modelDst != NULL && psMemCheckModel(modelDst), "pmModelCopy() returned a non-NULL pmModel"); … … 139 139 ok(modelDst->nIter == 3, "pmModelCopy() set the pmModel->nIter member correctly"); 140 140 ok(modelDst->flags == PM_MODEL_STATUS_NONE, "pmModelCopy() set the pmModel->flags member correctly"); 141 ok(modelDst-> radiusFit == 4, "pmModelCopy() set the pmModel->radiusFitmember correctly");141 ok(modelDst->fitRadius == 4, "pmModelCopy() set the pmModel->fitRadius member correctly"); 142 142 143 143 psFree(modelSrc); -
branches/eam_branches/20090715/psModules/test/objects/tap_pmModelUtils.c
r15985 r25496 81 81 ok(tmpModel->nIter == testModelPSF->nIter, "pmModelFromPSF() set the model->nIter correctly"); 82 82 ok(tmpModel->flags == testModelPSF->flags, "pmModelFromPSF() set the model->flags correctly"); 83 ok(tmpModel-> radiusFit == testModelPSF->radiusFit, "pmModelFromPSF() set the model->radiusFitcorrectly");83 ok(tmpModel->fitRadius == testModelPSF->fitRadius, "pmModelFromPSF() set the model->fitRadius correctly"); 84 84 ok(tmpModel->modelFunc == testModelPSF->modelFunc, "pmModelFromPSF() set the model->modelFunc correctly"); 85 85 ok(tmpModel->modelFlux == testModelPSF->modelFlux, "pmModelFromPSF() set the model->modelFlux correctly"); … … 140 140 ok(tmpModel->nIter == testModelPSF->nIter, "pmModelFromPSF() set the model->nIter correctly"); 141 141 ok(tmpModel->flags == testModelPSF->flags, "pmModelFromPSF() set the model->flags correctly"); 142 ok(tmpModel-> radiusFit == testModelPSF->radiusFit, "pmModelFromPSF() set the model->radiusFitcorrectly");142 ok(tmpModel->fitRadius == testModelPSF->fitRadius, "pmModelFromPSF() set the model->fitRadius correctly"); 143 143 ok(tmpModel->modelFunc == testModelPSF->modelFunc, "pmModelFromPSF() set the model->modelFunc correctly"); 144 144 ok(tmpModel->modelFlux == testModelPSF->modelFlux, "pmModelFromPSF() set the model->modelFlux correctly"); -
branches/eam_branches/20090715/psModules/test/objects/tap_pmSourcePhotometry.c
r9922 r25496 96 96 source->modelPSF = pmModelFromPSF (modelRef, psf); 97 97 source->modelPSF->dparams->data.F32[PM_PAR_I0] = 1; 98 source-> modelPSF->radiusFit= radius;98 source->apRadius = radius; 99 99 100 100 // measure photometry for centered source (fractional pix : 0.5,0.5)
Note:
See TracChangeset
for help on using the changeset viewer.
