pro deslantusage ;+ ; ; procedure: deslant.pro ; ; purpose: remove spectra slant along slit from iquv arrays ; ; routines: deslantusage findtline shiftspec deslant ; ; author: paul@ncar, 4/97 ; ;============================================================================== ; ; if 1 then begin print print, "usage: deslant, i, q, u, v $" print, " , ilo, ihi, halfwidth, ylo, yhi, winglo, winghi" print print, " purpose: remove spectra slant along slit from" print, " i q u v arrays" print print, " Arguments:" print, " ilo - first pixel of spectra line" print, " usually telluric used to determine" print, " slant per pixel" print, " (def: 0; unreasonable)" print, " ihi - last pixel of spectra line" print, " usually telluric used to determine" print, " slant per pixel" print, " (def: last pixel; unreasonable)" print pause, 'return to continue' print print, " halfwidth ~ print, " number of pixels either side of" print, " line minimum for parabolic fit to find" print, " line center. (def: 1 for 6302 telluric," print, " may need higher values for broader lines" print, " ylo - used to avoid hair lines." print, " First pixel along slit used" print, " to determine slant per pixel" print, " (def: 0)" print, " yhi - used to avoid hair lines." print, " Last pixel along slit used" print, " to determine slant per pixel" print, " (def: maximum)" print pause, 'return to continue' print print, " winglo - first good pixel for shifting" print, " (def: 0)" print, " winghi - last good pixel for shifting" print, " (def: last spectra pixel)" print return endif ;- end ;------------------------------------------------------------------------------ ; ; procedure: findtline ; ; purpose: find spectra slant as parabola fit to a line. ; ;------------------------------------------------------------------------------ pro findtline, i, ilo, ihi, hwd, ylo, yhi, prbl ;Array dimensions. junk = n_dims( i, dnumx, dnumy ) ;Initialize arrays. yyyy = findgen(dnumy) smin = fltarr(dnumy) ;Loop along slit. for along=ylo,yhi do begin ;Find line minimum. tmp = min( i(ilo:ihi,along), msub ) msub = ilo+msub ;Fit parabola to line profile. coef = poly_fit( findgen(2*hwd+1), i(msub-hwd:msub+hwd,along), 2 ) ;Save parabola minimum. smin(along) = msub-coef(1)/(2.*coef(2))-hwd end ;Parabola fit of spectra line centers. prbl = poly_fit( yyyy(ylo:yhi), smin(ylo:yhi), 2 ) end ;------------------------------------------------------------------------------ ; ; function: shiftspec ; ; purpose: shift ASP profile vector with FFT's. ; ;------------------------------------------------------------------------------ function shiftspec, vctr, dnumx, vshift, wlo, whi ;Extend vector to 256 pixels. if dnumx lt 256 then vctr = [ vctr, fltarr(256-dnumx) ] ; smoothly extend over ends of array vctr = extend(float(vctr),wlo,whi) ;Forward FTT. vfft = fft( vctr, -1 ) ;Shift if Fourier space. vfft = xshift( vfft, vshift ) ;Backward FFT. vctr = float( fft( vfft, 1 ) ) ;Return shifted vector return, vctr(0:dnumx-1) end ;------------------------------------------------------------------------------ ; ; procedure: deslant ; ; purpose: remove spectra slant along slit from i q uv arrays ; ;------------------------------------------------------------------------------ pro deslant, i, q, u, v, ilo_, ihi_, hwd_, ylo_, yhi_, wlo_, whi_ ;Check number of parameters. if n_params() eq 0 then begin deslantusage return end ;Array dimensions. junk = n_dims( i, dnumx, dnumy ) ;First pixel to search for minimum. ;Last pixel to search for minumun. ;Half width to fit parabola. ;First pixel along slit to fit. ;Last pixel along slit to fit. ;First good pixel for shifting. ;Last good pixel for shifting. if n_elements(ilo_) ne 0 then ilo=round(ilo_)>0 else ilo=0 if n_elements(ihi_) ne 0 then ihi=round(ihi_)<(dnumx-1) else ihi=dnumx-1 if n_elements(hwd_) ne 0 then hwd=round(hwd_) else hwd=1 if n_elements(ylo_) ne 0 then ylo=round(ylo_)>0 else ylo=0 if n_elements(yhi_) ne 0 then yhi=round(yhi_)<(dnumy-1) else yhi=dnumy-1 if n_elements(wlo_) ne 0 then wlo=round(wlo_)>0 else wlo=0 if n_elements(whi_) ne 0 then whi=round(whi_)<(dnumx-1) else whi=dnumx-1 ;Get shift as parabola fit to line. findtline, i, ilo, ihi, hwd, ylo, yhi, prbl ;Loop along slit. for iy=1L,dnumy-1L do begin ;Spectra shift from mean ylo yhi. ym = .5*(ylo+yhi) shft = ( prbl(1)*ym+prbl(2)*ym*ym ) - ( prbl(1)*iy+prbl(2)*iy*iy ) ;Shift spectra. i(*,iy) = shiftspec( i(*,iy), dnumx, shft, wlo, whi ) q(*,iy) = shiftspec( q(*,iy), dnumx, shft, wlo, whi ) u(*,iy) = shiftspec( u(*,iy), dnumx, shft, wlo, whi ) v(*,iy) = shiftspec( v(*,iy), dnumx, shft, wlo, whi ) end end