# [ncl-talk] inverse weighted distance

Kunal Bali kunal.bali9 at gmail.com
Mon Oct 15 03:34:04 MDT 2018

```Dear Dennis Sir,
Thanks for the information. I have some query regarding the gc_latlon
function/

This functions says "*Finds the great circle distance (true surface
distance) between two points on the globe and interpolates points along the
great circle*"

But my CoD output was in a rectangular box. So will this function be useful
for my rectangular box. and also I don't want to interpolate the points
along the rectangular box. I want to calculate the distance of the given
actual points/coordinates.

However, I am not getting the desired output from here,
I used

dist = gc_latlon(latz,lonz,latv,lonv,2,4)
print(dist)

But it's not giving the value at every dimension size
e.g. Dimensions and sizes: [641] x [641]
So I need the distance at this dimension size as well.

ALSO used,

gcdist = gc_latlon(latz,lonz, latv,lonv, npts,2)

print (gcdist)
print (gcdist at gclat+"  "+gcdist at gclon )  ; print the lats/lons

---
Kunal Bali

On Mon, Oct 15, 2018 at 5:06 AM Dennis Shea <shea at ucar.edu> wrote:

> Distance:
> *http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_latlon.shtml*
> <http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_latlon.shtml>
>
> On Sat, Oct 13, 2018 at 1:19 AM Kunal Bali <kunal.bali9 at gmail.com> wrote:
>
>> 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
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181015/70ba7848/attachment.html>
```