;PURPOSE:
;    This function will take an a 4x25xN array of Covariances and plot them.
;    
;INPUTS:
;    EllipticityArr:
;      Covariances(0,*,n)= X longitudinal
;      Covariances(0,*,n)= X transverse
;      Covariances(0,*,n)= Y longitudinal
;      Covariances(0,*,n)= Y transverse
;    PlotStyle:
;      0 = Plot to X Windwow
;      1 = Plot a PNG file
;
function plot_covariance_ff, ScreenCovarFileName, SoarCovarFileNames,$
	 PlotStyle, ParamStr, PostScriptDir

white='FFFFFF'x
black='000000'x
red='FF0000'x

readcol,ScreenCovarFileName,$
    Cxl,Cxt,Cyl,Cyt,$
    format='f,f,f,f'

!P.multi=[0,1,1]

plot,Cxt,psym=1,title="Transverse correlation along X direction",$
           xtitle="n",ytitle="Covariance",$
           background=white,color=black,$
           yrange=[-1,1],$
           POSITION=[0.10,0.10,0.9,0.9]
oplot,Cxl,psym=2,color=80
oplot,Cyt,psym=4,color=160
oplot,Cyl,psym=5,color=240
itemsC=['Transverse X', 'Longitudinal X', 'Transverse Y', 'Longitudinal Y']
psymC=[1,2,4,5]
colorsC=[0,80,160,240]
legend,itemsC,psym=psymC,colors=colorsC,pos=[0.7,0.7],/norm

if PlotStyle eq 0 then stop
Date=['10','11','12']
for Datei =0, 2 do begin
 readcol,SOARCovarFileNames(Datei),$
    Cxl,Cxt,Cyl,Cyt,$
    format='f,f,f,f'
 
 plot,Cxt,psym=1,title="Night of May "+Date(Datei),$
           xtitle="n",ytitle="Covariance",$
           background=white,color=black,$
           yrange=[-1,1],$
           POSITION=[0.10,0.10,0.9,0.9]
 oplot,Cxl,psym=2,color=80
 oplot,Cyt,psym=4,color=160
 oplot,Cyl,psym=5,color=240
 itemsC=['Transverse X', 'Longitudinal X', 'Transverse Y', 'Longitudinal Y']
 psymC=[1,2,4,5]
 colorsC=[0,80,160,240]
 legend,itemsC,psym=psymC,colors=colorsC,pos=[0.7,0.7],/norm

if PlotStyle eq 1 then begin

  jpgimg=tvrd()
  tvlct,reds,greens,blues,/get
  write_png,PostScriptDir+ParamStr+'Covariance.png',$
  jpgimg,reds,greens,blues

  erase
endif

endfor
return,1
end


