pro stereo_lethet_profile_spec, refdate

outdir00='/sasstore/dat10/syashir1/www_cdaw/www3/plots/stereo_lethet/'
outdir0=outdir00+anytim2yymmdd(refdate, format='yyyy/mm/dd/')


for s=0,1 do begin

   case s of
      0: sat='a'      
      1: sat='b'
   endcase

   reftime0=refdate+' 00:00'
   i1=y_time_keisan(reftime0,-27-3, form=11)
   i2=y_time_keisan(i1,+71.9+6+24, form=11)
   timerange=[i1,i2]
   lethet=read_stereolethet_genx(timerange,sat)

   if n_elements(lethet) ge 10 then begin
      
      loadct,0
      stretch, 255,0
      ycolors2
      red=gt_ycolors2(4,0,0)
      orange=gt_ycolors2(4,2,0)
      green=gt_ycolors2(0,3,0)
      cyan=gt_ycolors2(0,3,3)
      blue=gt_ycolors2(0,0,4)
      gray=gt_ycolors2(3,3,3)
      
      window, 0, xs=1024, ys=512, pix=1
      diamond_symbol,/fill
      
      ytitle='Protons [cm!U-2!N sr!U-1!N sec!U-1!N MeV!U-1!N]'
      
      
      
      if not file_test(outdir0) then yspawn,'mkdir -p '+outdir0

      for h=0,23 do begin
         
         targettime=refdate+' '+string(h, format='(i02)')+':02:30'
         
         dtim=abs(time_sub(lethet.daytim, targettime))
         i=min(where(dtim eq min(dtim)))
         
         reftime1=lethet(i).daytim
         i1=y_time_keisan(reftime1,-27, form=11)
         i2=y_time_keisan(i1,+71.9, form=11)
         trange=[i1,i2]
         
         
         
         !p.multi=[0,2,1]
         !p.charsize=1.5
         !y.margin=[3.5,2]
         !x.margin=[8,2]
         yr=[1e-4,1e5]
         
         
         utplot_io, trange, yr, yr=yr, ys=1, xs=1,/nodata, ytitle=ytitle,$
                    xtitle='Start Time ('+i1+')', title=reftime1
         
         outplot, lethet.daytim, lethet.p10int, color=gray, thick=3
         
         outplot, lethet.daytim, lethet.let_rebinned_pflux(0), color=red, thick=2
         outplot, lethet.daytim, lethet.let_rebinned_pflux(2), color=orange, thick=2
         
         outplot, lethet.daytim, lethet.het_rebinned_pflux(0), color=green, thick=2
         outplot, lethet.daytim, lethet.het_rebinned_pflux(5), color=cyan, thick=2
         outplot, lethet.daytim, lethet.het_rebinned_pflux(10), color=blue, thick=2
         
         
         outplot, reftime1+['',''], yr*[1,1]
;         clip_xyouts, 0.4, 0.025, reftime1, al=0.5
         
         stereo='STEREO-'+strupcase(sat)
         case sat of
            'a': satcolor=red
            'b': satcolor=blue
         endcase
         clip_xyouts, 0.95, 0.92, stereo, color=satcolor, al=1, charsize=2.0
         
         
         
                                ;---b---
         plot_oo, lethet(i).pch, [lethet(i).let_rebinned_pflux,lethet(i).het_rebinned_pflux], xr=[1,300], yr=[1e-4,1e5], psym=-4, ys=1,$
                  xtitle='Energy [MeV]', ytitle=ytitle, xs=1, title=reftime1
         
         oplot, lethet(i).pch, lethet(i).let_rebinned_pflux, psym=-4
         plots, lethet(i).pch(0), lethet(i).let_rebinned_pflux(0), color=red, psym=8, symsize=1.5
         plots, lethet(i).pch(2), lethet(i).let_rebinned_pflux(2), color=orange, psym=8, symsize=1.5
         plots, lethet(i).pch(0+4), lethet(i).het_rebinned_pflux(0), color=green, psym=8, symsize=1.5
         plots, lethet(i).pch(5+4), lethet(i).het_rebinned_pflux(5), color=cyan, psym=8, symsize=1.5
         plots, lethet(i).pch(10+4), lethet(i).het_rebinned_pflux(10), color=blue, psym=8, symsize=1.5
         
         
         
         clip_xyouts, 0.7, 0.95, 'LET+HET (Interpolate): ', al=1
;   clip_xyouts, 0.7, 0.90, 'HET (Power-Law Fit): ', al=1
         
         case 1 of
            lethet(i).p10int ge 10: format='(i6)'
            else: format='(F6.1)'
         endcase
         
         clip_xyouts, 0.7, 0.95, string(lethet(i).p10int, format=format)+' pfu', charsize=1.8
;   clip_xyouts, 0.7, 0.90, string(lethet(i).p10power_het, format=format)+' pfu', charsize=1.8


;stop
;   print, i
;   if i ge 300 then stop

         outfil=anytim2yymmdd(lethet(i).daytim, format='yyyymmdd_hhmmss')+'_st'+sat+'_lethet.gif'

         
         x2gif, outdir0+outfil
   

      endfor                    ;h
   endif; nlm(lethet) ge 10
endfor;s

end
