;                          VG
;+
;   Constructs a four-panel (one panel for light curves and 3 for spectral
;   data) viewgraph.  The BDA file start and stop dataset numbers are 
;   prompted for.  See GS_VG for greyscale interface to same plots.
;
;  
;   JM    Nov '91
;	RDB	18-Feb-92	DECOMPRESS -> BCS_DECOMP
;
;-
;

!p.font = 0
!p.multi = [0, 2, 2]
!p.charsize = 1.2

; get information, assuming usual data from test_rd
print, 'VG - Four-panel viewgraphs of flare data'
print, ''
print, 'Enter start and end record for light curve (first record is 0)'
read, start, stop
print, ''
print, 'Enter start record and number to sum for spectra"
read, istart, nsum

; First panel - light curves
plot, roadmap(start:stop).time/1000./3600., $
	roadmap(start:stop).total_cnts(3), xtitle='Time (hours)', $
	ytitle='Counts/dgi', title='BCS Light Curves',psym=3
oplot, roadmap(start:stop).time/1000./3600., $
	roadmap(start:stop).total_cnts(2),psym=3
oplot, roadmap(start:stop).time/1000./3600., $
	roadmap(start:stop).total_cnts(1),psym=3

; put some marks on to show where the spectra are
xl = [roadmap(istart).time, roadmap(istart+nsum-1).time]
xl = xl/1000.0/3600.0
oplot, [xl(0), xl(0)], [0, 3.0*max(roadmap(start:stop).total_cnts(3))]
oplot, [xl(1), xl(1)], [0, 3.0*max(roadmap(start:stop).total_cnts(3))]

y = data(0:767, istart:istart+nsum-1)
y = bcs_decomp(y, 1)
yt = fltarr(1024)
for i = 0, fix(nsum)-1 do yt = yt + y(*, i)
yt = yt/(index(istart).bcs.dgi*0.125*nsum)

plot, yt(256:510), xtitle='Bin', psym=10, ytitle='Counts/sec', $
	title='Fe XXV', xstyle=1, xrange=[0, 255], $
	xtickv=[0, 50, 100, 150, 200, 250]

plot, yt(512:638), xtitle='Bin', psym=10, ytitle='Counts/sec', $
	title='Ca XIX', xstyle=1, xrange=[0, 127], $
	xtickv=[0, 25, 50, 75, 100, 125], xticks=6
xyouts, !p.position(0), !p.position(1), infil, /normal

plot, yt(640:766), xtitle='Bin', psym=10, ytitle='Counts/sec', $
	title='S XV', xstyle=1, xrange=[0, 127], $
	xtickv=[0, 25, 50, 75, 100, 125], xticks=6

; clean up
!p.multi = 0

end
