# [ncl-talk] inverse weighted distance

Kunal Bali kunal.bali9 at gmail.com
Sat Oct 13 01:19:07 MDT 2018

```Dear NCL users,

I need to calculate the inverse weighted distance according to the attached
figure

The formula is
*xAvg = SUM[X/w]/SUM[1/w]*.  equation (1)

So first I need to calculate the distance from surrounding grid cells to
the receptor cell

receptor cell coordinates
latz = (/23.285/)
lonz = (/77.276/)

I don't know how to calculate this distance from single receptor site to
its surroundings grid cells. Surrounding grid cells spread ~500 km.

I have calculated the *X* here (which is a coefficient of divergence)

and the coefficient of divergence is calculated as
;-----calculation of the coefficient of divergence
DATA_SINGLE_3D = conform(data_subset, data_single, 0)
x1 = (DATA_SINGLE_3D - data_subset)
x2 = (DATA_SINGLE_3D + data_subset)
CoD1   = (x1/where(x2.ne.0,x2,x2 at _FillValue))^2

CoD2 = dim_avg_n_Wrap(CoD1, 0)    ; (nlat,mlon)
CoD_final = sqrt(CoD2)

So please provide some information on that. I have attached the script here.

regards
---
Kunal Bali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181013/497a3c3e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inverse_weighted_distance.jpg
Type: image/jpeg
Size: 129449 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181013/497a3c3e/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widst_iiserb_pm_cod.ncl
Type: application/octet-stream
Size: 2531 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181013/497a3c3e/attachment.obj>
```