;PHASE_OUT_PLOT
;
;PURPOSE:
;	This script will take in a phase screen generated by turb2d.c (written
;	by Garret Jernigan) and generate a color image of that screen
;
;CALLING SEQUENCE:
;	phase_out_plot,


pro phase_scroll_plot

;DIMENSIONS OF PHASE SCREEN
phase_dim=1024
sub_sec=256

color_screen_sub=indgen(sub_sec,sub_sec,3)

atmosphere_dir='/afs/slac.stanford.edu/u/ki/lances/lsst_sim/atmosphere/'
color_screen=indgen(phase_dim,phase_dim,3)
openr,phase,atmosphere_dir+'phase.out',/get_lun
screen=read_binary(phase,data_dims=[phase_dim,phase_dim],data_type=4)

max_screen=max(screen)
min_screen=min(screen)

screen_val=floor(255*((screen-min_screen)/(max_screen-min_screen)))

loadct,36
tvlct,R,G,B,/get

color_screen(*,*,0)=r(screen_val)
color_screen(*,*,1)=g(screen_val)
color_screen(*,*,2)=b(screen_val)

for segment=0,200 do begin

  color_screen_sub[*,*,0]=color_screen[segment:segment+sub_sec-1,$
    segment:segment+sub_sec-1,0]
  color_screen_sub[*,*,1]=color_screen[segment:segment+sub_sec-1,$
    segment:segment+sub_sec-1,1]
  color_screen_sub[*,*,2]=color_screen[segment:segment+sub_sec-1,$
    segment:segment+sub_sec-1,2]
  wait,.001
  tv,congrid(color_screen_sub,1024,1024,3),true=3
		
endfor
stop

end

