;+
; NAME:
;     NEUPERT_PLOT
; PURPOSE:
;     Make a standard plot of soft and hard X-ray light curves
; CATEGORY:
; CALLING SEQUENCE:
;     neupert_plot, t1, t2
;     neupert_plot,'25-aug 14:20','25-aug 15:00',/hxt,infil=infil,channel=0,/gif,back=.05
;       (where infil = "hda000825.1344", made the plot in 000901.html)
; INPUTS:
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
;     hxt forces HXT as the hard X-ray reference
;       (default is the late lamented BATSE)
;     infil=infil gets HXT counts (M1) from an HDA file
;     logplot forces semilog plot
;     bad, an array (e.g. 20+indgen(3)) that
;       lists the HDA index entries not to be plotted
;     channel, the HXT channel to be overplotted (M1 default) 
;     back, an empirical background level that you have to
;       enter manually if you want a pretty plot
;     gif, writes a gif version (and a thumbnail)
; OUTPUTS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     31-Aug-00, written by HSH
;      1-Sep-00, LF added elementary /ps, /eps switch
;-
pro neupert_plot, tt1, tt2, hxt=hxt, qdebug = qdebug, infil = infil, $
  logplot=logplot, bad=bad, channel=channel, back=back, gif=gif, ps=ps, $
  eps=eps

if not keyword_set(ps) and not keyword_set(eps) then window,0

if keyword_set(ps) or keyword_set(eps) then begin
  set_plot, 'ps'
  if keyword_set(ps) then  device, file='~/neupert_plot.ps'
  if keyword_set(eps) then  device, file='~/neupert_plot.eps',/encapsulated
  print, ' '
  print, '(e)ps file will be written to ~/neupert_plot.(e)ps'
  print, ''
endif

  loadct,0
  over
  tvlct,r,g,b,/get

if n_elements(channel) eq 0 then channel = 1
if n_elements(back) eq 0 then back = 0. 
if n_elements(tt1) eq 0 then tt1 = '12-may-97 04:30'
if n_elements(tt2) eq 0 then tt2 = '12-may-97 06:00'
if n_elements(infil) ne 0 then begin
  rd_roadmap,infil,rm
  fmt_timer,rm,t1,t2
endif
if n_elements(hxt) eq 0 then begin
  rd_gbl,t1,t2,gbl
  if n_elements(gbl) lt 100 then begin
    print,"No BATSE data, defaulting to HXT - declare the file please"
  endif
endif  
if n_elements(infil) ne 0 then begin
  rd_xda,infil,-1,hindex,hdata
  cts = ave_cts(hindex,hdata,time=time)
endif
rd_gxd,tt1,tt2,gxd

if n_elements(gxd) lt 10 then rd_gxd,tt1,tt2,gxd,/goes10
utplot,gxd,gxd.lo/max(gxd.lo),yr=[0,1.1],yst=1,charsi=1.5,$
  ytit="Normalized fluxes",tit="Hard and soft X-ray light curves",$
  xtit=strmid(t1,0,10)+' UT'
if n_elements(logplot) ne 0 then $
  utplot_io,gxd,gxd.lo/max(gxd.lo),yr=[1e-2,1.1],yst=1,charsi=1.5,$
    ytit="Normalized fluxes",tit="Hard and soft X-ray light curves",$
    xtit=strmid(t1,0,10)+' UT'
if n_elements(cts) eq 0 then begin
  outplot,gbl,gbl.channel1/max(gbl.channel1)
endif else begin
  good = indgen(n_elements(hindex))
  if n_elements(bad) ne 0 then good = kill_index(good, bad)
  outplot,time,cts(channel,*,good)/max(cts(channel,*,good))-back,hindex(0),psym=3
endelse

if keyword_set(gif) then begin
  out=tvrd()
  write_gif,'neupert_plot.gif',out,r,g,b
  write_gif,'neupert_plot_thumb.gif',rebin(out,160,128),r,g,b
endif

if keyword_set(ps) or keyword_set(eps) then  begin
  device, /close
  set_plot, 'x'
endif

if n_elements(qdebug) ne 0 then stop
end
