Changeset 9595 for trunk/psphot/src/psphotWeightBias.c
- Timestamp:
- Oct 16, 2006, 4:24:03 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotWeightBias.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotWeightBias.c
r9270 r9595 3 3 // select objects fitted with PSF model 4 4 // re-fit all of them with the non-poisson errors 5 // only allow the normalization to vary 5 // only allow the normalization to vary 6 6 // XXX eventually, we should be able to do this with linear fitting... 7 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 7 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 8 8 9 9 int Nfit = 0; … … 16 16 // source analysis is done in S/N order (brightest first) 17 17 sources = psArraySort (sources, psphotSortBySN); 18 18 19 19 // set fitting method to use non-poisson errors (local sky error) 20 20 pmSourceFitModelInit (15, 0.1, false); 21 21 22 22 // option to limit analysis to a specific region 23 23 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); … … 29 29 30 30 for (int i = 0; i < sources->n; i++) { 31 pmSource *source = sources->data[i];31 pmSource *source = sources->data[i]; 32 32 33 // skip lower-quality objects34 if (source->type != PM_SOURCE_TYPE_STAR) continue; 35 if (source->mode & PM_SOURCE_MODE_POOR) continue;36 if (source->mode & PM_SOURCE_MODE_FAIL) continue;37 if (source->mode & PM_SOURCE_MODE_PAIR) continue;38 if (source->mode & PM_SOURCE_MODE_BLEND) continue;39 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;33 // skip lower-quality objects 34 if (source->type != PM_SOURCE_TYPE_STAR) continue; 35 if (source->mode & PM_SOURCE_MODE_POOR) continue; 36 if (source->mode & PM_SOURCE_MODE_FAIL) continue; 37 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 38 if (source->mode & PM_SOURCE_MODE_BLEND) continue; 39 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 40 40 41 // if model is NULL, we don't have a starting guess42 if (source->modelPSF == NULL) continue;41 // if model is NULL, we don't have a starting guess 42 if (source->modelPSF == NULL) continue; 43 43 44 if (source->moments->x < AnalysisRegion.x0) continue;45 if (source->moments->y < AnalysisRegion.y0) continue;46 if (source->moments->x > AnalysisRegion.x1) continue;47 if (source->moments->y > AnalysisRegion.y1) continue;44 if (source->moments->x < AnalysisRegion.x0) continue; 45 if (source->moments->y < AnalysisRegion.y0) continue; 46 if (source->moments->x > AnalysisRegion.x1) continue; 47 if (source->moments->y > AnalysisRegion.y1) continue; 48 48 49 // replace object in image50 pmModelAdd (source->pixels, source->mask, source->modelPSF, false, false);49 // replace object in image 50 pmModelAdd (source->pixels, source->mask, source->modelPSF, false, false); 51 51 52 // make a temporary model (we don't keep the result of this analysis)53 pmModel *PSF = pmModelCopy (source->modelPSF);52 // make a temporary model (we don't keep the result of this analysis) 53 pmModel *PSF = pmModelCopy (source->modelPSF); 54 54 55 // extend source radius as needed56 psphotCheckRadiusPSF (readout, source, PSF);55 // extend source radius as needed 56 psphotCheckRadiusPSF (readout, source, PSF); 57 57 58 x = PSF->params->data.F32[2];59 y = PSF->params->data.F32[3];58 x = PSF->params->data.F32[2]; 59 y = PSF->params->data.F32[3]; 60 60 61 // fit PSF model (set/unset the pixel mask) 62 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_MASK_MARK); 63 pmSourceFitModel (source, PSF, PM_SOURCE_FIT_NORM); 64 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", NOT_U8(PM_MASK_MARK)); 65 66 // re-subtract PSF for object, leave local sky 67 pmModelSub (source->pixels, source->mask, source->modelPSF, false, false); 61 // fit PSF model (set/unset the pixel mask) 62 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_MASK_MARK); 63 pmSourceFitModel (source, PSF, PM_SOURCE_FIT_NORM); 64 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", PS_NOT_U8(PM_MASK_MARK)); 68 65 69 PARp = source->modelPSF->params->data.F32; 70 PARc = PSF->params->data.F32; 71 fprintf (f, "%7.1f %7.1f %9.2f %9.2f %10.3f\n", PARp[2], PARp[3], PARp[1], PARc[1], source->moments->dSky); 72 Nfit ++; 66 // re-subtract PSF for object, leave local sky 67 pmModelSub (source->pixels, source->mask, source->modelPSF, false, false); 68 69 PARp = source->modelPSF->params->data.F32; 70 PARc = PSF->params->data.F32; 71 fprintf (f, "%7.1f %7.1f %9.2f %9.2f %10.3f\n", PARp[2], PARp[3], PARp[1], PARc[1], source->moments->dSky); 72 Nfit ++; 73 73 } 74 74 fclose (f);
Note:
See TracChangeset
for help on using the changeset viewer.
