pro get_group,sc,bc,ch,ff,ffe,chl,chh,ctonth=ctonth,fout=fout ;+ ; ; calculate the boundary channel numbers for a constant signal to noise ratio ; spectrum ; ; sc - count vector for the source (including background) ; bc - expected background count vector ; ch - mean channel number of the output spectrum bins ; ff, ffe - output spectrum and its erro bars ; chl, chh - the lower and upper channel numbers of the output spectrum bins ; ctonth - the signal to noise threshold; def=3 ; fout - the output file name (to be used by grppha for example) ; which can be used in the program grppha for grouping. ; ; written by wqd, April 28, 2000 ; ;- if n_params() eq 0 then begin print,'CALLING SEQUENCE -- get_group,sc,bc,ch,ff,ffe,chl,chh,ctonth=ctonth,fout=fout' return endif nch=n_elements(sc) get_hist_var,lindgen(nch),sc,bc,replicate(1.,nch),ch,chl,chh,ff,ffe,t,cton=ctonth gl=[-999] gh=[-999] chl=fix(chl)+1 ng=n_elements(ch) chh=[chl(1:ng-1)-1,nch] chd=chh-chl+1 sel=where(chd ne 1,nsel) print,'channellow channelhigh groupfactor ' for k=0,nsel-1 do begin kk=sel(k) print,chl(kk)-1,chh(kk)-1,fix(chd(kk)) ; the output is to be used in grppha for grouping. endfor if n_elements(fout) ne 0 then begin openw,un,fout,/get for k=0,nsel-1 do begin kk=sel(k) printf,un,chl(kk)-1,chh(kk)-1,fix(chd(kk)) endfor free_lun,un endif ; ploterr,ch,ff,ffe if !debug eq 1 then stop return end