pro lineofsight,flux,rr,wi2,wi3,with=with,temp=temp,density=density,radii=radii,model=model,lin=lin
;+
; NAME
;  lineofsight
;
; PURPOSE
;  Do a 
;
; CALLING SEQUENCE
;  lineofsight,model=model,/with,flux,rr,wi2,wi3
;
; INPUT
;  model : 1 = Polar Coronal Hole at Solar Max 
;        : 3 = Polar Coronal Hole at for Solar Min 
;        : 2 = Equatorial Coronal Hole at for Solar Min
;        : 0 = Quiet Corona - Temperatures inconsistent with SXT observations
;
;  temp  : temp (MK)
;  min_dist : Minimum radial extent of the coronal hole in solar radii
;
; OUTPUT
; flux :     The sxt flux in DN/sec/half res pixel, for the Al and 
;            Dagwood filters. SXT_FLUX(0,*) is the Al filter each element 
;            is for 0.01 Solar Radii, in the range 0-10 solar radii.
;            To plot results use rad=dindgen(1000)/100d and then
;            plot,rad,fl(0,*),ys=1,xr=[0.5,1.5],xs=1
;            oplot,rad,fl(1,*),linestyle=1
;
; OPTIONAL OUTPUT
;  none
; OPTIONAL KEYWORD INPUT
;  none	
; RESTRICTION
;  none
; HISTORY
; 22 April 97 Carl Foley
;-
; set up arrays and default values

if NOT keyword_set(radii) then begin
  radii= findgen(1000)/100.+1.
endif

if NOT keyword_set(density) then begin
  www=withbroe(radii,1)
  density=www(2,*)
print,'using Withbroes solar maximum polar coronal hole density values'
endif

if keyword_set(lin) then begin
  lin=2.-lin
print,'Doing the on disk limb brightening also!'
endif else begin
 lin=1.
endelse

if keyword_set(with) then begin
 dist=findgen(1000)/100.+1.
 www=withbroe(dist,model)
 flux2=sxt_flux(alog10(www(1,*)*1e6),2)*www(2,*)^2.
 flux3=sxt_flux(alog10(www(1,*)*1e6),3)*www(2,*)^2.
endif else begin
  www=fltarr(3,n_elements(radii))
  www(0,*)=radii
  www(1,*)=temp
  www(2,*)=density
 flux2=sxt_flux(alog10(www(1,*)*1e6),2)*www(2,*)^2.
 flux3=sxt_flux(alog10(www(1,*)*1e6),3)*www(2,*)^2.
endelse
print,'sorted flux'

flux3 = flux3 / 1e20
pix_em = 4d*gt_pix_size()^2 * 7.5e7^2 * 6.96e8
flux3 = flux3 *  pix_em
flux3 = flux3 / 1e24
print,'normalised flux'
flux2 = flux2 / 1e20
flux2 = flux2 *  pix_em
flux2 = flux2 / 1e24

los=fltarr(1000,lin*100)
radial,los,500,lin*100.-200.,rr
rr=rr/100.

print,'created grid'

wi2=rr*0.
wi3=rr*0.

rrr=rr
s=where(rr lt 1.)
rrr(s)=1.
for a=0,99 do wi2(*,a)=dspline(www(0,*),flux2,rrr(*,a),interp=0.)
print,'finished filter 2'
wi2(s)=0.
for a=0,99 do wi3(*,a)=dspline(www(0,*),flux3,rrr(*,a),interp=0.)
print,'finished filter 3'
wi3(s)=0.
flux=fltarr(2,100)
for a=0,99 do flux(0,a) = total(wi2(*,a))   
print,'almost finished'
for a=0,99 do flux(1,a) = total(wi3(*,a)) 
c=where(rr(500,*) lt 1.) 
flux(1,c)=flux(1,c)/2.
flux(0,c)=flux(0,c)/2.

end
