# 6 Part 6

## 6.1 Estimating beam propagation using radiosonde data

When radiosonde data are available, it is often adventageous to calculate beam propagation given observed refractive conditions of the atmosphere. The following code allows you to do just that using standard radiosonde files archived here http://weather.uwyo.edu/upperair/sounding.html

Letâ€™s read in several files from the KLWX radar station on different nights that were collected during the onset of nocturnal flight. The following code will chart the limits of the top and bottom of the beam as it travels out from the radar. The beam path using the observed atmospheric data (solid pink lines) is charted along with the beam path in a standard atmosphere (dashed black lines) with refraction following the 4/3 Earth radius model.

``````for (j in list.files(pattern="\\.htm\$")){

beamhtall<-data.frame(range=numeric(),bbeam=numeric(),mbeam=numeric(),tbeam=numeric(),elev=numeric())
###calculate refraction

elev<-0.50 #tilt angle of beam
range<- seq(from = 1, to=  100, by =0.5)
beamhtall<-data.frame(range=range,bbeam=NA,mbeam=NA,tbeam=NA,elev=elev)
#propagate top, middle, and bottom of beam
####if height<antht

####if heightb<antht

####otherwise

###more otherwise

###############################################################
####make ranges####

##############################################################
####now we're creating beam heights
bb\$range<-range
bb\$relrange<-bb\$range-bb\$prevrange
beamhtall[,1+mom]<-bb\$k*bb\$a*((cos(bb\$theta)/cos(bb\$theta+(bb\$relrange/(bb\$k*bb\$a))))-1)*1000+(bb\$hght-(bb\$thickness*1000))

}###end beam loop

beamhtall<-na.replace(beamhtall, 0)

#   calculate beamht for standard atmosphere
beamhtallstd<-beamht_std(range=range*1000, antht=antht, theta=elev, earthr=earthr)