;+
; NAME
;
;    EIS_WAVELENGTH_TO_PIXELS()
;
; PROJECT
;
;    SOLAR-B/EIS
;
; EXPLANATION
;
;    Converts a wavelength to a pixel location.
;
; INPUT
;
;    WAVE   The wavelength specified in pico-metres. (This format is required
;           by the EIS planning software.) WAVE must be specified as a scalar.
;
;    SLIT_IND  The index of the EIS slit:
;              0   1"
;              1   266"
;              2   2"
;              3   40"
;
; OUTPUT
;
;    The pixel location corresponding to wavelength WAVE. Fractional pixel
;    values are not given.
;
; EXAMPLE
;
;    IDL> print,eis_wavelength_to_pixels(19512)
;            1291
;
; CALLS
;
;    EIS_GET_CCD_TRANSLATION()
;
; HISTORY
;
;    Ver.1, 16-May-2006, Peter Young
;    Ver.2, 12-Jan-2007, Peter Young
;         added SLIT_IND input
;    Ver.3, 02-Dec-2008
;         added TIME keyword
;-
;______________________________________________________________________________
FUNCTION eis_wavelength_to_pixels , wave, slit_ind , time = time

coeffs = eis_get_ccd_translation(slit_ind , time = time )

;
; The pixel offsets for the two detectors are given in the Lang et al. (2006)
; calibration paper.
;
pix=findgen(2048)
CASE (wave GT 24000) OF
  0: pix=pix+50.
  1: pix=pix+2198.
ENDCASE
wvl_array=dblarr(2048)

ii=(wave GT 24000)
c=coeffs[ii]
a=[c.a0,c.a1,c.a2,c.a3,c.a4]
n=n_elements(a)
FOR i=0,n-1 DO wvl_array=wvl_array+a[i]*pix^i

getmin=min(abs(wvl_array-wave/100.),imin)

return,imin

END
