Changeset 12665
- Timestamp:
- Mar 28, 2007, 5:20:02 PM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 1 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotChoosePSF.c (modified) (1 diff)
-
psphotMosaicSubimage.c (added)
-
psphotRadialPlot.c (modified) (2 diffs)
-
psphotReadout.c (modified) (2 diffs)
-
psphotReplaceUnfit.c (modified) (1 diff)
-
psphotSourcePlots.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r12633 r12665 49 49 psphotMergeSources.c \ 50 50 psphotReadoutCleanup.c \ 51 psphotSourcePlots.c \ 52 psphotRadialPlot.c \ 53 psphotMosaicSubimage.c \ 51 54 psphotAddNoise.c \ 52 55 psphotCleanup.c 53 56 54 # psphotSourcePlots.c55 # psphotRadialPlot.c56 57 57 58 include_HEADERS = \ -
trunk/psphot/src/psphot.h
r12627 r12665 104 104 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources); 105 105 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add); 106 bool psphotRadialPlot ( constchar *filename, pmSource *source);106 bool psphotRadialPlot (int *kapa, char *filename, pmSource *source); 107 107 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe); 108 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY); 109 110 bool psphotAddWithTest (pmSource *source, bool useState); 111 bool psphotSubWithTest (pmSource *source, bool useState); 112 bool psphotSetState (pmSource *source, bool curState); -
trunk/psphot/src/psphotChoosePSF.c
r11702 r12665 74 74 75 75 // select the candidate PSF stars (pointers to original sources) 76 for (int i = 0; (i < sources->n) && (stars->n < NSTARS); i++) {76 for (int i = 0; i < sources->n; i++) { 77 77 pmSource *source = sources->data[i]; 78 if (source->mode & PM_SOURCE_MODE_PSFSTAR) psArrayAdd (stars, 200, source); 78 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 79 // keep NSTARS PSF stars, unmark the rest 80 if (stars->n < NSTARS) { 81 psArrayAdd (stars, 200, source); 82 } else { 83 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 84 } 85 } 79 86 } 80 87 psLogMsg ("psphot.pspsf", PS_LOG_DETAIL, "selected candidate %ld PSF objects\n", stars->n); -
trunk/psphot/src/psphotRadialPlot.c
r12627 r12665 6 6 # include <kapa.h> 7 7 8 bool psphotRadialPlot (const char *filename, pmSource *source) { 8 static int nCount = 0; 9 10 bool psphotRadialPlot (int *kapa, char *filename, pmSource *source) { 11 12 Graphdata graphdata; 13 14 // only plot 50 stars for now... 15 if (nCount > 00) { 16 if (*kapa != 0) { 17 KiiClose (*kapa); 18 *kapa = 0; 19 } 20 return true; 21 } 9 22 10 23 // XXX get the 'showWindow' option from the recipes somewhere 11 int kapa = pmKapaOpen (false); 12 if (kapa == -1) { 24 // XXX 'showWindow = false' is broken 25 if (*kapa == 0) { 26 *kapa = pmKapaOpen (true); 27 KapaResize (*kapa, 500, 500); 28 unlink (filename); 29 } 30 if (*kapa == -1) { 13 31 psError(PSPHOT_ERR_UNKNOWN, true, "failure to open kapa"); 14 32 return false; 15 33 } 16 34 17 KapaResize (kapa, 500, 500);18 35 KapaInitGraph (&graphdata); 36 KapaClear(*kapa, true); 19 37 20 38 // examine sources to set data range 21 graphdata.xmin = -0.05; 39 graphdata.xmin = -0.05; 40 graphdata.xmax = +30.05; 22 41 graphdata.ymin = -0.05; 23 graphdata.xmax = +2.05; 24 graphdata.ymax = +2.05; 25 KapaSetLimits (kapa, &graphdata); 42 graphdata.ymax = +5.05; 43 KapaSetLimits (*kapa, &graphdata); 26 44 27 KapaSetFont ( kapa, "helvetica", 14);28 KapaBox ( kapa, &graphdata);29 KapaSendLabel ( kapa, "&ss&h_x|(pixels)", KAPA_LABEL_XM);30 KapaSendLabel ( kapa, "&ss&h_y| (pixels)", KAPA_LABEL_YM);45 KapaSetFont (*kapa, "helvetica", 14); 46 KapaBox (*kapa, &graphdata); 47 KapaSendLabel (*kapa, "radius (pixels)", KAPA_LABEL_XM); 48 KapaSendLabel (*kapa, "log flux (counts)", KAPA_LABEL_YM); 31 49 32 50 int nPts = source->pixels->numRows * source->pixels->numCols; 33 psVector *r adius= psVectorAllocEmpty (nPts, PS_TYPE_F32);34 psVector * lflux= psVectorAllocEmpty (nPts, PS_TYPE_F32);35 psVector *r mask= psVectorAllocEmpty (nPts, PS_TYPE_F32);36 psVector * lfmask= psVectorAllocEmpty (nPts, PS_TYPE_F32);51 psVector *rg = psVectorAllocEmpty (nPts, PS_TYPE_F32); 52 psVector *fg = psVectorAllocEmpty (nPts, PS_TYPE_F32); 53 psVector *rb = psVectorAllocEmpty (nPts, PS_TYPE_F32); 54 psVector *fb = psVectorAllocEmpty (nPts, PS_TYPE_F32); 37 55 38 int n = 0; 39 int nm = 0; 56 int ng = 0; 57 int nb = 0; 58 float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS] - source->pixels->col0; 59 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS] - source->pixels->row0; 40 60 for (int iy = 0; iy < source->pixels->numRows; iy++) { 41 61 for (int ix = 0; ix < source->pixels->numCols; ix++) { 42 43 62 if (source->mask->data.U8[iy][ix]) { 44 r mask->data.F32[nm] = RADIUS;45 lfmask->data.F32[nm] = log10(source->pixels->data.F32[iy][ix]);46 n m++;63 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ; 64 fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]); 65 nb++; 47 66 } else { 48 r adius->data.F32[n] = RADIUS;49 lflux->data.F32[n] = log10(source->pixels->data.F32[iy][ix]);50 n ++;67 rg->data.F32[ng] = hypot (ix - Xo, iy - Yo) ; 68 fg->data.F32[ng] = log10(source->pixels->data.F32[iy][ix]); 69 ng++; 51 70 } 52 71 } … … 56 75 57 76 graphdata.color = KapaColorByName ("black"); 77 graphdata.ptype = 2; 78 graphdata.size = 0.5; 79 graphdata.style = 2; 80 KapaPrepPlot (*kapa, ng, &graphdata); 81 KapaPlotVector (*kapa, ng, rg->data.F32); 82 KapaPlotVector (*kapa, ng, fg->data.F32); 83 84 graphdata.color = KapaColorByName ("red"); 58 85 graphdata.ptype = 0; 59 86 graphdata.size = 0.3; 60 87 graphdata.style = 2; 61 KapaPrepPlot ( kapa, nm, &graphdata);62 KapaPlotVector ( kapa, nm, rmask->data.F32);63 KapaPlotVector ( kapa, nm, lfmask->data.F32);88 KapaPrepPlot (*kapa, nb, &graphdata); 89 KapaPlotVector (*kapa, nb, rb->data.F32); 90 KapaPlotVector (*kapa, nb, fb->data.F32); 64 91 65 graphdata.color = KapaColorByName ("red"); 66 graphdata.ptype = 2; 67 graphdata.size = 0.5; 68 graphdata.style = 2; 69 KapaPrepPlot (kapa, n, &graphdata); 70 KapaPlotVector (kapa, n, radius->data.F32); 71 KapaPlotVector (kapa, n, lflux->data.F32); 92 psLogMsg ("psphot", 3, "saving plot to %s", filename); 72 93 73 psLogMsg ("psphot", 3, "saving plot to %s", file->filename); 74 KapaPS (kapa, false, KAPA_PS_NEWPAGE, filename, "none"); 94 char pagename[16]; 95 sprintf (pagename, "%02d", nCount); 96 if (nCount == 0) { 97 KiiPS (*kapa, false, KAPA_PS_NEWPLOT, filename, pagename); 98 } else { 99 KiiPS (*kapa, false, KAPA_PS_NEWPAGE, filename, pagename); 100 } 75 101 76 psFree (r adius);77 psFree ( lflux);78 psFree (r mask);79 psFree ( lfmask);102 psFree (rg); 103 psFree (fg); 104 psFree (rb); 105 psFree (fb); 80 106 107 nCount ++; 108 return true; 81 109 } 110 111 # else 112 113 bool psphotRadialPlot (int *kapa, const char *filename, pmSource *source) { 114 psLogMsg ("psphot", 3, "skipping source radial plots"); 115 return true; 116 } 117 118 # endif -
trunk/psphot/src/psphotReadout.c
r12632 r12665 108 108 } 109 109 110 // plot positive + negative sources (replace, then remove) 111 psphotSourcePlots (readout, sources, recipe); 112 110 113 // non-linear PSF and EXT fit to brighter sources 111 114 psphotBlendFit (readout, sources, recipe, psf); … … 113 116 // replace all sources 114 117 psphotReplaceAll (sources); 118 119 // plot positive sources 120 // psphotSourcePlots (readout, sources, recipe); 115 121 116 122 // linear PSF fit to remaining peaks -
trunk/psphot/src/psphotReplaceUnfit.c
r12625 r12665 53 53 return true; 54 54 } 55 56 // add or sub source replace or if the source has 57 bool psphotAddWithTest (pmSource *source, bool useState) { 58 59 // what is current state? (true : add; false : sub) 60 bool state = !(source->mode & PM_SOURCE_MODE_SUBTRACTED); 61 if (state && useState) return true; 62 63 // select appropriate model 64 pmModel *model = pmSourceGetModel (NULL, source); 65 if (model == NULL) return false; // model must be defined 66 67 psTrace ("psphot", 3, "replacing object at %f,%f\n", 68 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 69 70 // replace the model if 1) state says it is missing or 2) useState is false (just do it) 71 if (!state || !useState) { 72 pmModelAdd (source->pixels, source->mask, model, false, false); 73 } 74 return true; 75 } 76 77 // add or sub source replace or if the source has 78 bool psphotSubWithTest (pmSource *source, bool useState) { 79 80 // what is current state? (true : sub; false : add) 81 bool state = (source->mode & PM_SOURCE_MODE_SUBTRACTED); 82 if (state && useState) return true; 83 84 // select appropriate model 85 pmModel *model = pmSourceGetModel (NULL, source); 86 if (model == NULL) return false; // model must be defined 87 88 psTrace ("psphot", 3, "replacing object at %f,%f\n", 89 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 90 91 // replace the model if 1) state says it is missing or 2) useState is false (just do it) 92 if (!state || !useState) { 93 pmModelSub (source->pixels, source->mask, model, false, false); 94 } 95 return true; 96 } 97 98 // add or sub source replace or if the source has 99 bool psphotSetState (pmSource *source, bool curState) { 100 101 // what is desired state? (true : add; false : sub) 102 bool newState = !(source->mode & PM_SOURCE_MODE_SUBTRACTED); 103 if (curState == newState) return true; 104 105 // select appropriate model 106 pmModel *model = pmSourceGetModel (NULL, source); 107 if (model == NULL) return false; // model must be defined 108 109 psTrace ("psphot", 3, "replacing object at %f,%f\n", 110 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 111 112 if (curState && !newState) { 113 pmModelSub (source->pixels, source->mask, model, false, false); 114 } 115 if (newState && !curState) { 116 pmModelAdd (source->pixels, source->mask, model, false, false); 117 } 118 return true; 119 } -
trunk/psphot/src/psphotSourcePlots.c
r12627 r12665 3 3 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe) { 4 4 5 bool status = false;5 // bool status = false; 6 6 psTimerStart ("psphot"); 7 7 8 8 // the source images are written to an image 10x the size of a PSF object 9 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 10 PS_ASSERT (status); 9 // float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 10 // PS_ASSERT (status, false); 11 12 int DX = 21; 13 int DY = 21; 11 14 12 15 // examine PSF sources in S/N order (brightest first) … … 16 19 int dX = 0; // starting corner of next box 17 20 int dY = 0; // height of row so far 18 int NX = 10*(2*OUTER+1);// full width of output image21 int NX = 20*DX; // full width of output image 19 22 int NY = 0; // total height of output image 20 23 21 24 // first, examine the PSF and SAT stars: 22 // - generate radial plots (PS plots)23 25 // - determine bounding boxes for summary image 24 26 for (int i = 0; i < sources->n; i++) { … … 32 34 33 35 // how does this subimage get placed into the output image? 34 if (dX + source->pixels->numCols >= NX) { 36 // DX = source->pixels->numCols 37 // DY = source->pixels->numRows 38 39 if (dX + DX > NX) { 35 40 // too wide for the rest of this row 36 41 if (dX == 0) { 37 42 // alone on this row 38 NY += source->pixels->numRows;43 NY += DY; 39 44 dX = 0; 40 45 dY = 0; … … 42 47 // start the next row 43 48 NY += dY; 44 dX = source->pixels->numCols;45 dY = source->pixels->numRows;49 dX = DX; 50 dY = DY; 46 51 } 47 52 } else { 48 53 // extend this row 49 dX += source->pixels->numCols;50 dY = PS_MAX (dY, source->pixels->numRows);54 dX += DX; 55 dY = PS_MAX (dY, DY); 51 56 } 52 psphotRadialPlot ("radial.plots.ps", source);53 57 } 54 58 … … 59 63 int Xo = 0; // starting corner of next box 60 64 int Yo = 0; // starting corner of next box 61 int dY = 0; // height of row so far 65 dY = 0; // height of row so far 66 67 int nPSF = 0; 68 int nSAT = 0; 69 int kapa = 0; // file descriptor for plotting routine 62 70 63 71 // first, examine the PSF and SAT stars: 64 72 // - generate radial plots (PS plots) 65 // - determine bounding boxes for summary image73 // - create output image array 66 74 for (int i = 0; i < sources->n; i++) { 67 75 … … 69 77 70 78 bool keep = false; 71 keep |= (source->mode & PM_SOURCE_MODE_PSFSTAR); 72 keep |= (source->mode & PM_SOURCE_MODE_SATSTAR); 79 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 80 nPSF ++; 81 keep = true; 82 } 83 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 84 nSAT ++; 85 keep = true; 86 } 73 87 if (!keep) continue; 74 88 75 89 // how does this subimage get placed into the output image? 76 if (Xo + source->pixels->numCols >= NX) { 90 // DX = source->pixels->numCols 91 // DY = source->pixels->numRows 92 93 if (Xo + DX > NX) { 77 94 // too wide for the rest of this row 78 95 if (Xo == 0) { 79 // alone on this row 80 PlaceImage (source, Xo, Yo); 81 Yo += source->pixels->numRows; 96 // place source alone on this row 97 psphotAddWithTest (source, true); // replace source if subtracted 98 psphotRadialPlot (&kapa, "radial.plots.ps", source); 99 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY); 100 101 psphotSubWithTest (source, false); // remove source (force) 102 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY); 103 104 psphotSetState (source, false); // replace source (has been subtracted) 105 Yo += DY; 82 106 Xo = 0; 83 107 dY = 0; … … 86 110 Yo += dY; 87 111 Xo = 0; 88 PlaceImage (source, Xo, Yo); 89 Xo = source->pixels->numCols; 90 dY = source->pixels->numRows; 112 psphotAddWithTest (source, true); // replace source if subtracted 113 psphotRadialPlot (&kapa, "radial.plots.ps", source); 114 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY); 115 116 psphotSubWithTest (source, false); // remove source (force) 117 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY); 118 psphotSetState (source, false); // replace source (has been subtracted) 119 120 Xo = DX; 121 dY = DY; 91 122 } 92 123 } else { 93 124 // extend this row 94 PlaceImage (source, Xo, Yo); 95 Xo += source->pixels->numCols; 96 dY = PS_MAX (dY, source->pixels->numRows); 125 psphotAddWithTest (source, true); // replace source if subtracted 126 psphotRadialPlot (&kapa, "radial.plots.ps", source); 127 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY); 128 129 psphotSubWithTest (source, false); // remove source (force) 130 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY); 131 psphotSetState (source, false); // replace source (has been subtracted) 132 133 Xo += DX; 134 dY = PS_MAX (dY, DY); 97 135 } 98 136 } 99 137 100 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d failed: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot")); 138 psphotSaveImage (NULL, outpos, "outpos.fits"); 139 psphotSaveImage (NULL, outsub, "outsub.fits"); 140 psLogMsg ("psphot", PS_LOG_INFO, "plotted %d sources (%d psf, %d sat): %f sec\n", nPSF + nSAT, nPSF, nSAT, psTimerMark ("psphot")); 141 142 psFree (outpos); 143 psFree (outsub); 101 144 return (sources); 102 145 }
Note:
See TracChangeset
for help on using the changeset viewer.
