FUNCTION PROSHIFT2,cube,ds,reb ; ;Calculation of line profile shift by means of a two-slit method. ;Two "slits" with a constant distance DS between them are shifted ;along the line profile(s) (last dimension of CUBE) in order to ;achieve equal intensities on both slits. Then the position of the ;"slits" shows the relative shift(s) of the line profile(s). ; ;INPUTS: CUBE - 1D-3D array, where the spectral dimension is last ; DS - distance between the slits (pixels) ; REB - rebinning coefficient to make the spectral sampling finer ;OUTPUT: relative shift of the profile in pixels (float) ; ;Version 2 of proshift, more robust, using the fact that the searched ;minimum of difc is always between two maxima. The formula ; a = I1+I3-2*I2 is used and the convexity maximum is searched. ; ;4 October 2013, Michal on_error,1 si=size(cube) if si(0) eq 1 then begin ;a single spectral profile (lambda) cub=rebin(cube,si(1)*reb) ;rebin to refine spectral resolution cub=cub(0:(si(1)-1)*reb) ;cut away the constant tail difc=cub-shift(cub,ds*reb) ;compare shifted spectra cub=0 difc=abs(difc(ds*reb:*)) ;abs difference in the useful range nlp=n_elements(difc) a=shift(difc,1)+shift(difc,-1)-2*difc ;convexity difc=0 ;at which position is the minimum of difference (= convexity maximum)? ma=max(a(2*reb:nlp-2*reb-1),pos) RETURN,float(pos)/reb ; a scalar endif if si(0) eq 2 then begin ;1D spectral image (x,lambda) cub=rebin(cube,si(1),si(2)*reb) ;rebin to refine spectral resolution cub=cub(*,0:(si(2)-1)*reb) ;cut away the constant tail difc=cub-shift(cub,0,ds*reb) ;compare shifted spectra cub=0 difc=abs(difc(*,ds*reb:*)) ;abs difference in the useful range nlp=n_elements(difc(0,*)) a=shift(difc,0,1)+shift(difc,0,-1)-2*difc ;convexity difc=0 prosh=fltarr(si(1)) ;at which position is the minimum of difference (= convexity maximum)? for i=0,si(1)-1 do begin ma=max(a(i,2*reb:nlp-2*reb-1),pos) prosh(i)=float(pos) endfor RETURN,prosh/reb ;a 1D float vector endif if si(0) eq 3 then begin ;2D spectral image (x,y,lambda) cub=rebin(cube,si(1),si(2),si(3)*reb) ;rebin to refine spectral resolution cub=cub(*,*,0:(si(3)-1)*reb) ;cut away the constant tail difc=cub-shift(cub,0,0,ds*reb) ;compare shifted spectra cub=0 difc=abs(difc(*,*,ds*reb:*)) ;abs difference in the useful range nlp=n_elements(difc(0,0,*)) a=shift(difc,0,0,1)+shift(difc,0,0,-1)-2*difc ;convexity difc=0 prosh=fltarr(si(1),si(2)) ;at which position is the minimum of difference (= convexity maximum)? for i=0,si(1)-1 do begin for j=0,si(2)-1 do begin ma=max(a(i,j,2*reb:nlp-2*reb-1),pos) prosh(i,j)=float(pos) endfor endfor RETURN,prosh/reb ;a 2D float array endif message,'Input array must have 1-3 dimensions' END