Changeset 6753
- Timestamp:
- Mar 31, 2006, 4:58:31 PM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 10 edited
-
psphot.h (modified) (1 diff)
-
psphotApResid.c (modified) (5 diffs)
-
psphotBlendFit.c (modified) (1 diff)
-
psphotEnsemblePSF.c (modified) (2 diffs)
-
psphotGrowthCurve.c (modified) (1 diff)
-
psphotImageMedian.c (modified) (1 diff)
-
psphotMagnitudes.c (modified) (2 diffs)
-
psphotRadiusChecks.c (modified) (4 diffs)
-
psphotReadout.c (modified) (2 diffs)
-
psphotSourceFits.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.h
r6727 r6753 4 4 # include <pslib.h> 5 5 # include <psmodules.h> 6 7 # if (0)8 # include <psLine.h>9 # include <psSparse.h>10 # include <psEllipse.h>11 # include <psAdditionals.h>12 # include <pmConfig.h>13 # include <pmHDU.h>14 # include <pmHDUUtils.h>15 # include <pmFPA.h>16 # include <pmFPAview.h>17 # include <pmFPAfile.h>18 # include <pmFPARead.h>19 # include <pmFPAConstruct.h>20 # include <pmMaskBadPixels.h>21 # include <pmConcepts.h>22 23 # include <pmPeaks.h>24 # include <pmMoments.h>25 # include <pmModel.h>26 # include <pmSource.h>27 # include <pmSourceIO.h>28 # include <pmSourceSky.h>29 # include <pmSourceFitModel.h>30 # include <pmSourceFitSet.h>31 # include <pmSourceContour.h>32 # include <pmGrowthCurve.h>33 # include <pmPSF.h>34 # include <pmPSFtry.h>35 # include <pmModelGroup.h>36 # include <pmSourcePhotometry.h>37 # endif38 6 39 7 # define PSPHOT_RECIPE "PSPHOT" -
trunk/psphot/src/psphotApResid.c
r6715 r6753 17 17 // measure the aperture loss as a function of radius for PSF 18 18 float REF_RADIUS = psMetadataLookupF32 (&status, config, "PSF_REF_RADIUS"); 19 psf->growth = pmGrowthCurveAlloc (3.0, REF_RADIUS, 0.1);19 psf->growth = pmGrowthCurveAlloc (3.0, 50.0, REF_RADIUS); 20 20 psphotGrowthCurve (readout, psf); 21 21 … … 43 43 if (source->moments->SN < 2*FIT_SN_LIM) continue; 44 44 45 // get uncorrected magnitudes in scaled apertures46 model = pmSourceMagnitudes (source, NULL, 0);45 // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures 46 model = pmSourceMagnitudes (source, psf, true, false); 47 47 if (model == NULL) continue; 48 48 49 apResid->data.F64[Npsf] = source->apMag - source->psfMag; 50 51 xPos->data.F64[Npsf] = model->params->data.F32[2]; 52 yPos->data.F64[Npsf] = model->params->data.F32[3]; 53 54 flux->data.F64[Npsf] = pow(10.0, -0.4*source->psfMag); 55 r2rflux->data.F64[Npsf] = PS_SQR(model->radiusTMP) / flux->data.F64[Npsf]; 56 49 57 mask->data.U8[Npsf] = 0; 50 xPos->data.F64[Npsf] = model->params->data.F32[2];51 yPos->data.F64[Npsf] = model->params->data.F32[3];52 53 flux->data.F64[Npsf] = pow(10.0, -0.4*source->psfMag);54 r2rflux->data.F64[Npsf] = PS_SQR(model->radius) / flux->data.F64[Npsf];55 56 apResid->data.F64[Npsf] = source->apMag + pmGrowthCurveCorrect (psf->growth, model->radius) - source->psfMag;57 58 58 59 // XXX sanity clip? … … 83 84 stats->max = 3.0; 84 85 86 // no correction 87 if (!strcasecmp (ApTrendOption, "NONE")) { 88 // remove ApTrend fit from pmPSFtry 89 psf->ApTrend->coeff[0][0][0][0] = 0; 90 } 91 85 92 // constant only 86 93 if (!strcasecmp (ApTrendOption, "CONSTANT")) { … … 202 209 psVector *resid = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) fit); 203 210 204 # if ( 0)211 # if (1) 205 212 FILE *fout = fopen ("resid.dat", "w"); 206 213 for (int i = 0; i < resid->n; i++) { … … 241 248 242 249 psLogMsg ("psphot.apresid", 3, "measure full-frame aperture residual: %f sec\n", psTimerMark ("psphot")); 243 psLogMsg ("psphot.apresid", 4, "aperture residual: %f +/- %f : %f bias \n", psf->ApResid, psf->dApResid, psf->skyBias);250 psLogMsg ("psphot.apresid", 4, "aperture residual: %f +/- %f : %f bias, %f skysat\n", psf->ApResid, psf->dApResid, psf->skyBias, psf->skySat); 244 251 psLogMsg ("psphot.apresid", 4, "apresid trends: %f %f %f %f %f\n", 245 252 1e3*psf->ApTrend->coeff[1][0][0][0], -
trunk/psphot/src/psphotBlendFit.c
r6715 r6753 31 31 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 32 32 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 33 34 // skip DBL second sources (ie, added by psphotFitBlob) 35 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 33 36 34 37 // limit selection to some SN limit -
trunk/psphot/src/psphotEnsemblePSF.c
r6715 r6753 118 118 // fill in the model pixel values 119 119 psImageInit (flux, 0.0); 120 psImageKeepCircle (mask, x, y, model->radius , "OR", PM_SOURCE_MASK_MARKED);120 psImageKeepCircle (mask, x, y, model->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 121 121 pmModelAdd (flux, mask, model, false, false); 122 122 … … 209 209 y = model->params->data.F32[3]; 210 210 211 psImageKeepCircle (Fi->mask, x, y, model->radius , "OR", PM_SOURCE_MASK_MARKED);211 psImageKeepCircle (Fi->mask, x, y, model->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 212 212 pmSourceChisq (model, Fi->pixels, Fi->mask, Fi->weight); 213 psImageKeepCircle (Fi->mask, x, y, model->radius , "AND", ~PM_SOURCE_MASK_MARKED);213 psImageKeepCircle (Fi->mask, x, y, model->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED); 214 214 } 215 215 -
trunk/psphot/src/psphotGrowthCurve.c
r6715 r6753 52 52 53 53 psImageKeepCircle (mask, xc, yc, radius, "AND", ~PM_SOURCE_MASK_MARKED); 54 55 54 psf->growth->apMag->data.F32[i] = apMag; 56 55 } -
trunk/psphot/src/psphotImageMedian.c
r6715 r6753 211 211 psLogMsg ("psphot", 3, "build resampled image: %f sec\n", psTimerMark ("psphot")); 212 212 213 psphotSaveImage (NULL, background, "back.fits"); 214 213 215 // back-sub image pixels, from output background file (don't create if not requested) 214 216 psImage *backSub = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKSUB", 0, 0, PS_TYPE_F32); -
trunk/psphot/src/psphotMagnitudes.c
r6715 r6753 3 3 bool psphotMagnitudes (psArray *sources, psMetadata *config, pmPSF *psf) { 4 4 5 bool status;6 7 5 psTimerStart ("psphot"); 8 6 9 float RADIUS = psMetadataLookupF32 (&status, config, "AP_RADIUS");10 7 for (int i = 0; i < sources->n; i++) { 11 8 pmSource *source = (pmSource *) sources->data[i]; 12 pmSourceMagnitudes (source, psf, RADIUS);9 pmSourceMagnitudes (source, psf, true, true); 13 10 } 14 11 … … 16 13 return true; 17 14 } 18 19 // XXX should this function use RADIUS or should it -
trunk/psphot/src/psphotRadiusChecks.c
r6715 r6753 1 1 # include "psphot.h" 2 # define RADIUS_TYPE float 2 3 3 4 static float PSF_FIT_NSIGMA; … … 23 24 24 25 // set the fit radius based on the object flux limit and the model 25 model->radius = modelRadiusPSF (model->params, PSF_FIT_NSIGMA*moments->dSky) + PSF_FIT_PADDING;26 if (isnan(model->radius )) psAbort ("apply_psf_model", "error in radius");26 model->radiusTMP = (RADIUS_TYPE) (modelRadiusPSF (model->params, PSF_FIT_NSIGMA*moments->dSky) + PSF_FIT_PADDING); 27 if (isnan(model->radiusTMP)) psAbort ("apply_psf_model", "error in radius"); 27 28 28 if (source->mode & PM_SOURCE_MODE_SATSTAR) {29 model->radius *= 2;29 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 30 model->radiusTMP *= 2; 30 31 } 31 32 32 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius );33 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusTMP); 33 34 return status; 34 35 } … … 40 41 41 42 // set the fit radius based on the object flux limit and the model 42 model->radius = modelRadiusPSF (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING;43 if (isnan(model->radius )) psAbort ("apply_psf_model", "error in radius");43 model->radiusTMP = (RADIUS_TYPE) (modelRadiusPSF (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING); 44 if (isnan(model->radiusTMP)) psAbort ("apply_psf_model", "error in radius"); 44 45 45 46 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 46 model->radius *= 2;47 model->radiusTMP *= 2; 47 48 } 48 49 49 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius );50 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusTMP); 50 51 return status; 51 52 } … … 73 74 74 75 // set the fit radius based on the object flux limit and the model 75 model->radius = modelRadiusEXT (model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING;76 if (isnan(model->radius )) psAbort (__func__, "error in radius");76 model->radiusTMP = (RADIUS_TYPE) (modelRadiusEXT (model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING); 77 if (isnan(model->radiusTMP)) psAbort (__func__, "error in radius"); 77 78 78 79 // redefine the pixels if needed 79 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius );80 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusTMP); 80 81 return status; 81 82 } -
trunk/psphot/src/psphotReadout.c
r6727 r6753 56 56 57 57 // linear PSF fit to remaining peaks 58 psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);58 // psphotEnsemblePSF (readout, sources, recipe, psf, TRUE); 59 59 60 60 // measure aperture photometry corrections … … 83 83 } 84 84 85 # if (1)86 fprintf (stderr, "making fake sources\n");87 sources = psphotFakeSources ();88 psMetadata *tmp = psMetadataAlloc ();89 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);90 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA, "header stats", tmp);91 psFree (sources);92 psFree (tmp);93 return true;94 # endif85 # if (0) 86 fprintf (stderr, "making fake sources\n"); 87 sources = psphotFakeSources (); 88 psMetadata *tmp = psMetadataAlloc (); 89 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources); 90 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA, "header stats", tmp); 91 psFree (sources); 92 psFree (tmp); 93 return true; 94 # endif -
trunk/psphot/src/psphotSourceFits.c
r6715 r6753 17 17 18 18 // fit PSF model (set/unset the pixel mask) 19 psImageKeepCircle (source->mask, x, y, PSF->radius , "OR", PM_SOURCE_MASK_MARKED);19 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 20 20 pmSourceFitModel (source, PSF, true); 21 psImageKeepCircle (source->mask, x, y, PSF->radius , "AND", ~PM_SOURCE_MASK_MARKED);21 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED); 22 22 23 23 // does the PSF model succeed? … … 189 189 190 190 // fit EXT (not PSF) model (set/unset the pixel mask) 191 psImageKeepCircle (source->mask, x, y, PSF->radius , "OR", PM_SOURCE_MASK_MARKED);191 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 192 192 pmSourceFitSet (source, modelSet, true); 193 psImageKeepCircle (source->mask, x, y, PSF->radius , "AND", ~PM_SOURCE_MASK_MARKED);193 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED); 194 194 195 195 return (modelSet); … … 209 209 210 210 // fit EXT (not PSF) model (set/unset the pixel mask) 211 psImageKeepCircle (source->mask, x, y, EXT->radius , "OR", PM_SOURCE_MASK_MARKED);211 psImageKeepCircle (source->mask, x, y, EXT->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 212 212 pmSourceFitModel (source, EXT, false); 213 psImageKeepCircle (source->mask, x, y, EXT->radius , "AND", ~PM_SOURCE_MASK_MARKED);213 psImageKeepCircle (source->mask, x, y, EXT->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED); 214 214 215 215 return (EXT); … … 272 272 273 273 // fit PSF model (set/unset the pixel mask) 274 psImageKeepCircle (source->mask, x, y, PSF->radius , "OR", PM_SOURCE_MASK_MARKED);274 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_SOURCE_MASK_MARKED); 275 275 pmSourceFitSet (source, modelSet, true); 276 psImageKeepCircle (source->mask, x, y, PSF->radius , "AND", ~PM_SOURCE_MASK_MARKED);276 psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", ~PM_SOURCE_MASK_MARKED); 277 277 278 278 // evaluate the blend objects, subtract if good, free otherwise
Note:
See TracChangeset
for help on using the changeset viewer.
