# Re: [idvusers] Help with Averaging NexRad scans over time.

```

Tom Whittaker wrote:
```
```The "angles" are the azimuth angles that Don Murray mentioned.  Since
each time might have a different structure (as Don said, one starting
at 170 degrees and the next at 176), you may have difficulties with
the resampling.
```
```
Indeed - thanks the for clarification. I keep thinking angles in terms of up and
not to the left or right. ;)

```
```The "rule" for resampling when combining data is this:  The coordinate
system of the result will be the coordinate system of the first-named
variable.  These means that when summing up using that little code
snippet, an attempt will be made to resample all the data to the
coordinates of "g[0]".
```
```
ok - so then let me know if this is possible:

I assume we are agreed on what a "gate" is....

Set up two arrays of two dimensions each (az, ra). Range wants to be even km for
REF, of course. Az can be any resolution. Even degrees (0-359) is convenient and
is assumed below. The two arrays hold the data for averaging one elevation for
>1 scan (so two dimensions are enough, but that is a detail).

SumZ    Holds the sum of Z (not dBZ) for all gates and portions of gates that
fall in that azimuth and range.
N       Holds the number of gates that have contributed to SumZ. This is not
usually an integer.

Most Nexrad gates will have azimuths that are not even integers. (An azimuth
such as 15.000 degrees is an edge case in the coding.) The procedure is to
convert each range gate's dBZ value to Z and compute what two SumZ azimuths it
overlaps. Then run along the ranges. Add z*p and z*(1-p) to the two elements of
SumZ. Add p and (1-p) to the two elements of N.

After all the desired scans have been summed in this way, divide SumZ by N to
get average Z and convert to dBZ for displaying.

Can that be done in IDV?

-Ben

```