;+ ; Show the most recently fit gaussians and annotate plot with their ; peak, center, width values. ; ; @keyword modelindex {in}{optional}{type=integer} The data container ; index containing the model of the most recent gaussian fit. If this ; is omitted, a value of -1 is assumed. If this is -1 then a model is ; constructed from the fit parameters in !g.gauss. This is ignored if ; parts is set. ; ; @keyword parts {in}{optional}{type=boolean} When set, show the ; individual gaussians as separate plots. This always constructs the ; gaussians from the parameters in !g.gauss. modelindex is ignored ; when this keyword is set. ; ; @keyword color {in}{optional}{type=integer}{default=!g.gshowcolor} ; A color to use for the plots. ; ; @version $Id: gshow.pro,v 1.8 2005/05/02 19:16:50 bgarwood Exp $ ;- pro gshow, modelindex=modelindex, parts=parts, color=color if (n_elements(modelindex) eq 0) then modelindex = -1 if (n_elements(color) eq 0) then color=!g.gshowcolor ; do we show the entire model, or just the fit for each gaussian if (keyword_set(parts) eq 0) then begin ; get the data to be plotted: from model, or coefficients? if (modelindex ne -1) then begin ; over plot the model data if !g.line then begin data = *!g.s[modelindex].data_ptr endif else begin data = *!g.c[modelindex].data_ptr endelse endif else begin ng = !g.gauss.ngauss if (ng le 0) then return ; create the model from the coefficients in !g if !g.line then begin npts = data_valid(!g.s[0]) endif else begin npts = data_valid(!g.c[0]) endelse if (npts le 0) then begin message, 'No data at index 0 to base the model on.',/info return endif x = indgen(npts) data = make_gauss_data(x,!g.gauss.fit[*,0:(ng-1)],0.0) endelse ; plot it gbtoplot, data, color=color, /chan endif else begin ; create a gaussian from each set of coefficients, and plot them ng = !g.gauss.ngauss if (ng le 0) then return if !g.line then begin npts = data_valid(!g.s[0]) endif else begin npts = data_valid(!g.c[0]) endelse if npts le 0 then return x = indgen(npts) ; go through each gauss mc = machar() ; data is floating point prec, so don't plot anything ; that would require more than that precision to represent for i=0,ng-1 do begin params = !g.gauss.fit[*,i] data = make_gauss_data(x,params,0.) adata = abs(data) indxok = where(adata gt max(adata)*mc.eps) ; plot this part gbtoplot, x[indxok], data[indxok], color=color, /chan endfor endelse clearannotations ; annotate the gaussians lab=' P C W' off=-.03 annotate,.13,.71,lab,/normal,charsize=1.4,color=!yellow,/noshow ; label for i=0,!g.gauss.ngauss-1 do begin ; convert those to x-axis coordinate values left=!g.gauss.fit[1,i]-!g.gauss.fit[2,i]/2.0d right=left+!g.gauss.fit[2,i] xvals = chantox([!g.gauss.fit[1,i],left,right]) sh=fstring(!g.gauss.fit[0,i],'(f10.3)') sc=fstring(xvals[0],'(f10.3)') sw=fstring(abs(xvals[2]-xvals[1]),'(f10.3)') y = .67+i*off annotate,.13,y,sh,/normal,charsize=1.5,color=!yellow,/noshow ; peak annotate,.22,y,sc,/normal,charsize=1.5,color=!yellow,/noshow ; center annotate,.31,y,sw,/normal,charsize=1.5,color=!yellow,/noshow ; width endfor show,/reshow end