;+ ;PRO removeline,x,y,out,_EXTRA=ex ; this allows you to interact with any plot, just insert an out parameter and call removeline instead of plot ; it will allow you to subtract any gaussian or lorentzian line from your spectra,for best results, select a width close to where the line visibly disappears into the spectra ;by Conor Laver 06/11/2006 ; written during World Cup '06 ;- PRO removeline,x,y,out,_EXTRA=ex iny=y pickcenter: window,8,title='Remove line' plot,x,iny,_extra=ex print,'Click on the line center' cursor,xcen,ydata,/data,/down ver,xcen,linestyle=1 print,'Click on one side, for fit width, make it big' cursor,xedge,ydata,/data,/down ; car='' ; read,'Is it ok,Conor? (yes/no)',car ; if strmid(car,0,1) eq 'n' then goto,pickcenter side=min(where(x gt xedge)) index=min(where(x gt xcen)) width=abs(index-side) ver,x[index-width],linestyle=2 ver,x[index+width],linestyle=2 xr=x[index-width:index+width] yr=iny[index-width:index+width] res=mpfitpeak(xr,yr,a,/lorentzian) curvelor=a[0]/(((xr-a[1])/a[2])^2+1) res=mpfitpeak(xr,yr,a,/gaussian) curvegau=a[0]*exp(-0.5*((xr-a[1])/a[2])^2) window,9,title='Close up of Gaussian line at:'+strc(a[1])+' subtraction' plot,xr,yr oplot,xr,yr-curvegau,linestyle=2 window,7,title='Close up of Lorentz line at:'+strc(a[1])+' subtraction' plot,xr,yr oplot,xr,yr-curvelor,linestyle=2 wset,8 picktype: line='' read,'Would you like to fit [1]Gaussian or [2]Lorentzian line? ',line print,'You chose option '+line if strmid(line,0,1) eq '2' then curve=curvelor else curve=curvegau newy=iny newy[index-width:index+width]=newy[index-width:index+width]-curve plot,x,newy,_extra=ex happy='' read,'Would you like to [1]Fit new line [2]Totally redo this line or [3]Choose different fit type or [4]Output current spectra? ',happy if strmid(happy,0,1) eq '1' then begin iny=newy goto,pickcenter endif if strmid(happy,0,1) eq '2' then goto,pickcenter if strmid(happy,0,1) eq '3' then goto,picktype out=newy end