Changeset 6056
- Timestamp:
- Jan 19, 2006, 2:55:33 PM (21 years ago)
- Location:
- trunk/psphot
- Files:
-
- 20 edited
-
Makefile (modified) (2 diffs)
-
src/psphot.c (modified) (3 diffs)
-
src/psphot.h (modified) (3 diffs)
-
src/psphotApResid.c (modified) (2 diffs)
-
src/psphotApplyPSF.c (modified) (2 diffs)
-
src/psphotBlendFit.c (modified) (2 diffs)
-
src/psphotDefinePixels.c (modified) (5 diffs)
-
src/psphotEnsemblePSF.c (modified) (2 diffs)
-
src/psphotFindPeaks.c (modified) (2 diffs)
-
src/psphotFitGalaxies.c (modified) (2 diffs)
-
src/psphotFullFit.c (modified) (3 diffs)
-
src/psphotGrowthCurve.c (modified) (3 diffs)
-
src/psphotImageBackground.c (modified) (2 diffs)
-
src/psphotImageStats.c (modified) (1 diff)
-
src/psphotModelTest.c (modified) (2 diffs)
-
src/psphotOutput.c (modified) (13 diffs)
-
src/psphotRadiusChecks.c (modified) (4 diffs)
-
src/psphotSetup.c (modified) (5 diffs)
-
src/psphotSourceFits.c (modified) (11 diffs)
-
src/psphotSourceStats.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/Makefile
r5993 r6056 56 56 $(SRC)/psSparse.$(ARCH).o \ 57 57 $(SRC)/psPolynomialUtils.$(ARCH).o \ 58 $(SRC)/psImageData.$(ARCH).o \59 58 $(SRC)/psModulesUtils.$(ARCH).o \ 60 59 $(SRC)/pmSourceContour.$(ARCH).o \ … … 66 65 $(SRC)/psBicube.$(ARCH).o \ 67 66 $(SRC)/psphotTestArguments.$(ARCH).o 67 68 OLD = \ 69 $(SRC)/psImageData.$(ARCH).o 70 68 71 69 72 psphot: $(BIN)/psphot.$(ARCH) -
trunk/psphot/src/psphot.c
r5993 r6056 5 5 6 6 psMetadata *config = NULL; 7 eamReadout *imdata = NULL; 7 psMetadata *header = NULL; 8 pmReadout *readout = NULL; 8 9 psArray *sources = NULL; 9 10 psArray *peaks = NULL; … … 18 19 19 20 // load input data (config and images (signal, noise, mask) 20 imdata = psphotSetup (config);21 readout = psphotSetup (config, &header); 21 22 22 23 // run a single-model test if desired 23 psphotModelTest ( imdata, config);24 psphotModelTest (readout, config); 24 25 25 26 // measure image stats for initial guess 26 sky = psphotImageStats ( imdata, config);27 sky = psphotImageStats (readout, config); 27 28 28 29 // generate a background model (currently, 2D polynomial) 29 30 // XXX this should be available to be re-added to the original image 30 psphotImageBackground ( imdata, config, sky);31 psphotImageBackground (readout, config, sky); 31 32 32 33 // find the peaks in the image 33 peaks = psphotFindPeaks ( imdata, config, sky);34 peaks = psphotFindPeaks (readout, config, sky); 34 35 35 36 // construct sources and measure basic stats 36 sources = psphotSourceStats ( imdata, config, peaks);37 sources = psphotSourceStats (readout, config, peaks); 37 38 38 39 // classify sources based on moments, brightness … … 49 50 switch (FITMODE) { 50 51 case 0: 51 psphotEnsemblePSF ( imdata, config, sources, psf, sky);52 psphotEnsemblePSF (readout, config, sources, psf, sky); 52 53 break; 53 54 54 55 case 1: 55 psphotEnsemblePSF ( imdata, config, sources, psf, sky);56 psphotFullFit ( imdata, config, sources, psf, sky);56 psphotEnsemblePSF (readout, config, sources, psf, sky); 57 psphotFullFit (readout, config, sources, psf, sky); 57 58 psphotReplaceUnfit (sources); 58 psphotApResid ( imdata, sources, config, psf);59 psphotApResid (readout, sources, config, psf); 59 60 break; 60 61 61 62 case 2: 62 psphotEnsemblePSF ( imdata, config, sources, psf, sky);63 psphotBlendFit ( imdata, config, sources, psf, sky);63 psphotEnsemblePSF (readout, config, sources, psf, sky); 64 psphotBlendFit (readout, config, sources, psf, sky); 64 65 psphotReplaceUnfit (sources); 65 psphotApResid ( imdata, sources, config, psf);66 psphotApResid (readout, sources, config, psf); 66 67 break; 67 68 68 69 case 3: 69 psphotApplyPSF ( imdata, config, sources, psf, sky);70 psphotApplyPSF (readout, config, sources, psf, sky); 70 71 break; 71 72 72 73 case 4: 73 psphotApplyPSF ( imdata, config, sources, psf, sky);74 psphotFitExtended ( imdata, config, sources, sky);74 psphotApplyPSF (readout, config, sources, psf, sky); 75 psphotFitExtended (readout, config, sources, sky); 75 76 break; 76 77 } 77 78 78 79 // write out data in appropriate format 79 psphotOutput ( imdata, config, sources, psf, sky);80 psphotOutput (readout, header, config, sources, psf, sky); 80 81 psLogMsg ("psphot", 3, "wrote output: %f sec\n", psTimerMark ("psphot")); 81 82 psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete")); -
trunk/psphot/src/psphot.h
r5993 r6056 14 14 # define psMemCopy(A)(psMemIncrRefCounter((A))) 15 15 16 typedef struct {17 psImage *image;18 psImage *mask;19 psImage *weight;20 psMetadata *header;21 } eamReadout;22 23 16 // top-level psphot functions 24 17 psMetadata *psphotArguments (int *argc, char **argv); 25 eamReadout *psphotSetup (psMetadata *config);26 bool psphotModelTest ( eamReadout *imdata, psMetadata *config);27 psStats *psphotImageStats ( eamReadout *imdata, psMetadata *config);28 psPolynomial2D *psphotImageBackground ( eamReadout *imdata, psMetadata *config, psStats *sky);29 psArray *psphotFindPeaks ( eamReadout *imdata, psMetadata *config, psStats *sky);30 psArray *psphotSourceStats ( eamReadout *imdata, psMetadata *config, psArray *allpeaks);18 pmReadout *psphotSetup (psMetadata *config, psMetadata **header); 19 bool psphotModelTest (pmReadout *readout, psMetadata *config); 20 psStats *psphotImageStats (pmReadout *readout, psMetadata *config); 21 psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky); 22 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config, psStats *sky); 23 psArray *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *allpeaks); 31 24 bool psphotRoughClass (psArray *sources, psMetadata *config); 32 25 bool psphotBasicDeblend (psArray *sources, psMetadata *config, psStats *sky); 33 26 pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky); 34 void psphotOutput ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);27 void psphotOutput (pmReadout *readout, psMetadata *header, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 35 28 36 29 // optional object analysis steps 37 bool psphotEnsemblePSF ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);38 bool psphotFullFit ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);39 bool psphotBlendFit ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);30 bool psphotEnsemblePSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 31 bool psphotFullFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 32 bool psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 40 33 bool psphotReplaceUnfit (psArray *sources); 41 bool psphotApplyPSF ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);42 bool psphotFitExtended ( eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats);43 bool psphotApResid ( eamReadout *imdata, psArray *sources, psMetadata *config, pmPSF *psf);34 bool psphotApplyPSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 35 bool psphotFitExtended (pmReadout *readout, psMetadata *config, psArray *sources, psStats *skyStats); 36 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf); 44 37 45 38 // basic support functions … … 51 44 int psphotSortBySN (const void **a, const void **b); 52 45 int psphotSortByY (const void **a, const void **b); 53 bool psphotGrowthCurve ( eamReadout *imdata, pmPSF *psf);46 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf); 54 47 void psphotTestArguments (int *argc, char **argv); 55 48 56 49 // functions to set the correct source pixels 57 50 bool psphotInitRadiusPSF (psMetadata *config, psStats *sky, pmModelType type); 58 bool psphotCheckRadiusPSF ( eamReadout *imdata, pmSource *source, pmModel *model);51 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model); 59 52 bool psphotInitRadiusEXT (psMetadata *config, psStats *sky, pmModelType type); 60 bool psphotCheckRadiusEXT ( eamReadout *imdata, pmSource *source, pmModel *model);61 bool psphotDefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);62 bool psphotRedefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);53 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model); 54 bool psphotDefinePixels (pmSource *mySource, const pmReadout *readout, psF32 x, psF32 y, psF32 Radius); 55 bool psphotRedefinePixels (pmSource *mySource, const pmReadout *readout, psF32 x, psF32 y, psF32 Radius); 63 56 64 57 // output functions 65 bool pmSourcesWriteText ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);66 bool pmSourcesWriteOBJ ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);67 bool pmSourcesWriteCMP ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);68 bool pmSourcesWriteCMF ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);69 bool pmSourcesWriteSX ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);58 bool pmSourcesWriteText (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 59 bool pmSourcesWriteOBJ (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 60 bool pmSourcesWriteCMP (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 61 bool pmSourcesWriteCMF (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 62 bool pmSourcesWriteSX (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 70 63 71 64 bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf); … … 96 89 bool psphotInitLimitsPSF (psMetadata *config); 97 90 bool psphotInitLimitsEXT (psMetadata *config, psStats *sky); 98 bool psphotFitBlend (eamReadout *imdata, pmSource *source); 99 bool psphotFitBlob (eamReadout *imdata, pmSource *source, psArray *sources); 100 bool psphotFitPSF (eamReadout *imdata, pmSource *source); 101 pmModel *psphotFitEXT (eamReadout *imdata, pmSource *source); 102 psArray *psphotFitDBL (eamReadout *imdata, pmSource *source); 103 104 // eamReadout functions 105 eamReadout *eamReadoutAlloc (psImage *image, psImage *noise, psImage *mask, psMetadata *header); 91 bool psphotFitBlend (pmReadout *readout, pmSource *source); 92 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources); 93 bool psphotFitPSF (pmReadout *readout, pmSource *source); 94 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source); 95 psArray *psphotFitDBL (pmReadout *readout, pmSource *source); 106 96 107 97 // bicubic interpolation -
trunk/psphot/src/psphotApResid.c
r5993 r6056 2 2 3 3 // measure the aperture residual statistics 4 bool psphotApResid ( eamReadout *imdata, psArray *sources, psMetadata *config, pmPSF *psf) {4 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) { 5 5 6 6 int Npsf; … … 14 14 float REF_RADIUS = psMetadataLookupF32 (&status, config, "PSF_REF_RADIUS"); 15 15 psf->growth = pmGrowthCurveAlloc (3.0, REF_RADIUS, 0.1); 16 psphotGrowthCurve ( imdata, psf);16 psphotGrowthCurve (readout, psf); 17 17 18 18 psVector *mask = psVectorAlloc (300, PS_TYPE_U8); -
trunk/psphot/src/psphotApplyPSF.c
r5993 r6056 2 2 3 3 // fit psf model to all objects 4 bool psphotApplyPSF ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky)4 bool psphotApplyPSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 5 5 { 6 6 float x; … … 34 34 35 35 // sets the model radius (via source->model) and adjusts pixels as needed 36 psphotCheckRadiusPSF ( imdata, source, model);36 psphotCheckRadiusPSF (readout, source, model); 37 37 38 38 x = model->params->data.F32[2]; -
trunk/psphot/src/psphotBlendFit.c
r5993 r6056 2 2 3 3 // XXX I don't like this name 4 bool psphotBlendFit ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {4 bool psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 5 5 6 6 psTimerStart ("psphot"); … … 30 30 psTrace ("psphot.blend", 5, "trying source at %f, %f\n", source->moments->x, source->moments->y); 31 31 32 if (psphotFitBlend ( imdata, source)) continue;33 if (psphotFitBlob ( imdata, source, sources)) continue;32 if (psphotFitBlend (readout, source)) continue; 33 if (psphotFitBlob (readout, source, sources)) continue; 34 34 35 35 psTrace ("psphot.blend", 5, "failed fits\n"); -
trunk/psphot/src/psphotDefinePixels.c
r5993 r6056 2 2 3 3 bool psphotDefinePixels(pmSource *mySource, 4 const eamReadout *imdata,4 const pmReadout *readout, 5 5 psF32 x, 6 6 psF32 y, … … 11 11 // Grab a subimage of the original image of size (2 * outerRadius). 12 12 srcRegion = psRegionForSquare (x, y, Radius); 13 srcRegion = psRegionForImage ( imdata->image, srcRegion);13 srcRegion = psRegionForImage (readout->image, srcRegion); 14 14 15 mySource->pixels = psImageSubset( imdata->image, srcRegion);16 mySource->weight = psImageSubset( imdata->weight, srcRegion);17 mySource->mask = psImageSubset( imdata->mask, srcRegion);15 mySource->pixels = psImageSubset(readout->image, srcRegion); 16 mySource->weight = psImageSubset(readout->weight, srcRegion); 17 mySource->mask = psImageSubset(readout->mask, srcRegion); 18 18 mySource->region = srcRegion; 19 19 … … 22 22 23 23 bool psphotRedefinePixels(pmSource *mySource, 24 const eamReadout *imdata,24 const pmReadout *readout, 25 25 psF32 x, 26 26 psF32 y, … … 34 34 // check to see if new region is completely contained within old region 35 35 newRegion = psRegionForSquare (x, y, Radius); 36 newRegion = psRegionForImage ( imdata->image, newRegion);36 newRegion = psRegionForImage (readout->image, newRegion); 37 37 38 38 extend = false; … … 53 53 psFree (mySource->mask); 54 54 55 mySource->pixels = psImageSubset( imdata->image, newRegion);56 mySource->weight = psImageSubset( imdata->weight, newRegion);57 mySource->mask = psImageSubset( imdata->mask, newRegion);55 mySource->pixels = psImageSubset(readout->image, newRegion); 56 mySource->weight = psImageSubset(readout->weight, newRegion); 57 mySource->mask = psImageSubset(readout->mask, newRegion); 58 58 mySource->region = newRegion; 59 59 } -
trunk/psphot/src/psphotEnsemblePSF.c
r5993 r6056 1 1 # include "psphot.h" 2 2 3 bool psphotEnsemblePSF ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {3 bool psphotEnsemblePSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 4 4 5 5 bool status; … … 103 103 104 104 // if needed, ask for more object pixels 105 psphotRedefinePixels (inSource, imdata, x, y, model->radius);105 psphotRedefinePixels (inSource, readout, x, y, model->radius); 106 106 107 107 // make temporary copies of the image pixels and mask -
trunk/psphot/src/psphotFindPeaks.c
r5986 r6056 1 1 # include "psphot.h" 2 2 3 psArray *psphotFindPeaks ( eamReadout *imdata, psMetadata *config, psStats *sky) {3 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config, psStats *sky) { 4 4 5 5 bool status = false; … … 15 15 NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_NSIGMA"); 16 16 17 psImage *smooth = psImageCopy (NULL, imdata->image, PS_TYPE_F32);17 psImage *smooth = psImageCopy (NULL, readout->image, PS_TYPE_F32); 18 18 psImageSmooth (smooth, SIGMA, NSIGMA); 19 19 psLogMsg ("psphot", 4, "smooth: %f sec\n", psTimerMark ("psphot")); -
trunk/psphot/src/psphotFitGalaxies.c
r5993 r6056 1 1 # include "psphot.h" 2 2 3 bool psphotFitExtended ( eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats)3 bool psphotFitExtended (pmReadout *readout, psMetadata *config, psArray *sources, psStats *skyStats) 4 4 { 5 5 bool status; … … 43 43 44 44 // sets the model radius (via source->model) and adjusts pixels as needed 45 psphotCheckRadiusEXT ( imdata, source, model);45 psphotCheckRadiusEXT (readout, source, model); 46 46 47 47 // fit EXT (not PSF) model (set/unset the pixel mask) -
trunk/psphot/src/psphotFullFit.c
r5993 r6056 1 1 # include "psphot.h" 2 2 3 bool psphotFullFit ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky)3 bool psphotFullFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 4 4 { 5 5 bool status; … … 46 46 source->mode &= ~PM_SOURCE_SUBTRACTED; 47 47 48 psphotCheckRadiusPSF ( imdata, source, modelPSF);48 psphotCheckRadiusPSF (readout, source, modelPSF); 49 49 50 50 x = modelPSF->params->data.F32[2]; … … 95 95 pmModel *modelEXT = source->modelEXT; 96 96 97 psphotCheckRadiusEXT ( imdata, source, modelEXT);97 psphotCheckRadiusEXT (readout, source, modelEXT); 98 98 99 99 x = modelEXT->params->data.F32[2]; -
trunk/psphot/src/psphotGrowthCurve.c
r5986 r6056 5 5 // the 'center' option 6 6 7 bool psphotGrowthCurve ( eamReadout *imdata, pmPSF *psf) {7 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf) { 8 8 9 9 // bool status; … … 16 16 17 17 // use this image region 18 xc = 0.5* imdata->image->numCols;19 yc = 0.5* imdata->image->numRows;18 xc = 0.5*readout->image->numCols; 19 yc = 0.5*readout->image->numRows; 20 20 dx = psf->growth->maxRadius + 1; 21 21 dy = psf->growth->maxRadius + 1; … … 33 33 // generate working image for this source 34 34 psRegion region = {xc - dx, xc + dx, yc - dy, yc + dy}; 35 psImage *view = psImageSubset ( imdata->image, region);35 psImage *view = psImageSubset (readout->image, region); 36 36 psImage *image = psImageCopy (NULL, view, PS_TYPE_F32); 37 37 psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8); -
trunk/psphot/src/psphotImageBackground.c
r5828 r6056 1 1 # include "psphot.h" 2 2 3 psPolynomial2D *psphotImageBackground ( eamReadout *imdata, psMetadata *config, psStats *sky)3 psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky) 4 4 { 5 5 … … 7 7 psTimerStart ("psphot"); 8 8 9 psImage *image = imdata->image;10 psImage *mask = imdata->mask;9 psImage *image = readout->image; 10 psImage *mask = readout->mask; 11 11 12 12 bool status = false; -
trunk/psphot/src/psphotImageStats.c
r5828 r6056 1 1 # include "psphot.h" 2 2 3 psStats *psphotImageStats ( eamReadout *imdata, psMetadata *config)3 psStats *psphotImageStats (pmReadout *readout, psMetadata *config) 4 4 { 5 5 psStats *stats = NULL; 6 6 psStats *sky = NULL; 7 7 8 psImage *image = imdata->image;8 psImage *image = readout->image; 9 9 10 10 // get image stats on a subset of the image (random 1e5 pts) -
trunk/psphot/src/psphotModelTest.c
r5993 r6056 2 2 # include "psEllipse.h" 3 3 4 bool psphotModelTest ( eamReadout *imdata, psMetadata *config) {4 bool psphotModelTest (pmReadout *readout, psMetadata *config) { 5 5 6 6 bool status; … … 75 75 pmSource *source = pmSourceAlloc(); 76 76 source->peak = pmPeakAlloc (xObj, yObj, 0, 0); 77 psphotDefinePixels (source, imdata, xObj, yObj, OUTER);77 psphotDefinePixels (source, readout, xObj, yObj, OUTER); 78 78 79 79 // find the local sky -
trunk/psphot/src/psphotOutput.c
r5993 r6056 2 2 3 3 // output functions: we have several fixed modes (sx, obj, cmp) 4 void psphotOutput ( eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {4 void psphotOutput (pmReadout *readout, psMetadata *header, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 5 5 6 6 bool status; … … 13 13 char *psfFile = psMetadataLookupPtr (&status, config, "PSF_OUTPUT_FILE"); 14 14 15 if (residImage != NULL) psphotSaveImage ( imdata->header, imdata->image, residImage);16 psphotSamplePSFs (config, psf, imdata->image);15 if (residImage != NULL) psphotSaveImage (header, readout->image, residImage); 16 psphotSamplePSFs (config, psf, readout->image); 17 17 18 18 if (psfFile != NULL) { … … 30 30 } 31 31 if (!strcasecmp (outputMode, "OBJ")) { 32 pmSourcesWriteOBJ ( imdata, config, outputFile, sources, psf, sky);32 pmSourcesWriteOBJ (readout, config, outputFile, sources, psf, sky); 33 33 return; 34 34 } 35 35 if (!strcasecmp (outputMode, "SX")) { 36 pmSourcesWriteSX ( imdata, config, outputFile, sources, psf, sky);36 pmSourcesWriteSX (readout, config, outputFile, sources, psf, sky); 37 37 return; 38 38 } 39 39 if (!strcasecmp (outputMode, "CMP")) { 40 pmSourcesWriteCMP ( imdata, config, outputFile, sources, psf, sky);40 pmSourcesWriteCMP (readout, header, config, outputFile, sources, psf, sky); 41 41 return; 42 42 } 43 43 if (!strcasecmp (outputMode, "CMF")) { 44 pmSourcesWriteCMF ( imdata, config, outputFile, sources, psf, sky);44 pmSourcesWriteCMF (readout, header, config, outputFile, sources, psf, sky); 45 45 return; 46 46 } 47 47 if (!strcasecmp (outputMode, "TEXT")) { 48 pmSourcesWriteText ( imdata, config, outputFile, sources, psf, sky);48 pmSourcesWriteText (readout, config, outputFile, sources, psf, sky); 49 49 return; 50 50 } … … 54 54 55 55 // dophot-style output list with fixed line width 56 bool pmSourcesWriteOBJ ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {56 bool pmSourcesWriteOBJ (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 57 57 58 58 int type; … … 106 106 107 107 // elixir-mode / sextractor-style output list with fixed line width 108 bool pmSourcesWriteSX ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {108 bool pmSourcesWriteSX (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 109 109 110 110 pmModel *model; … … 157 157 158 158 // elixir-style pseudo FITS table (header + ascii list) 159 bool pmSourcesWriteCMP ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {159 bool pmSourcesWriteCMP (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 160 160 161 161 int i, type; … … 172 172 173 173 // write necessary information to output header 174 psphotUpdateHeader ( imdata->header, config);175 psMetadataAdd ( imdata->header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n);174 psphotUpdateHeader (header, config); 175 psMetadataAdd (header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n); 176 176 177 177 // create file, write-out header … … 179 179 180 180 // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0 181 mdi = psMetadataLookup ( imdata->header, "NAXIS");181 mdi = psMetadataLookup (header, "NAXIS"); 182 182 mdi->data.S32 = 0; 183 183 mdi->type = PS_DATA_S32; 184 184 185 // psMetadataAdd ( imdata->header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0);186 psFitsWriteHeader ( imdata->header, fits);185 // psMetadataAdd (header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0); 186 psFitsWriteHeader (header, fits); 187 187 psFitsClose (fits); 188 188 … … 232 232 // this format consists of a header derived from the image header 233 233 // followed by a zero-size matrix, followed by the table data 234 bool pmSourcesWriteCMF ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {234 bool pmSourcesWriteCMF (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 235 235 236 236 psArray *table; … … 249 249 250 250 // write necessary information to output header 251 psphotUpdateHeader ( imdata->header, config);251 psphotUpdateHeader (header, config); 252 252 253 253 table = psArrayAlloc (sources->n); … … 286 286 287 287 // write the correct number of sources in the header 288 psMetadataAdd ( imdata->header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", table->n);289 psMetadataAdd ( imdata->header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);288 psMetadataAdd (header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", table->n); 289 psMetadataAdd (header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true); 290 290 291 291 // set NAXIS to 0 (we don't write out the data array) 292 mdi = psMetadataLookup ( imdata->header, "NAXIS");292 mdi = psMetadataLookup (header, "NAXIS"); 293 293 mdi->data.S32 = 0; 294 294 mdi->type = PS_DATA_S32; … … 300 300 // write out the header and table 301 301 psFits *fits = psFitsOpen (filename, "w"); 302 psFitsWriteHeader ( imdata->header, fits);302 psFitsWriteHeader (header, fits); 303 303 psFitsWriteTable (fits, theader, table); 304 304 psFitsClose (fits); … … 309 309 /***** Text Output Methods *****/ 310 310 311 bool pmSourcesWriteText ( eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) {311 bool pmSourcesWriteText (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) { 312 312 313 313 char *name = (char *) psAlloc (strlen(filename) + 10); -
trunk/psphot/src/psphotRadiusChecks.c
r5993 r6056 20 20 } 21 21 22 bool psphotCheckRadiusPSF ( eamReadout *imdata, pmSource *source, pmModel *model) {22 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model) { 23 23 24 24 // set the fit radius based on the object flux limit and the model … … 31 31 } 32 32 33 bool status = psphotRedefinePixels (source, imdata, model->params->data.F32[2], model->params->data.F32[3], model->radius);33 bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius); 34 34 return status; 35 35 } … … 54 54 } 55 55 56 bool psphotCheckRadiusEXT ( eamReadout *imdata, pmSource *source, pmModel *model) {56 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) { 57 57 58 58 // set the fit radius based on the object flux limit and the model … … 61 61 62 62 // redefine the pixels if needed 63 bool status = psphotRedefinePixels (source, imdata, model->params->data.F32[2], model->params->data.F32[3], model->radius);63 bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius); 64 64 return status; 65 65 } -
trunk/psphot/src/psphotSetup.c
r5986 r6056 7 7 // load or construct the weight 8 8 9 eamReadout *psphotSetup (psMetadata *config)9 pmReadout *psphotSetup (psMetadata *config, psMetadata **header) 10 10 { 11 psMetadata * header = NULL;11 psMetadata *myHeader; 12 12 psImage *image = NULL; 13 13 psImage *weight = NULL; … … 23 23 // setup header template, specify COMMENT and HISTORY as MULTI 24 24 // XXX EAM - shouldn't this be part of the basic FITS concept? 25 header = psMetadataAlloc ();26 psMetadataAdd ( header, PS_LIST_HEAD, "COMMENT", PS_DATA_METADATA_MULTI, "folder for comment", NULL);27 psMetadataAdd ( header, PS_LIST_HEAD, "HISTORY", PS_DATA_METADATA_MULTI, "folder for history", NULL);25 myHeader = psMetadataAlloc (); 26 psMetadataAdd (myHeader, PS_LIST_HEAD, "COMMENT", PS_DATA_METADATA_MULTI, "folder for comment", NULL); 27 psMetadataAdd (myHeader, PS_LIST_HEAD, "HISTORY", PS_DATA_METADATA_MULTI, "folder for history", NULL); 28 28 29 29 // read header and image data from INPUT … … 31 31 if (!status) psAbort ("psphot", "input image not specified"); 32 32 psFits *file = psFitsOpen (input, "r"); 33 header = psFitsReadHeader (header, file);33 myHeader = psFitsReadHeader (myHeader, file); 34 34 psImage *tmpimage = psFitsReadImage (NULL, file, region, 0); 35 35 image = psImageCopy (NULL, tmpimage, PS_TYPE_F32); … … 40 40 41 41 // grab these values from the approrpiate location (image header if necessary) 42 float RDNOISE = pmConfigLookupF32 (&status, config, header, "RDNOISE");43 float GAIN = pmConfigLookupF32 (&status, config, header, "GAIN");42 float RDNOISE = pmConfigLookupF32 (&status, config, myHeader, "RDNOISE"); 43 float GAIN = pmConfigLookupF32 (&status, config, myHeader, "GAIN"); 44 44 psMetadataAdd (config, PS_LIST_TAIL, "RDNOISE", PS_DATA_F32 | PS_META_REPLACE, "read noise value used", RDNOISE); 45 45 psMetadataAdd (config, PS_LIST_TAIL, "GAIN", PS_DATA_F32 | PS_META_REPLACE, "gain value used", GAIN); … … 108 108 109 109 // return image data 110 eamReadout *imdata = eamReadoutAlloc(image, weight, mask, header); 111 return (imdata); 110 pmReadout *readout = pmReadoutAlloc(NULL); 111 readout->image = image; 112 readout->weight = weight; 113 readout->mask = mask; 114 115 *header = myHeader; 116 return (readout); 112 117 } -
trunk/psphot/src/psphotSourceFits.c
r5993 r6056 4 4 // given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful 5 5 6 bool psphotFitPSF ( eamReadout *imdata, pmSource *source) {6 bool psphotFitPSF (pmReadout *readout, pmSource *source) { 7 7 8 8 float x, y; … … 12 12 13 13 // extend source radius as needed 14 psphotCheckRadiusPSF ( imdata, source, PSF);14 psphotCheckRadiusPSF (readout, source, PSF); 15 15 16 16 x = PSF->params->data.F32[2]; … … 61 61 } 62 62 63 bool psphotFitBlob ( eamReadout *imdata, pmSource *source, psArray *sources) {63 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources) { 64 64 65 65 bool okEXT, okDBL; … … 79 79 pmSource *tmpSrc = pmSourceAlloc (); 80 80 81 pmModel *EXT = psphotFitEXT ( imdata, source);81 pmModel *EXT = psphotFitEXT (readout, source); 82 82 okEXT = psphotEvalEXT (tmpSrc, EXT); 83 83 chiEXT = EXT->chisq / EXT->nDOF; 84 84 85 psArray *DBL = psphotFitDBL ( imdata, source);85 psArray *DBL = psphotFitDBL (readout, source); 86 86 okDBL = psphotEvalDBL (tmpSrc, DBL->data[0]); 87 87 okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]); … … 129 129 130 130 // fit a double PSF source to an extended blob 131 psArray *psphotFitDBL ( eamReadout *imdata, pmSource *source) {131 psArray *psphotFitDBL (pmReadout *readout, pmSource *source) { 132 132 133 133 float x, y, dx, dy; … … 149 149 // save the PSF model from the Ensemble fit 150 150 PSF = source->modelPSF; 151 psphotCheckRadiusPSF ( imdata, source, PSF);151 psphotCheckRadiusPSF (readout, source, PSF); 152 152 153 153 modelSet = psArrayAlloc (2); … … 176 176 } 177 177 178 pmModel *psphotFitEXT ( eamReadout *imdata, pmSource *source) {178 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) { 179 179 180 180 float x, y; … … 183 183 pmModel *EXT = pmSourceModelGuess (source, modelTypeEXT); 184 184 185 psphotCheckRadiusEXT ( imdata, source, EXT);185 psphotCheckRadiusEXT (readout, source, EXT); 186 186 187 187 x = EXT->params->data.F32[2]; … … 196 196 } 197 197 198 bool psphotFitBlend ( eamReadout *imdata, pmSource *source) {198 bool psphotFitBlend (pmReadout *readout, pmSource *source) { 199 199 200 200 float x, y, dR; … … 202 202 // if this source is not a possible blend, just fit as PSF 203 203 if ((source->blends == NULL) || (source->mode & PM_SOURCE_SATSTAR)) { 204 bool status = psphotFitPSF ( imdata, source);204 bool status = psphotFitPSF (readout, source); 205 205 return status; 206 206 } … … 212 212 213 213 // extend source radius as needed 214 psphotCheckRadiusPSF ( imdata, source, PSF);214 psphotCheckRadiusPSF (readout, source, PSF); 215 215 216 216 x = PSF->params->data.F32[2]; -
trunk/psphot/src/psphotSourceStats.c
r5986 r6056 1 1 # include "psphot.h" 2 2 3 psArray *psphotSourceStats ( eamReadout *imdata, psMetadata *config, psArray *peaks)3 psArray *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *peaks) 4 4 { 5 5 bool status = false; … … 25 25 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 26 26 // XXX EAM : this has 12 leaks (v.5) 27 psphotDefinePixels (source, imdata, source->peak->x, source->peak->y, OUTER);27 psphotDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 28 28 29 29 // measure a local sky value
Note:
See TracChangeset
for help on using the changeset viewer.
