Changeset 9882
- Timestamp:
- Nov 6, 2006, 11:09:14 PM (20 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSF.c
r9808 r9882 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-1 0-31 19:38:04$8 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-11-07 09:08:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 154 154 } 155 155 156 157 158 /*****************************************************************************159 pmPSFFromModels (*psf, *models, *mask): build a PSF from a collection of160 free-fitted models. The PSF ignores the first 4 (independent) model161 parameters and constructs a polynomial fit to the remaining as a function of162 image coordinate.163 input: an array of pmModels, pre-allocated psf164 Note: some of the array entries may be NULL (failed fits); ignore them.165 *****************************************************************************/166 bool pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask)167 {168 169 // construct the fit vectors from the collection of objects170 // use the mask to ignore missing fits171 psVector *x = psVectorAlloc (models->n, PS_TYPE_F64);172 psVector *y = psVectorAlloc (models->n, PS_TYPE_F64);173 psVector *z = psVectorAlloc (models->n, PS_TYPE_F64);174 psVector *dz = psVectorAlloc (models->n, PS_TYPE_F64);175 176 // construct the x,y terms177 for (int i = 0; i < models->n; i++) {178 pmModel *model = models->data[i];179 if (model == NULL)180 continue;181 182 // use F64 for polynomial fitting183 x->data.F64[i] = model->params->data.F32[PM_PAR_XPOS];184 y->data.F64[i] = model->params->data.F32[PM_PAR_YPOS];185 }186 187 // we are doing a robust fit. after each pass, we drop points which are188 // more deviant than three sigma.189 // mask is currently updated for each pass. this is inconsistent?190 191 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);192 193 // skip the unfitted parameters (X, Y, Io, Sky)194 for (int i = 0; i < psf->params_NEW->n; i++) {195 if (i == PM_PAR_SKY)196 continue;197 if (i == PM_PAR_I0)198 continue;199 if (i == PM_PAR_XPOS)200 continue;201 if (i == PM_PAR_YPOS)202 continue;203 204 // select the per-object fitted data for this parameter205 for (int j = 0; j < models->n; j++) {206 pmModel *model = models->data[j];207 if (model == NULL)208 continue;209 z->data.F64[j] = model->params->data.F32[i];210 dz->data.F64[j] = 1; // use the model-fitted error? or S/N?211 212 // for SXY, we actually fit SXY / (SXX^-2 + SYY^-2)213 if (i == PM_PAR_SXY) {214 z->data.F64[j] = pmPSF_SXYfromModel (model->params->data.F32);215 }216 }217 psf->params_NEW->data[i] = psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, mask, 0xff, z, dz, x, y);218 // psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF param %d)\n", Nkeep, mask->n, i);219 220 // XXX Test output221 # if (0)222 223 psPolynomial2D *poly = psf->params_NEW->data[i];224 fprintf (stderr, "stats: %f +/- %f\n", stats->robustMedian, stats->robustStdev);225 fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][0], poly->coeff[1][0], poly->coeff[0][1]);226 fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][2], poly->coeff[1][1], poly->coeff[2][0]);227 fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][0], poly->coeff[1][0], poly->coeff[0][1]);228 fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][2], poly->coeff[1][1], poly->coeff[2][0]);229 # endif230 231 }232 233 // XXX test dump of star parameters vs position (compare with fitted values)234 if (0) {235 FILE *f = fopen ("params.dat", "w");236 237 for (int j = 0; j < models->n; j++) {238 pmModel *model = models->data[j];239 if (model == NULL)240 continue;241 242 pmModel *modelPSF = pmModelFromPSF (model, psf);243 244 fprintf (f, "%f %f : ", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);245 246 for (int i = 0; i < psf->params_NEW->n; i++) {247 if (psf->params_NEW->data[i] == NULL)248 continue;249 fprintf (f, "%f %f : ", model->params->data.F32[i], modelPSF->params->data.F32[i]);250 }251 fprintf (f, "%f %d\n", model->chisq, model->nIter);252 }253 fclose (f);254 }255 256 psFree (stats);257 psFree (x);258 psFree (y);259 psFree (z);260 psFree (dz);261 return (true);262 }263 264 156 /***************************************************************************** 265 157 pmModelFromPSF (*modelEXT, *psf): use the model position parameters to … … 331 223 double SXY = fit * PS_SQR(1.0 / PS_SQR(SXX) + 1.0 / PS_SQR(SYY)); 332 224 return SXY; 225 } 226 227 // generate a psf model of the requested type, with fixed shape 228 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...) 229 { 230 231 va_list ap; 232 va_start(ap, sxy); 233 234 pmModelType type = pmModelSetType (typeName); 235 psPolynomial2D *psfTrend = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 0, 0); 236 pmPSF *psf = pmPSFAlloc (type, true, psfTrend); 237 238 // set the psf shape parameters 239 psPolynomial2D *poly = psf->params_NEW->data[PM_PAR_SXX]; 240 poly->coeff[0][0] = M_SQRT2*sxx; 241 242 poly = psf->params_NEW->data[PM_PAR_SYY]; 243 poly->coeff[0][0] = M_SQRT2*syy; 244 245 poly = psf->params_NEW->data[PM_PAR_SXY]; 246 poly->coeff[0][0] = sxy; 247 248 for (int i = PM_PAR_SXY + 1; i < psf->params_NEW->n; i++) { 249 poly = psf->params_NEW->data[i]; 250 poly->coeff[0][0] = (psF32)va_arg(ap, psF64); 251 } 252 va_end(ap); 253 254 return psf; 333 255 } 334 256 -
trunk/psModules/src/objects/pmPSF.h
r9779 r9882 72 72 ); 73 73 74 75 /**76 *77 * This function takes a collection of pmModel fitted models from across a78 * single image and builds a pmPSF representation of the PSF. The input array of79 * model fits may consist of entries to be ignored (noted by a non-zero mask80 * entry). The analysis of the models fits a 2D polynomial for each parameter to81 * the collection of model parameters as a function of position (and82 * normalization?). In this process, some of the input models may be marked as83 * outliers and excluded from the fit. These elements will be marked with a84 * specific mask value (1 == PSFTRY_MASK_OUTLIER).85 *86 */87 bool pmPSFFromModels(88 pmPSF *psf, ///< Add comment89 psArray *models, ///< Add comment90 psVector *mask ///< Add comment91 );92 93 94 74 /** 95 75 *
Note:
See TracChangeset
for help on using the changeset viewer.
