;xy_offsets
;
;PURPOSE:
;	This script will return the difference in coordinates between a 
;	ShackHartman image centroid and the corresponding point on the 
;	reference grid
;
;	Since the center of the grid seems to be drifting 

pro cn_full_log_jpegs,Date=Date,stats_directory=stats_directory,$
	x_center_file=x_center_file,y_center_file=y_center_file,$
	depth=depth,x_off=x_off,y_off=y_off


If (not keyword_set(Date)) then Date='10'
If (not keyword_set(stats_directory)) then stats_directory='stats'
If (not keyword_set(x_center_file)) then x_center_file='x_centers.txt'
If (not keyword_set(y_center_file)) then y_center_file='y_centers.txt'
If (not keyword_set(depth)) then depth=1
If (not keyword_set(postscript_dir)) then postscript_dir='postscripts'
If (not keyword_set(x_off)) then x_off=0
If (not keyword_set(y_off)) then y_off=0

stats_directory='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$
	  '/ShackHartman/'+stats_directory+'/'
postscript_dir='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$
          '/ShackHartman/'+postscript_dir+'/'
Cor_directory='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$
          '/ShackHartman/correlations/'
jpeg_dir='/a/pippin01/Volumes/u08/lsst/CPanalysis/2005-05-'+Date+$
          '/ShackHartman/jpegs/'

num=25
Cxt_means=fltarr(num,depth)
Cxl_means=fltarr(num,depth)
Cyl_means=fltarr(num,depth)
Cyt_means=fltarr(num,depth)

for m=0, depth-1 do begin
	
	
     readcol,stats_directory+'Depth_'+string(strtrim(m,2))+'Correlations.ps',$
     Cxl,Cxt,Cyl,Cyt,format='f,f,f,f'
     Cxt_means(*,m)=cxt
     Cxl_means(*,m)=cxl
     Cyl_means(*,m)=cyl
     Cyt_means(*,m)=cyt

endfor

set_plot,'Z'

loadct,39                       ;load color table 39
device, set_font='Courier'
device,set_resolution=[800,600]
!p.charsize=1
!p.charthick=1.5
!x.thick=2
!y.thick=2
!p.thick=3
!p.color=0

white='FFFFFF'x
black='000000'x

items_time=['t=0']
sym_time=[1]
items_k_tran=['Data Points','n!e-7/32!n','n!e-13/64!n','n!e-27/128!n']
sym_k_tran=[1,0,0,0]
line_k_tran=[0,1,2,3]
items_k_lon=['Data Points','n!e-1/3!n']
sym_k_long=[0,1]
colors_time=[0]



;*************FIRST PLOT
!P.multi=[0,2,2]

plot,Cxt_means(*,0),psym=1,title="Transverse X",$
               xtitle="n",ytitle="Covariance (Pixels Squared)",$
               background=white,color=black,$
               yrange=[1e-3,1e1],$
               position=[0.5,0.55,0.8,0.9], /ylog

;Over Plot the various separations in time and also generate legends

for i=1,depth-1 do begin

        oplot,Cxt_means(*,i),psym=1,color=20*i
        sym_time=[sym_time,1]
        items_time=[items_time,string(strtrim(i*7,2))+' seconds']
        colors_time=[colors_time,20*i]

endfor

;***************FIFTH PLOT
plot,Cxl_means(*,0),psym=1,title="Longitudinal X",$
               xtitle="n",ytitle="Covariance (Pixels Squared)",$
               background=white,color=black,$
               yrange=[1e-3,1e1],$
                position=[0.1,0.55,0.4,0.9],/ylog

for i=1,depth-1 do begin

        oplot,Cxl_means(*,i),psym=1,color=20*i

endfor


;**************NINTH PLOT
plot,Cyt_means(*,0),psym=1,title="Transverse Y",$
               xtitle="n",ytitle="Covariance (Pixels Squared)",$
               background=white,color=black,$
               yrange=[1e-3,1e1],$
                position=[0.5,0.1,0.8,0.45],/ylog

for i=1,depth-1 do begin

        oplot,Cyt_means(*,i),psym=1,color=20*i

endfor

;*************THIRTEENTH
plot,Cyl_means(*,0),psym=1,title="Longitudinal Y",$
               xtitle="n",ytitle="Covariance (Pixels Squared)",$
               background=white,color=black,$
               yrange=[1e-3,1e1],$
               position=[0.1,0.1,0.40,0.45],/ylog

for i=1,depth-1 do begin

        oplot,Cyl_means(*,i),psym=1,color=20*i

endfor

legend,items_time,psym=sym_time,position=[.82,.9],/normal,colors=colors_time


jpgimg=tvrd()
tvlct,reds,greens,blues,/get
write_png,jpeg_dir+'Log_time_correlations'+Date+'.png',$
        jpgimg,reds,greens,blues


erase

device,/close
set_plot,'X'


end


