;$Id: read_data.pro,v 1.14 2016/05/06 01:21:45 brandenb Exp $
;
;sed_data = read_csv(testfile, HEADER=SedHeader, N_TABLE_HEADER=1, TABLE_HEADER=SedTableHeader)
;
;  Here are some of the directory and files that I have looked at.
;
;  The first ones were those where we moved the detector across the disk.
;
dir='data/April14_11h/'
name='Olivia_Peter_140414_massive_sunspot' & dr=+.35
name='Olivia_Peter_140414_trial_5' & dr=+.35
dir='data/April_22_11h/'
name='Max_Kourtney_160422_trial_2_clear' & dr=+.35
name='Max_Kourtney_160422_trial_3_clear' & dr=+.35
name='Max_Kourtney_160422_trial_6_clear' & dr=+.35
name='Max_Kourtney_160422_trial_4_clear' & dr=-.35
;
;  These ones are those where we led to Sun pass across the detector.
;
dir='data/March11_1h/'
dir='data/March11_11h/'
name='Mohira_160311_trial_4' & dr=-.4
name='Sashank_Kyle_160311_trial_4' & dr=-.0
;
dir='data/March10_12h/'
name='Rachel_161310_trial_2' & dr=-.05
name='Rachel_Brandon_161310_trial_3' & dr=-.05
name='Rachel_Brandon_1613310_trial_4_27parts' & dr=-.65
name='Rachel_Brandon_161310_trial_5_25parts' & dr=.2
name='Rachel_Brandon_161310_trial_6_27parts' & dr=-.7
name='Rachel_161310_trial_1' & dr=+.35
;
;  reading the data
;
default,iread,0
if iread eq 0 then begin
  ext='.csv'
  file=dir+name+ext
  read_csv,file,aa,n_lines_head=1
  iread=1
endif
;
;  Stop here. The rest is not needed when running XX
;
stop
s=size(aa)
nruns=s[1]/2
nlam=s[2]
a=reform(float(aa),2,nruns,nlam)
;
nm=1d-9  ;(nm)
llam=reform(a(0,0,*))*nm
ii=reform(a(1,*,*))
;
;plot,llam,llam*0+[0,1]
;for iruns=0,nruns-1 do begin
;  oplot,llam,ii(iruns,*)
;endfor
;
;for ilam=0,nlam-1 do begin
;  plot,ii(*,ilam),yr=[0,1]
;  wait,.1 
;endfor
;
;  frequency integration
;
lllam=spread(llam,[0],[nruns])
iii1=total(ii/lllam^2,2)
iii2=total(ii,2)
;
print,nruns
r0=(nruns-1.)/2.
r00=r0*.92
;
r=findgen(nruns)-r0
r1=r-dr & good1=where(r1 > 0.)
r2=r+dr & good2=where(r2 > 0.)
;
!p.multi=[0,1,2]
plot,r1(good1)/r00,iii1(good1),yst=0,xr=[0,1]
oplot,r2(good2)/r00,(reverse(iii1))(good2),col=122,li=2
;
mu1=sqrt(1.-(r1(good1)/r00)^2)
mu2=sqrt(1.-(r2(good2)/r00)^2)
plot,mu1,iii1(good1),yst=0,xr=[1,0]
oplot,mu2,(reverse(iii1))(good2),col=122,li=2
oplot,[0,1],[.4,1]*1.15e15,col=188
;
END