pro show_slit6, n2=n2


common cds_wavecal, ncoff, gcoff

;
;  save existing coefficients
;
sncoff = ncoff

;
;  load old coeffs
;
s = load_wavecal('n2','1997-1-1')

;
;  Read in correct spectrum and associated CHIANTI info
;
if keyword_set(n2) then begin
   get_avgspec,w,d,/n2
   w = pix2wave('n2',indgen(1024))
   ch = gt_chianti(concat_dir('$CDS_ATOMIC','nis2_ar_mc_ar'))
   minwav = 510
   sp = 'NIS2'
   xr=[510,635]
   yr = [0,2]
   delw = 0.5
endif else begin
   get_avgspec,w,d
   w = pix2wave('n1',indgen(1024))
   ch = gt_chianti(concat_dir('$CDS_ATOMIC','nis1_ar_mc_ar'))
   minwav = 310
   sp = 'NIS1'
   xr=[310,380]
   yr = [0,0.3]
   delw = 0.3
endelse

;
;  for convenience
;
intensity = float(strmid(ch.list_ident,68,10))
wave = ch.list_wvl
ident = strtrim(ch.list_ident,2)

;
;   Only keep intense lines and add HeI/II manually
;
n = where(intensity gt 1.0d11)
intensity = [intensity(n),5.0d14,5.0d14]
wave = [wave(n),584.327,607.56]
ident = [ident(n),'He I     ','He II     ']


;
;  Plot spectrum
;
plot,w,d,psym=10,xr=xr,/xst,tit=sp+' Average spectrum',xtit='Wavelength',$
            ytit='Intensity',chars=1.4,yr=yr,/yst


print,' '
print,'Click cursor on line of interest: click to left of Y-axis to finish'
print,' '


;
;  Loop on cursor input
;
xc = 1000
while xc gt minwav do begin
   cursor,xc,yc,3,/data
   if xc gt minwav then begin
      x1 = wave2pix(sp,xc)-27 > 0
      x2 = wave2pix(sp,xc)+27 < 1023
      maxy = max(d(x1:x2)) < (yr(1)-0.02)
      w1 = pix2wave(sp,x1)
      w2 = pix2wave(sp,x2)
      n = where(wave gt (xc-delw) and wave lt (xc+delw), count)
      if count gt 0 then begin
         ww1 = wave(n)
         id1 = strmid(ident(n),0,8)
         inten1 =intensity(n)
         print,'  '
         print_str,id1+'  '+strtrim(string(ww1),2)+'  '+string(inten1)
      endif else begin
         print,'  '
         print,'No line ID'+'  '+trim(xc)
      endelse
      oplot,[w1,w1],[0,maxy],th=2
      oplot,[w1,w2],[maxy,maxy],th=2
      oplot,[w2,w2],[0,maxy],th=2
   endif
endwhile

;
;  restore previous coefficients
;
ncoff = sncoff

end