pro plot_ind_mass_cn2,min1=min1,hr1=hr1,date1=date1,min2=min2,hr2=hr2,date2=date2,night=night

If (not keyword_set(night)) then night='10'
If (not keyword_set(min1)) then min1=50
If (not keyword_set(hr1)) then hr1=22
If (not keyword_set(date1)) then date1=10
If (not keyword_set(min2)) then min2=30
If (not keyword_set(hr2)) then hr2=3
If (not keyword_set(date2)) then date2=11


;Arrays Containing time separation
night10=fltarr(18,6)

;--------Min,hr,date,Min,hr,Date
If night eq '10' then begin
night10=[[27,22,10,39,22,10],$
	 [41,22,10,53,22,10],$
	 [54,22,10,7,23,10],$
	 [14,23,10,28,23,10],$
	 [29,23,10,42,23,10],$
	 [43,23,10,58,23,10],$
	 [6,00,11,20,00,11],$
	 [20,00,11,33,00,11],$
	 [45,00,11,58,00,11]$ 
	]
  letter=['hr5132a','hr5132b','hr5132c','hr5132d','hr5132e','hr5132f',$
          'hr5132g','hr5132h','hr5132i']

endif else if night eq '11' then begin
night10=[[6,23,11,18,23,11],$
	 [20,23,11,32,23,11],$
	 [33,23,11,45,23,11],$
	 [54,23,11,08,00,12],$
	 [08,00,12,20,00,12],$
	 [21,00,12,33,00,12],$
	 [57,00,12,09,01,12],$
	 [11,01,12,27,01,12],$
	 [29,01,12,41,01,12],$
	 [42,01,12,54,01,12]]
 letter=['h5132g','h5132h','h5132i','hr5132a','hr5132b','hr5132c','hr5132d',$
          'hr5132e','hr5132f','hr5132g','hr5132h']

endif else if night eq '12' then begin
night10=[[29,23,12,41,23,12],$
	 [42,23,12,54,23,12],$
	 [56,23,12,08,00,13],$
	 [26,00,13,38,00,13],$
	 [40,00,13,52,00,13],$
	 [53,00,13,04,01,12],$
	 [17,01,13,29,01,13],$
	 [32,01,13,44,01,13],$
  	 [48,01,13,00,02,13]$
	 ]
 letter=['hr5132a','hr5132b','hr5132c','hr5132d','hr5132e','hr5132f',$
           'hr5132g','hr5132h','hr5132i']

endif

stats_directory='/nfs/slac/g/ki/ki08/lsst/CPanalysis/2005-05-'+Night+$
          '/ShackHartman/stats/'

set_plot,'ps'
device,filename='/nfs/slac/g/ki/ki08/lsst/CPanalysis/2005-05-'+night+'/ShackHartman/distorted_postscripts/wind_mass_dimm.ps'
loadct,39                       ;load color table 39
device,/color                   ;allow color on the postscript
device,ysize=8.5,/inches        ;Height of plot in y
device,xsize=11.0,/inches        ;Width of plot in x
device,yoffset=1.0,/inches      ;Y position of lower left corner


for i=0, N_elements(night10(0,*))-1  do begin


!p.multi=[0,2,2]

MASS=return_mass_spread(night10(0,i),night10(1,i),night10(2,i),$
		night10(3,i),night10(4,i),night10(5,i))
MASS_points=N_elements(MASS(0,*))
alt05=fltarr(MASS_points)+1
alt1=fltarr(MASS_points)+2
alt2=fltarr(MASS_points)+3
alt4=fltarr(MASS_points)+4
alt8=fltarr(MASS_points)+5
alt16=fltarr(MASS_points)+6
plot,MASS(12,*),alt05,psym=0,ytickname=[0,0.5,1,2,4,8,16,32],ytickinterval=1,$
        yrange=[0,7],xtickunits='time',color='000000'x,background='FFFFFF'x
axis,.47,0,0,yaxis=1,ytitle='CN2dh (10^-11 m 1/3)',/normal,color='000000'x,$
	ytickinterval=40,ystyle=3,ytickname=['']
errplot,MASS(12,*),1-(10^11.*MASS(0,*)/2),1+(10^11.*MASS(0,*)/2),color='000000'x
oplot,MASS(12,*),alt1,psym=0,color=40
errplot,MASS(12,*),2-(10^11.*MASS(1,*)/2),2+(10^11.*MASS(1,*)/2),color=40
oplot,MASS(12,*),alt2,psym=0,color=80
errplot,MASS(12,*),3-(10^11.*MASS(2,*)/2),3+(10^11.*MASS(2,*)/2),color=80
oplot,MASS(12,*),alt4,psym=0,color=120
errplot,MASS(12,*),4-(10^11.*MASS(3,*)/2),4+(10^11.*MASS(3,*)/2),color=120
oplot,MASS(12,*),alt8,psym=0,color=160
errplot,MASS(12,*),5-(10^11.*MASS(4,*)/2),5+(10^11.*MASS(4,*)/2),color=160
oplot,MASS(12,*),alt16,psym=0,color=200
errplot,MASS(12,*),6-(10^11.*MASS(4,*)/2),6+(10^11.*MASS(4,*)/2),color=200

DIMM=return_dimm(night10(0,i),night10(1,i),night10(2,i),$
                night10(3,i),night10(4,i),night10(5,i))


plot,DIMM(4,*),DIMM(0,*),psym=1,xtickunits='time',$
	background='FFFFFF'x,color='000000'x,$
	xtitle='Date & Time (UT)',ytitle='Seeing (arcseconds)'

WIND=return_wind(night10(0,i),night10(1,i),night10(2,i),$
                night10(3,i),night10(4,i),night10(5,i))


plot,WIND(2,*),WIND(1,*),psym=1,xtickunits='time',$
        background='FFFFFF'x,color='000000'x,$
	ytitle='Direction',xtitle='Date & Time (UT)'

plot,WIND(2,*),WIND(0,*),psym=1,xtickunits='time',$
        background='FFFFFF'x,color='000000'x,$
        ytitle='Speed (m/s)',xtitle='Date & Time (UT)'

xyouts,.2,.98,'Cerro Pachon 2005-05-'+$
	strtrim(night10(2,i),2)+' '+strtrim(night10(1,i),2)+':'+$
	strtrim(night10(0,i),2)+$
        ':00 -- 2005-05-'+$
	strtrim(night10(5,i),2)+' '+strtrim(night10(4,i),2)+':'+$
        strtrim(night10(3,i),2)+':00     ('+letter(i)+')',$
	color='000000'x,/normal


wait,5

  stats_files=file_search(stats_directory+letter(i)+'*stats.txt',$
        count=num_stats_files)
  average_mag=fltarr(num_stats_files)
  for j=0, num_stats_files-1 do begin
    readcol,stats_files(j),magnitudes,format='x,x,x,x,x,f'
    average_mag(j)=10^(mean(magnitudes(where(magnitudes ne -1)))-12)
  endfor

  !p.multi=[0,1,1]
  plot,average_mag,background='FFFFFF'x,color='000000'x,$
	xtitle='File_number',ytitle='10^(Magnitude-12)',$
	psym=1
  xyouts,.2,.98,'Cerro Pachon 2005-05-'+$
        strtrim(night10(2,i),2)+' '+strtrim(night10(1,i),2)+':'+$
        strtrim(night10(0,i),2)+$
        ':00 -- 2005-05-'+$
        strtrim(night10(5,i),2)+' '+strtrim(night10(4,i),2)+':'+$
        strtrim(night10(3,i),2)+':00   ('+letter(i)+')',$
	color='000000'x,/normal
   
wait,5
endfor
device,/close

stop
end

