# 5 Range bias correction

In the previous section we have explored vertical integration of vertical profiles (`vp`

’s). In this paragraph we will generalize vertical integration to entire radar images (`ppi`

’s). To do that properly, we will account for the changing beam shape of the radar with range.

First, let’s examine the beam shape of the lowest elevation scan of the radar, which is typically around 0.5 degrees.

```
# define ranges from 0 to 2500000 meter (250 km), in steps of 100 m:
<- seq(0, 250000, 100)
range
# plot the beam height of the 0.5 degree elevation beam:
plot(range, beam_height(range, 0.5), ylab = "beam height [m]", xlab = "range [m]", type='l')
# let's add the lower and upper altitude of the beam, as determined by the beam width:
points(range, beam_height(range, 0.5)-beam_width(range)/2, type='l',lty=3)
points(range, beam_height(range, 0.5)+beam_width(range)/2, type='l',lty=3)
```

We will start with downloading a polar volume and processing it into a profile:

## 5.1 Processing a polar volume into a profile

```
# download a polar volume for the KBRO radar in Brownsville, TX
download_pvolfiles(date_min=as.POSIXct("2017-05-14 05:50:00"), date_max=as.POSIXct("2017-05-14 06:00:00"), radar="KBRO", directory="./data_pvol")
# Load all the polar volume filenames downloaded so far for the KBRO radar:
<- list.files("./data_pvol", recursive = TRUE, full.names = TRUE, pattern="KBRO")
my_pvolfiles # we will process the first one into a vp:
<- my_pvolfiles[1]
my_pvolfile # calculate the profile, using MistNet to remove precipitation:
# we calculate 60 layers of 50 meter width, so up to 30*100=3000 m.
<- calculate_vp(my_pvolfile, n_layer=60, h_layer=50, sd_vvp_threshold = 1) my_vp
```

**Exercise 10:** Plot the bird density in the vertical profile you just estimated and compare it with the plots above of the beam height and width of the lowest radar beam. At which approximate range do you expect the radar will no longer be able to resolve the altitude distribution of the migratory birds. And at which range will the radar start to overshoot the migration layer entirely?

To correct for the decreasing ability of the radar to resolve the altitude distributions of birds with range, we will make one important (and likely imperfect!) assumption:

**We assume that all birds within the image are distributed vertically according to the same relative vertical profile.**

This assumptions simplifies the problem, and allows us to estimate the spatial distribution of the birds, as we will explore in the next paragraph:

## 5.2 Range bias correction and vertical integration on a map

```
# We will use the piping operator %>% of magrittr package to
# execute multiple operations in one statement:
library(magrittr)
# first, load the polar volume:
%>% read_pvolfile() -> my_pvol
my_pvolfile # Next, let's calculate a PPI for the 1.5 degree elevation scan
# Finally, we calculated the vertically integrated PPI
<- integrate_to_ppi(pvol=my_pvol,vp=my_vp, res=1000) my_ppi_integrated
```

Next, we will compare the PPI for the 1.0 degree sweep and the vertically integrated PPI, to highlight the effect of the range correction and vertical integration. We will plot the log-transform of VID for a more direct comparison with the reflectivity factor DBZH, which is also logarithmic in bird density.

```
#
%>%
my_pvol get_scan(elev = 1.0) %>%
project_as_ppi(raster=raster::raster(my_ppi_integrated$data)) ->
my_ppi# let's take the logarithm of the vertically integrated density, so
# we can compare it more directly to DBZH, which is also a logarithmic quantity:
<- calculate_param(my_ppi_integrated, logVID=log(VID))
my_ppi_integrated # plot both ppi's:
plot(my_ppi)
plot(my_ppi_integrated, param="logVID", zlim=c(-10,10))
```

**Exercise 11:** Explain why we see concentric rings in the 1.0 degree sweep, and not in the vertically integrated PPI.