Changeset 6862
- Timestamp:
- Apr 14, 2006, 11:58:44 AM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 3 deleted
- 20 edited
-
psphot.c (modified) (1 diff)
-
psphot.h (modified) (4 diffs)
-
psphotApResid.c (modified) (5 diffs)
-
psphotBasicDeblend.c (modified) (3 diffs)
-
psphotBlendFit.c (modified) (2 diffs)
-
psphotChoosePSF.c (modified) (6 diffs)
-
psphotEnsemblePSF.c (modified) (3 diffs)
-
psphotEvalPSF.c (modified) (1 diff)
-
psphotFindPeaks.c (modified) (5 diffs)
-
psphotImageBackground.c (deleted)
-
psphotImageLoop.c (modified) (3 diffs)
-
psphotImageMedian.c (modified) (5 diffs)
-
psphotImageStats.c (deleted)
-
psphotMagnitudes.c (modified) (2 diffs)
-
psphotMaskCell.c (deleted)
-
psphotOutput.c (modified) (2 diffs)
-
psphotParseCamera.c (modified) (1 diff)
-
psphotRadiusChecks.c (modified) (2 diffs)
-
psphotReadout.c (modified) (5 diffs)
-
psphotRoughClass.c (modified) (1 diff)
-
psphotSourceFits.c (modified) (1 diff)
-
psphotSourceStats.c (modified) (3 diffs)
-
psphotWeightBias.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.c
r6851 r6862 1 1 # include "psphot.h" 2 2 3 // XXX need a better structure for handling optional sequences4 3 int main (int argc, char **argv) { 5 4 -
trunk/psphot/src/psphot.h
r6851 r6862 23 23 // psphotReadout functions 24 24 bool psphotImageMedian (pmConfig *config, pmFPAview *view); 25 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config); 26 psArray *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *allpeaks); 27 bool psphotRoughClass (psArray *sources, psMetadata *config); 28 bool psphotBasicDeblend (psArray *sources, psMetadata *config); 29 pmPSF *psphotChoosePSF (psArray *sources, psMetadata *config); 30 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf, bool final); 31 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf); 25 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe); 26 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks); 27 bool psphotRoughClass (psArray *sources, psMetadata *recipe); 28 bool psphotBasicDeblend (psArray *sources, psMetadata *recipe); 29 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe); 30 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf); 31 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 32 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 32 33 bool psphotReplaceUnfit (psArray *sources); 33 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata * config, pmPSF *psf);34 bool psphotMagnitudes (psArray *sources, psMetadata * config, pmPSF *psf);34 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 35 bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf); 35 36 bool psphotSkyReplace (pmConfig *config, pmFPAview *view); 36 37 … … 42 43 void psphotTestArguments (int *argc, char **argv); 43 44 bool psphotMaskReadout (pmReadout *readout, psMetadata *recipe); 44 bool psphotBackgroundNames (psMetadata *arguments);45 // bool psphotBackgroundNames (psMetadata *arguments); 45 46 46 47 // functions to set the correct source pixels 47 bool psphotInitRadiusPSF (psMetadata * config, pmModelType type);48 bool psphotInitRadiusPSF (psMetadata *recipe, pmModelType type); 48 49 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model); 49 50 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR); 50 bool psphotInitRadiusEXT (psMetadata * config, pmModelType type);51 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type); 51 52 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model); 52 53 53 54 // output functions 54 bool psphotDumpMoments (psMetadata * config, psArray *sources);55 psMetadata *psphotDefineHeader (psMetadata * config);56 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata * config, pmPSF *psf);55 bool psphotDumpMoments (psMetadata *recipe, psArray *sources); 56 psMetadata *psphotDefineHeader (psMetadata *recipe); 57 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 57 58 58 59 // PSF / DBL / EXT evaluation functions … … 62 63 63 64 // functions to support the source fitting process 64 bool psphotInitLimitsPSF (psMetadata * config);65 bool psphotInitLimitsEXT (psMetadata * config);65 bool psphotInitLimitsPSF (psMetadata *recipe); 66 bool psphotInitLimitsEXT (psMetadata *recipe); 66 67 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf); 67 68 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf); … … 73 74 bool psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode); 74 75 75 // XXX these can probably be dropped:76 77 # if (0)78 79 pmHDU *pmHDUFromReadout (pmReadout *readout);80 bool psRegionIsNaN (psRegion region);81 bool pmReadoutSetWeights(pmReadout *readout);82 83 // bicubic interpolation84 psPolynomial2D *psImageBicubeFit (psImage *image, int x, int y);85 psPlane psImageBicubeMin (psPolynomial2D *poly);86 87 bool psImageJpegColormap (char *name);88 bool psImageJpeg (psImage *image, char *filename, float zero, float scale);89 90 bool pmSourceFitSet (pmSource *source, psArray *modelSet, const bool PSF);91 psF32 pmModelFitSet (psVector *deriv, const psVector *params, const psVector *x);92 bool pmModelFitSetInit (pmModelType type);93 void pmModelFitSetClear (void);94 95 // optional mode for clip fit?96 psPolynomial4D *psVectorChiClipFitPolynomial4D(97 psPolynomial4D *poly,98 psStats *stats,99 const psVector *mask,100 psMaskType maskValue,101 const psVector *f,102 const psVector *fErr,103 const psVector *x,104 const psVector *y,105 const psVector *z,106 const psVector *t);107 108 # endif109 110 # if (0)111 bool psphotSamplePSFs (pmPSF *psf, psImage *image, char *output);112 int psphotSaveImage (psMetadata *header, psImage *image, char *filename);113 114 bool pmSourcesWriteSX (psArray *sources, char *filename);115 bool pmSourcesWriteOBJ (psArray *sources, char *filename);116 bool pmSourcesWriteCMP (psArray *sources, char *filename, psMetadata *header);117 bool pmSourcesWriteCMF (psArray *sources, char *filename, psMetadata *header);118 bool pmSourcesWriteText (psArray *sources, char *filename);119 bool pmPeaksWriteText (psArray *sources, char *filename);120 121 bool pmModelWritePSFs (psArray *sources, char *filename);122 bool pmModelWriteEXTs (psArray *sources, char *filename);123 bool pmModelWriteNULLs (psArray *sources, char *filename);124 bool pmMomentsWriteText (psArray *sources, char *filename);125 # endif126 127 // XXX deprecate128 129 // char *psphotNameSubstitute (char *input, char *replace, char *key);130 // char *psphotSplitName (psMetadata *header);131 // pmModel *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius);132 // float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj);133 // float pmSourceCrossWeight (pmSource *Mi, pmSource *Mj);134 // psArray *pmSourceContour_EAM (psImage *image, int x, int y, float threshold);135 // psStats *psphotImageStats (pmReadout *readout, psMetadata *config);136 // psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky);137 // void psphotOutput (pmReadout *readout, psMetadata *arguments);138 139 // void psphotOutputPrep (ppFile *file, ppConfig *config);140 // void psphotOutputCleanup (void);141 142 // bool ppImageLoadPixels (ppFile *input, psDB *db, int chipNum, int cellNum);143 -
trunk/psphot/src/psphotApResid.c
r6753 r6862 3 3 4 4 // measure the aperture residual statistics 5 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata * config, pmPSF *psf) {5 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 6 6 7 7 int Npsf; … … 13 13 14 14 // S/N limit to perform full non-linear fits 15 float FIT_SN_LIM = psMetadataLookupF32 (&status, config, "FULL_FIT_SN_LIM");15 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM"); 16 16 17 17 // measure the aperture loss as a function of radius for PSF 18 float REF_RADIUS = psMetadataLookupF32 (&status, config, "PSF_REF_RADIUS");18 float REF_RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_REF_RADIUS"); 19 19 psf->growth = pmGrowthCurveAlloc (3.0, 50.0, REF_RADIUS); 20 20 psphotGrowthCurve (readout, psf); … … 76 76 77 77 // APTREND options : NONE SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL 78 char *ApTrendOption = psMetadataLookupPtr (&status, config, "APTREND");78 char *ApTrendOption = psMetadataLookupPtr (&status, recipe, "APTREND"); 79 79 if (!status) ApTrendOption = DEFAULT_OPTION; 80 80 … … 208 208 psVector *fit = psPolynomial4DEvalVector (psf->ApTrend, xPos, yPos, r2rflux, flux); 209 209 psVector *resid = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) fit); 210 211 # if (1)212 FILE *fout = fopen ("resid.dat", "w");213 for (int i = 0; i < resid->n; i++) {214 fprintf (fout, "%d %f %f %f %f %f %f %f %f %d\n",215 i,216 (float) psVectorGet(xPos, i), (float) psVectorGet(yPos, i), (float) psVectorGet(r2rflux, i), (float) psVectorGet(flux, i),217 (float) psVectorGet(apResid, i), (float) psVectorGet(fit, i), (float) psVectorGet(resid, i), (float) psVectorGet(dMag, i),218 mask->data.U8[i]);219 }220 fclose (fout);221 # endif222 210 223 211 // measure scatter for sources with dMag < 0.01 (S/N = 100) … … 240 228 241 229 // save results for later output 242 psMetadataAdd ( config, PS_LIST_TAIL, "SKYBIAS", PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias", psf->skyBias);243 psMetadataAdd ( config, PS_LIST_TAIL, "SKYSAT", PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias", psf->skySat);244 psMetadataAdd ( config, PS_LIST_TAIL, "APMIFIT", PS_DATA_F32 | PS_META_REPLACE, "aperture residual", psf->ApResid);245 psMetadataAdd ( config, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);246 psMetadataAdd ( config, PS_LIST_TAIL, "APLOSS", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->growth->apLoss);247 psMetadataAdd ( config, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "ap residual scatter", psf->nApResid);230 psMetadataAdd (recipe, PS_LIST_TAIL, "SKYBIAS", PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias", psf->skyBias); 231 psMetadataAdd (recipe, PS_LIST_TAIL, "SKYSAT", PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias", psf->skySat); 232 psMetadataAdd (recipe, PS_LIST_TAIL, "APMIFIT", PS_DATA_F32 | PS_META_REPLACE, "aperture residual", psf->ApResid); 233 psMetadataAdd (recipe, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid); 234 psMetadataAdd (recipe, PS_LIST_TAIL, "APLOSS", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->growth->apLoss); 235 psMetadataAdd (recipe, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "ap residual scatter", psf->nApResid); 248 236 249 237 psLogMsg ("psphot.apresid", 3, "measure full-frame aperture residual: %f sec\n", psTimerMark ("psphot")); -
trunk/psphot/src/psphotBasicDeblend.c
r6715 r6862 2 2 3 3 // 2006.02.07 : no leaks 4 bool psphotBasicDeblend (psArray *sources, psMetadata * config) {4 bool psphotBasicDeblend (psArray *sources, psMetadata *recipe) { 5 5 6 6 int N; … … 13 13 psTimerStart ("psphot"); 14 14 15 float FRACTION = psMetadataLookupF32 (&status, config, "DEBLEND_PEAK_FRACTION");15 float FRACTION = psMetadataLookupF32 (&status, recipe, "DEBLEND_PEAK_FRACTION"); 16 16 if (!status) FRACTION = 0.25; 17 17 18 float NSIGMA = psMetadataLookupF32 (&status, config, "DEBLEND_SKY_NSIGMA");18 float NSIGMA = psMetadataLookupF32 (&status, recipe, "DEBLEND_SKY_NSIGMA"); 19 19 if (!status) NSIGMA = 5.0; 20 20 … … 129 129 psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f sec)\n", Nblend, psTimerMark ("psphot")); 130 130 131 char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");131 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 132 132 if (!strcasecmp (breakPt, "DEBLEND")) exit (0); 133 133 -
trunk/psphot/src/psphotBlendFit.c
r6851 r6862 2 2 3 3 // XXX I don't like this name 4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata * config, pmPSF *psf) {4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 5 5 6 6 int Nfit = 0; … … 13 13 14 14 // S/N limit to perform full non-linear fits 15 float FIT_SN_LIM = psMetadataLookupF32 (&status, config, "FULL_FIT_SN_LIM");15 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM"); 16 16 17 psphotInitLimitsPSF ( config);18 psphotInitLimitsEXT ( config);19 psphotInitRadiusPSF ( config, psf->type);17 psphotInitLimitsPSF (recipe); 18 psphotInitLimitsEXT (recipe); 19 psphotInitRadiusPSF (recipe, psf->type); 20 20 21 21 // option to limit analysis to a specific region 22 char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");22 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 23 23 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 24 24 if (psRegionIsNaN (AnalysisRegion)) psAbort ("psphot", "analysis region mis-defined"); -
trunk/psphot/src/psphotChoosePSF.c
r6851 r6862 1 1 # include "psphot.h" 2 2 3 // 2006.02.07 : no leaks!4 3 // try PSF models and select best option 5 pmPSF *psphotChoosePSF (p sArray *sources, psMetadata *config) {4 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe) { 6 5 7 6 bool status; 8 7 char *modelName; 9 pmPSFtry *try = NULL; 8 pmPSF *psf = NULL; 9 pmPSFtry *try = NULL; 10 10 psArray *stars = NULL; 11 11 … … 13 13 14 14 // check if a PSF model is supplied by the user 15 char *psfFile = psMetadataLookupStr (&status, config, "PSF_INPUT_FILE"); 16 if (status) { 17 int Nfail; 18 psMetadata *psfData = psMetadataConfigParse (NULL, &Nfail, psfFile, FALSE); 19 pmPSF *psf = pmPSFfromMD (psfData); 20 return psf; 21 } 15 psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 16 if (psf != NULL) return psf; 22 17 23 18 // examine PSF sources in S/N order (brightest first) … … 25 20 26 21 // array to store candidate PSF stars 27 int NSTARS = psMetadataLookupS32 (&status, config, "PSF_MAX_NSTARS");22 int NSTARS = psMetadataLookupS32 (&status, recipe, "PSF_MAX_NSTARS"); 28 23 if (!status) NSTARS = PS_MIN (sources->n, 200); 29 24 30 25 // use poissonian errors or local-sky errors 31 bool POISSON_ERRORS = psMetadataLookupBool (&status, config, "POISSON_ERRORS");26 bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS"); 32 27 if (!status) POISSON_ERRORS = true; 33 28 pmSourceFitModelInit (15, 0.1, POISSON_ERRORS); … … 45 40 // get the fixed PSF fit radius 46 41 // XXX EAM : check that PSF_FIT_RADIUS < SKY_OUTER_RADIUS 47 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS");42 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS"); 48 43 49 44 // get the list pointers for the PSF_MODEL entries 50 45 psList *list = NULL; 51 psMetadataItem *mdi = psMetadataLookup ( config, "PSF_MODEL");46 psMetadataItem *mdi = psMetadataLookup (recipe, "PSF_MODEL"); 52 47 if (mdi == NULL) psAbort ("psphotChoosePSF", "missing PSF_MODEL selection"); 53 48 … … 100 95 101 96 // save only the best model; 102 p mPSF *psf = psMemCopy(try->psf);97 psf = psMemCopy(try->psf); 103 98 psFree (models); 104 99 105 psMetadataAdd ( config, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars);100 psMetadataAdd (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars); 106 101 107 102 modelName = pmModelGetType (psf->type); … … 109 104 psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid); 110 105 111 char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");106 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 112 107 if (!strcasecmp (breakPt, "PSFFIT")) exit (0); 113 108 114 109 return (psf); 115 110 } 111 112 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) { 113 114 psEllipseShape shape; 115 psEllipseAxes axes; 116 117 psImage *image = readout->image; 118 119 pmModel *modelEXT = pmModelAlloc (psf->type); 120 121 // make a model with unit central intensity at the image center 122 modelEXT->params->data.F32[0] = 0; 123 modelEXT->params->data.F32[1] = 1; 124 modelEXT->params->data.F32[2] = 0.5*image->numCols; 125 modelEXT->params->data.F32[3] = 0.5*image->numRows; 126 127 // construct a PSF model at this coordinate 128 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); 129 130 // get the correct model-radius function 131 pmModelRadius modelRadiusFunc = pmModelRadius_GetFunction (psf->type); 132 133 // get the model full-width at half-max 134 psF64 FWHM_X = 2*modelRadiusFunc (modelPSF->params, 0.5); 135 136 shape.sx = modelPSF->params->data.F32[4]; 137 shape.sy = modelPSF->params->data.F32[5]; 138 shape.sxy = modelPSF->params->data.F32[6]; 139 axes = psEllipseShapeToAxes (shape); 140 141 psF64 FWHM_Y = FWHM_X * (axes.minor / axes.major); 142 143 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X); 144 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y); 145 psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE", PS_DATA_F32 | PS_META_REPLACE, "PSF angle", axes.theta); 146 147 return true; 148 } -
trunk/psphot/src/psphotEnsemblePSF.c
r6753 r6862 4 4 // 2006.02.07 : no leaks! 5 5 // fit all reasonable sources with the linear PSF model 6 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata * config, pmPSF *psf, bool final) {6 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) { 7 7 8 8 bool status; … … 21 21 // radius for source moments if star is saturated 22 22 // XXX we already do this in psphotSourceStats, is it still needed? 23 float INNER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_INNER_RADIUS");23 float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 24 24 25 25 // setup the PSF fit details 26 psphotInitRadiusPSF ( config, psf->type);26 psphotInitRadiusPSF (recipe, psf->type); 27 27 28 28 // pre-calculate all model pixels … … 33 33 34 34 // option to limit analysis to a specific region 35 char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");35 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 36 36 psRegion AnalysisRegion = psRegionFromString (region); 37 37 AnalysisRegion = psRegionForImage (readout->image, AnalysisRegion); -
trunk/psphot/src/psphotEvalPSF.c
r6851 r6862 31 31 static float PSF_SHAPE_NSIGMA; 32 32 33 bool psphotInitLimitsPSF (psMetadata * config) {33 bool psphotInitLimitsPSF (psMetadata *recipe) { 34 34 35 35 bool status; 36 36 37 37 // we may set this differently here from the value used to mark likely saturated stars 38 SATURATION = psMetadataLookupF32 (&status, config, "SATURATION");39 PSF_MIN_SN = psMetadataLookupF32 (&status, config, "PSF_MIN_SN");40 PSF_MAX_CHI = psMetadataLookupF32 (&status, config, "PSF_MAX_CHI");41 PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_SHAPE_NSIGMA");38 SATURATION = psMetadataLookupF32 (&status, recipe, "SATURATION"); 39 PSF_MIN_SN = psMetadataLookupF32 (&status, recipe, "PSF_MIN_SN"); 40 PSF_MAX_CHI = psMetadataLookupF32 (&status, recipe, "PSF_MAX_CHI"); 41 PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_SHAPE_NSIGMA"); 42 42 43 43 return true; -
trunk/psphot/src/psphotFindPeaks.c
r6495 r6862 2 2 3 3 // 2006.02.02 : no leaks 4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata * config) {4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe) { 5 5 6 6 bool status = false; … … 12 12 psTimerStart ("psphot"); 13 13 14 SIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_SIGMA");15 NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_NSIGMA");14 SIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 15 NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 16 16 17 17 psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32); … … 37 37 38 38 // set peak threshold 39 NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_NSIGMA_LIMIT");39 NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); 40 40 // threshold = NSIGMA*sky->sampleStdev + sky->sampleMean; 41 41 threshold = PS_SQR(NSIGMA); … … 49 49 50 50 // optional dump of all peak data 51 char *output = psMetadataLookupStr (&status, config, "PEAKS_OUTPUT_FILE");51 char *output = psMetadataLookupStr (&status, recipe, "PEAKS_OUTPUT_FILE"); 52 52 if (status && (output != NULL) && (output[0])) { 53 53 pmPeaksWriteText (peaks, output); … … 55 55 psLogMsg ("psphot", 3, "%d peaks: %f sec\n", peaks->n, psTimerMark ("psphot")); 56 56 57 char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");57 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 58 58 if (!strcasecmp (breakPt, "PEAKS")) exit (0); 59 59 -
trunk/psphot/src/psphotImageLoop.c
r6727 r6862 2 2 3 3 // XXX where do we load optional mask and weight input images? 4 5 4 bool psphotImageLoop (pmConfig *config) { 6 5 … … 23 22 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 24 23 psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 25 if (! chip->process) { continue; } 26 if (! chip->file_exists) { continue; } 24 if (! chip->process || ! chip->file_exists) { continue; } 27 25 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 28 26 29 27 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 30 28 psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 31 if (! cell->process) { continue; } 32 if (! cell->file_exists) { continue; } 29 if (! cell->process || ! cell->file_exists) { continue; } 33 30 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 34 31 … … 63 60 // PSPHOT.PSF : sample PSF images 64 61 65 66 /**67 68 filename | pmFPAfile | pmFPA | pmFPAview69 chip00.f | PSPHOT.IN | input | view70 chip01.f | PSPHOT.IN | input | view71 chip02.f | PSPHOT.IN | input | view72 chip03.f | PSPHOT.IN | input | view73 74 out00.f | PSPHOT.OUT | input | view75 out01.f | PSPHOT.OUT | input | view76 out02.f | PSPHOT.OUT | input | view77 out03.f | PSPHOT.OUT | input | view78 79 obj00.f | PSPHOT.OBJ | input | view80 obj01.f | PSPHOT.OBJ | input | view81 obj02.f | PSPHOT.OBJ | input | view82 obj03.f | PSPHOT.OBJ | input | view83 84 bin00.f | PSPHOT.BIN | binned | view85 bin01.f | PSPHOT.BIN | binned | view86 bin02.f | PSPHOT.BIN | binned | view87 bin03.f | PSPHOT.BIN | binned | view88 89 mosaic.f | PSPHOT.MOS | mosaic | view90 91 **/ -
trunk/psphot/src/psphotImageMedian.c
r6851 r6862 33 33 34 34 // scaling factor 35 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN"); 36 if (!status) {DX = 64;} 37 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN"); 38 if (!status) {DY = 64;} 35 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN"); 36 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN"); 39 37 40 38 // overhang : we will balance this evenly … … 69 67 70 68 // XXX the value of the upper and lower cuts probably should be studied... 71 modelData[iy][ix] = psImageClippedStats (subset, submask, 0xff, 0.25, 0.75) + SKY_BIAS; 69 psStats *stats = psImageClippedStats (subset, submask, 0xff, 0.25, 0.75); 70 modelData[iy][ix] = stats->robustMedian + SKY_BIAS; 72 71 72 psFree (stats); 73 73 psFree (subset); 74 74 psFree (submask); … … 82 82 psLogMsg ("psphot", 3, "build median image: %f sec\n", psTimerMark ("psphot")); 83 83 84 // XXX temporarily until we get the pmFPAfile output finished 85 psphotSaveImage (NULL, model->image, "model.fits"); 84 // measure background stats and save for later output 85 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_MIN | PS_STAT_MAX); 86 stats = psImageStats (stats, model->image, NULL, 0); 87 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MEAN", PS_DATA_F32 | PS_META_REPLACE, "sky model mean", stats->sampleMean); 88 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_STDV", PS_DATA_F32 | PS_META_REPLACE, "sky model stdev", stats->sampleStdev); 89 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MAX", PS_DATA_F32 | PS_META_REPLACE, "sky model maximum value", stats->max); 90 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MIN", PS_DATA_F32 | PS_META_REPLACE, "sky model minimum value", stats->min); 91 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_NX", PS_DATA_S32 | PS_META_REPLACE, "sky model size (x)", nx); 92 psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_NY", PS_DATA_S32 | PS_META_REPLACE, "sky model size (y)", ny); 93 psFree (stats); 86 94 87 95 // select background pixels, from output background file, or create … … 89 97 if (background == NULL) { 90 98 background = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32); 91 } else { 92 // replace the supplied image data with an image of the desired size 93 // XXX should not have to do this: it should be allocated correctly 94 // psImageRecycle (background->image, Nx, Ny, PS_TYPE_F32); 95 } 96 99 } 97 100 psF32 **backData = background->image->data.F32; 98 101 … … 100 103 psImageUnbin (background->image, model->image, DX, DY, dx, dy); 101 104 psLogMsg ("psphot", 3, "build resampled image: %f sec\n", psTimerMark ("psphot")); 102 103 // XXX temporarily until we get the pmFPAfile output finished...104 psphotSaveImage (NULL, background->image, "back.fits");105 105 106 106 // back-sub image pixels, from output background file (don't create if not requested) -
trunk/psphot/src/psphotMagnitudes.c
r6753 r6862 1 1 # include "psphot.h" 2 2 3 bool psphotMagnitudes (psArray *sources, psMetadata * config, pmPSF *psf) {3 bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf) { 4 4 5 5 psTimerStart ("psphot"); … … 13 13 return true; 14 14 } 15 16 // XXX add in a measurement of the bright and faint completeness values 17 // XXX push these into the recipe -
trunk/psphot/src/psphotOutput.c
r6727 r6862 1 1 # include "psphot.h" 2 3 int psphotSaveImage (psMetadata *header, psImage *image, char *filename) { 4 5 psFits *fits = psFitsOpen (filename, "w"); 6 psFitsWriteImage (fits, NULL, image, 0, NULL); 7 psFitsClose (fits); 8 return (TRUE); 9 } 10 11 bool psphotDumpMoments (psMetadata *recipe, psArray *sources) { 12 13 bool status; 14 15 // optional dump of all rough source data 16 char *output = psMetadataLookupStr (&status, recipe, "MOMENTS_OUTPUT_FILE"); 17 if (!status) return false; 18 if (output == NULL) return false; 19 if (output[0] == 0) return false; 20 21 pmMomentsWriteText (sources, output); 22 return true; 23 } 24 25 // these values are saved in an output header stub - they are added to either the 26 // PHU header (CMP) or the MEF table header (CMF) 27 psMetadata *psphotDefineHeader (psMetadata *recipe) { 28 29 psMetadata *header = psMetadataAlloc (); 30 31 // write necessary information to output header 32 psMetadataItemTransfer (header, recipe, "ZERO_PT"); 33 psMetadataItemTransfer (header, recipe, "PHOTCODE"); 34 35 psMetadataItemTransfer (header, recipe, "APMIFIT"); 36 psMetadataItemTransfer (header, recipe, "DAPMIFIT"); 37 psMetadataItemTransfer (header, recipe, "NAPMIFIT"); 38 psMetadataItemTransfer (header, recipe, "SKYBIAS"); 39 psMetadataItemTransfer (header, recipe, "SKYSAT"); 40 41 // PSF model parameters (shape values for image center) 42 psMetadataItemTransfer (header, recipe, "NPSFSTAR"); 43 psMetadataItemTransfer (header, recipe, "APLOSS"); 44 psMetadataItemTransfer (header, recipe, "FWHM_X"); 45 psMetadataItemTransfer (header, recipe, "FWHM_Y"); 46 psMetadataItemTransfer (header, recipe, "ANGLE"); 47 48 // XXX these need to be defined from elsewhere 49 psMetadataAdd (header, PS_LIST_TAIL, "FSATUR", PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG", 0.0); 50 psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT", PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG", 0.0); 51 52 // sky background model statistics 53 psMetadataItemTransfer (header, recipe, "SKY_MEAN"); 54 psMetadataItemTransfer (header, recipe, "SKY_STDV"); 55 psMetadataItemTransfer (header, recipe, "SKY_MIN"); 56 psMetadataItemTransfer (header, recipe, "SKY_MAX"); 57 psMetadataItemTransfer (header, recipe, "SKY_NX"); 58 psMetadataItemTransfer (header, recipe, "SKY_NY"); 59 60 return header; 61 } 2 62 3 63 # if (0) … … 66 126 } 67 127 # endif 68 69 int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {70 71 psFits *fits = psFitsOpen (filename, "w");72 psFitsWriteImage (fits, NULL, image, 0, NULL);73 psFitsClose (fits);74 return (TRUE);75 }76 77 bool psphotDumpMoments (psMetadata *config, psArray *sources) {78 79 bool status;80 81 // optional dump of all rough source data82 char *output = psMetadataLookupStr (&status, config, "MOMENTS_OUTPUT_FILE");83 if (!status) return false;84 if (output == NULL) return false;85 if (output[0] == 0) return false;86 87 pmMomentsWriteText (sources, output);88 return true;89 }90 91 // these values are saved in an output header stub - they are added to either the92 // PHU header (CMP) or the MEF table header (CMF)93 psMetadata *psphotDefineHeader (psMetadata *recipe) {94 95 psMetadata *header = psMetadataAlloc ();96 97 // write necessary information to output header98 psMetadataItemTransfer (header, recipe, "ZERO_PT");99 psMetadataItemTransfer (header, recipe, "PHOTCODE");100 101 psMetadataItemTransfer (header, recipe, "APMIFIT");102 psMetadataItemTransfer (header, recipe, "DAPMIFIT");103 psMetadataItemTransfer (header, recipe, "NAPMIFIT");104 psMetadataItemTransfer (header, recipe, "SKYBIAS");105 psMetadataItemTransfer (header, recipe, "SKYSAT");106 107 psMetadataItemTransfer (header, recipe, "NPSFSTAR");108 psMetadataItemTransfer (header, recipe, "APLOSS");109 110 // XXX these need to be defined from elsewhere111 psMetadataAdd (header, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM X", 0.0);112 psMetadataAdd (header, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Y", 0.0);113 psMetadataAdd (header, PS_LIST_TAIL, "ANGLE", PS_DATA_F32 | PS_META_REPLACE, "PSF ANGLE", 0.0);114 psMetadataAdd (header, PS_LIST_TAIL, "FSATUR", PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG", 0.0);115 psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT", PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG", 0.0);116 117 return header;118 } -
trunk/psphot/src/psphotParseCamera.c
r6851 r6862 1 1 # include "psphot.h" 2 2 3 // define the needed / desired I/O files 3 4 bool psphotParseCamera (pmConfig *config) { 4 5 5 bool status ;6 bool status = false; 6 7 7 status = false;8 8 pmFPAfile *input = pmFPAfileFromArgs (&status, config, "PSPHOT.INPUT", "INPUT"); 9 if (!status) { 10 psAbort (__func__, "missing INPUT entry"); 11 } 9 if (!status) { psAbort (__func__, "missing INPUT entry"); } 12 10 13 // recipe override values (command-line options): 11 // select recipe options supplied on command line 12 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT"); 14 13 psMetadata *options = psMetadataLookupPtr (&status, config->arguments, "PSPHOT.OPTIONS"); 15 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT"); 16 psMetadataIterator *iter = psMetadataIteratorAlloc (options, PS_LIST_HEAD, NULL); 17 psMetadataItem *item = NULL; 18 while ((item = psMetadataGetAndIncrement (iter)) != NULL) { 19 psMetadataAddItem (recipe, item, PS_LIST_TAIL, PS_META_REPLACE); 20 } 21 psFree (iter); 14 psMetadataCopy (recipe, options); 15 16 // set default recipe values here 17 psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE"); 18 psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE"); 19 psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE"); 20 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00); 21 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning", 64); 22 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning", 64); 22 23 23 24 // these calls bind the I/O handle to the specified fpa 24 25 pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.OUTPUT"); 25 pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");26 26 27 // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT"); 28 // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT"); 27 // optionally save the residual image 28 if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) { 29 pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID"); 30 } 31 32 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN"); 33 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN"); 29 34 30 35 // these calls construct a new fpa for the I/O handle 31 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN"); 32 if (!status) {DX = 64;} 33 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN"); 34 if (!status) {DY = 64;} 35 pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL"); 36 pmFPAfileFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKGND"); 37 pmFPAfileFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKSUB"); 36 37 // optionally save the background model (small FITS image) 38 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) { 39 pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL"); 40 } 41 // optionally save the full background image 42 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) { 43 pmFPAfileFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKGND"); 44 } 45 // optionally save the background-subtracted image 46 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) { 47 pmFPAfileFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKSUB"); 48 } 49 // optionally save the PSF Model 50 if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) { 51 pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.SAVE"); 52 } 53 // optionally load the PSF Model 54 if (psMetadataLookupBool(NULL, recipe, "LOAD.PSF")) { 55 pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.LOAD"); 56 } 38 57 39 58 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE"); 40 59 41 // psphot is supplied with the output name 42 // this needs to be better: supply to all output (WRITE) files? 60 // supply the output name (from cmd-line) to all output (WRITE) files 43 61 char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT"); 44 62 pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE); 45 63 46 // set default recipe values here 47 psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE"); 48 psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE"); 49 psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE"); 50 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00); 51 52 // Chip selection: if we are using a single chip, select it for each FPA 53 // Chip numbers to work on: -chip 1,2,3,5,8,10 54 # if (0) 55 char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 56 if (chips != NULL) { 57 char *p = chips; 58 while (strlen(p)) { 59 char *q = strchr (p, ','); 60 if (q == NULL) { 61 q = p + strlen(p); 62 } else { 63 *q = 0; 64 q = q + 1; 65 } 66 int chipNum = atoi(p); 67 // XXX EAM : extend this to allow an array of selected chips (by name) 68 if (! pmFPASelectChip(input->fpa, chipNum)) { 64 // Chip selection: turn on only the chips specified 65 char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 66 psArray *chips = psStringSplitArray (chipLine, ","); 67 if (chips->n > 0) { 68 pmFPASelectChip (input->fpa, -1, true); // deselect all chips 69 for (int i = 0; i < chips->n; i++) { 70 int chipNum = atoi(chips->data[i]); 71 if (! pmFPASelectChip(input->fpa, chipNum, false)) { 69 72 psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum); 70 73 exit(EXIT_FAILURE); 71 74 } 72 psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);73 p = q;74 75 } 75 76 } 76 # endif77 77 78 78 psTrace(__func__, 1, "Done with psphotParseCamera...\n"); -
trunk/psphot/src/psphotRadiusChecks.c
r6753 r6862 6 6 static pmModelRadius modelRadiusPSF; 7 7 8 bool psphotInitRadiusPSF (psMetadata * config, pmModelType type) {8 bool psphotInitRadiusPSF (psMetadata *recipe, pmModelType type) { 9 9 10 10 bool status; 11 11 12 PSF_FIT_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_FIT_NSIGMA");13 PSF_FIT_PADDING = psMetadataLookupF32 (&status, config, "PSF_FIT_PADDING");12 PSF_FIT_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_FIT_NSIGMA"); 13 PSF_FIT_PADDING = psMetadataLookupF32 (&status, recipe, "PSF_FIT_PADDING"); 14 14 15 15 // this function specifies the radius at this the model hits the given flux … … 56 56 static pmModelRadius modelRadiusEXT; 57 57 58 bool psphotInitRadiusEXT (psMetadata * config, pmModelType type) {58 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type) { 59 59 60 60 bool status; 61 61 62 EXT_FIT_NSIGMA = psMetadataLookupF32 (&status, config, "EXT_FIT_NSIGMA");63 EXT_FIT_PADDING = psMetadataLookupF32 (&status, config, "EXT_FIT_PADDING");62 EXT_FIT_NSIGMA = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA"); 63 EXT_FIT_PADDING = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING"); 64 64 65 65 // this function specifies the radius at this the model hits the given flux -
trunk/psphot/src/psphotReadout.c
r6851 r6862 1 1 # include "psphot.h" 2 2 3 // XXX 2006.03.28 : no leaks!4 3 bool psphotReadout (pmConfig *config, pmFPAview *view) { 5 4 … … 18 17 // XXX move this input the psphotImageLoop level? 19 18 pmReadoutSetWeights (readout); 20 psphotSaveImage (NULL, readout->weight, "weight.fits");21 19 22 20 // I have a valid mask, now mask in the analysis region of interest … … 44 42 45 43 // use bright stellar objects to measure PSF 46 psf = psphotChoosePSF (sources, recipe); 44 psf = psphotChoosePSF (readout, sources, recipe); 45 psphotPSFstats (readout, recipe, psf); 47 46 48 47 // linear PSF fit to peaks … … 52 51 psphotBlendFit (readout, sources, recipe, psf); 53 52 53 // XXX this was an attempt to measure bias due to the weighting. 54 54 // psphotWeightBias (readout, sources, recipe, psf); 55 55 … … 91 91 return true; 92 92 } 93 94 # if (0)95 fprintf (stderr, "making fake sources\n");96 sources = psphotFakeSources ();97 psMetadata *tmp = psMetadataAlloc ();98 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);99 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA, "header stats", tmp);100 psFree (sources);101 psFree (tmp);102 return true;103 # endif -
trunk/psphot/src/psphotRoughClass.c
r6379 r6862 2 2 3 3 // 2006.02.02 : no leaks 4 bool psphotRoughClass (psArray *sources, psMetadata * config) {4 bool psphotRoughClass (psArray *sources, psMetadata *recipe) { 5 5 6 6 bool status; 7 7 pmPSFClump psfClump; 8 8 9 psfClump = pmSourcePSFClump (sources, config);9 psfClump = pmSourcePSFClump (sources, recipe); 10 10 11 11 // group into STAR, COSMIC, EXTENDED, SATURATED, etc. 12 pmSourceRoughClass (sources, config, psfClump);12 pmSourceRoughClass (sources, recipe, psfClump); 13 13 14 14 // optional printout of source moments only 15 psphotDumpMoments ( config, sources);15 psphotDumpMoments (recipe, sources); 16 16 17 char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");17 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 18 18 if (!strcasecmp (breakPt, "CLASS")) exit (0); 19 19 -
trunk/psphot/src/psphotSourceFits.c
r6851 r6862 50 50 static pmModelType modelTypeEXT; 51 51 52 bool psphotInitLimitsEXT (psMetadata * config) {52 bool psphotInitLimitsEXT (psMetadata *recipe) { 53 53 54 54 bool status; 55 55 56 56 // extended source model parameters 57 EXT_MIN_SN = psMetadataLookupF32 (&status, config, "EXT_MIN_SN");58 EXT_MOMENTS_RAD = psMetadataLookupF32 (&status, config, "EXT_MOMENTS_RADIUS");57 EXT_MIN_SN = psMetadataLookupF32 (&status, recipe, "EXT_MIN_SN"); 58 EXT_MOMENTS_RAD = psMetadataLookupF32 (&status, recipe, "EXT_MOMENTS_RADIUS"); 59 59 60 60 // extended source model descriptions 61 char *modelNameEXT = psMetadataLookupStr (&status, config, "EXT_MODEL");61 char *modelNameEXT = psMetadataLookupStr (&status, recipe, "EXT_MODEL"); 62 62 modelTypeEXT = pmModelSetType (modelNameEXT); 63 psphotInitRadiusEXT ( config, modelTypeEXT);63 psphotInitRadiusEXT (recipe, modelTypeEXT); 64 64 65 65 return true; -
trunk/psphot/src/psphotSourceStats.c
r6715 r6862 2 2 3 3 // 2006.02.02 : no leaks 4 psArray *psphotSourceStats (pmReadout *readout, psMetadata * config, psArray *peaks)4 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks) 5 5 { 6 6 bool status = false; … … 11 11 12 12 // determine properties (sky, moments) of initial sources 13 float INNER = psMetadataLookupF32 (&status, config, "SKY_INNER_RADIUS");14 float OUTER = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS");15 float RADIUS = psMetadataLookupF32 (&status, config, "PSF_MOMENTS_RADIUS");13 float INNER = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 14 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 15 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS"); 16 16 17 17 sources = psArrayAlloc (peaks->n); … … 72 72 psLogMsg ("psphot", 3, "%d moments: %f sec\n", sources->n, psTimerMark ("psphot")); 73 73 74 char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");74 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 75 75 if (!strcasecmp (breakPt, "STATS")) exit (0); 76 76 -
trunk/psphot/src/psphotWeightBias.c
r6851 r6862 5 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 * config, pmPSF *psf) {7 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 8 8 9 9 int Nfit = 0; … … 21 21 22 22 // option to limit analysis to a specific region 23 char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");23 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 24 24 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 25 25 if (psRegionIsNaN (AnalysisRegion)) psAbort ("psphot", "analysis region mis-defined");
Note:
See TracChangeset
for help on using the changeset viewer.
