; Comments added by Erik Johnson 7/6/07
; step_view.pro, compiles and runs with idl
; needs flag.pro to run
; used in the manual step of removing spikes
; input ?
; output: graphs?
pro step_view,bx,by,bz,start_mark,stop_mark,x,y,z,ss=ss,ee=ee,fixer=fixer,$
oplot_only=oplot_only
!p.multi = [0,1,3,2]
!p.background=255
!p.color=0
!p.charsize=1.5
t = lindgen(86400)
if keyword_set(fixer) then begin
!p.multi = [0,2,3,0,1]
ss = start_mark*3600.-600.
ee = start_mark*3600.+600.
if ss lt 0 then ss=0
if ee gt 86399 then ee=86399
bbx = bx & bby = by & bbz = bz
bbx(start_mark*3600.:stop_mark*3600.) = bx(start_mark*3600.:stop_mark*3600.) + x
bby(start_mark*3600.:stop_mark*3600.) = by(start_mark*3600.:stop_mark*3600.) + y
bbz(start_mark*3600.:stop_mark*3600.) = bz(start_mark*3600.:stop_mark*3600.) + z
bad = where(bx eq 32767,count)
if count ne 0 then bbx(bad) = 32767
bad = where(by eq 32767,count)
if count ne 0 then bby(bad) = 32767
bad = where(bz eq 32767,count)
if count ne 0 then bbz(bad) = 32767
fss = start_mark*3600.-10
fee = start_mark*3600.+10
if fss lt 0 then fss=0
if fee gt 86399 then fee=86399
bbx(fss:fee) = 32767
bby(fss:fee) = 32767
bbz(fss:fee) = 32767
fss = stop_mark*3600.-10
fee = stop_mark*3600.+10
if fss lt 0 then fss=0
if fee gt 86399 then fee=86399
bbx(fss:fee) = 32767
bby(fss:fee) = 32767
bbz(fss:fee) = 32767
plot,t(ss:ee)/3600.,flag(bbx(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
plot,t(ss:ee)/3600.,flag(bby(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
plot,t(ss:ee)/3600.,flag(bbz(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
ss = stop_mark*3600.-600.
ee = stop_mark*3600.+600.
if ss lt 0 then ss=0
if ee gt 86399 then ee=86399
plot,t(ss:ee)/3600.,flag(bbx(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
plot,t(ss:ee)/3600.,flag(bby(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
plot,t(ss:ee)/3600.,flag(bbz(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2
endif else begin
if keyword_set(oplot_only) then begin
!p.multi=[3,1,3,2]
ss = ss*3600L
ee = ee*3600L-1
plot,t(ss:ee)/3600.,flag(bx(ss:ee)),max_val=100000,$
/xstyle,/ystyle,/nodata
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
plot,t(ss:ee)/3600.,flag(by(ss:ee)),max_val=100000,$
/xstyle,/ystyle,/nodata
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
plot,t(ss:ee)/3600.,flag(bz(ss:ee)),max_val=100000,$
/xstyle,/ystyle,/nodata
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
endif else begin
ss = ss*3600L
ee = ee*3600L-1
plot,t(ss:ee)/3600.,flag(bx(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
plot,t(ss:ee)/3600.,flag(by(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
plot,t(ss:ee)/3600.,flag(bz(ss:ee)),max_val=100000,$
/xstyle,/ystyle
oplot,[start_mark,start_mark],[-90000,90000],linestyle=2,color=20
oplot,[stop_mark,stop_mark],[-90000,90000],linestyle=2,color=140
endelse
endelse
!p.multi=0
end

