[ncl-talk] inverse weighted distance

Dennis Shea shea at ucar.edu
Mon Oct 15 19:44:34 MDT 2018


I guess I do not understand:

  latz  = (/23.285/)
  lonz  = (/77.276/)

  nlat  = 2
  mlon  = 3
  lat2d = *random_uniform*( 15, 30, (/nlat,mlon/))
  lon2d = *random_uniform*( 50, 90, (/nlat,mlon/))

  print(lat2d)
  print("====")
  print(lon2d)
  print("====")

;;  abs(iu) = 1   ; return the distance in radians
;;          = 2   ; return the distance in degrees
;;          = 3   ; return the distance in meters
;;          = 4   ; return the distance in kilometers
  iu   = 2
  npts = 2        ; beginning and end
  gcdist= *gc_latlon*(latz,lonz, lat2d,lon2d, npts,iu)
  print(gcdist)
  print("====")
                                  ; For 'fun' ; Pythagorean theorem
                                  ; Not for sphere but ... crude approx for
small distances
  dlat = *abs*(lat2d - latz)
  dlon = *abs*(lon2d - lonz)
  dist = *sqrt*(dlat^2 + dlon^2)

  print(latz+"  "+lonz+"  "+lat2d+"  "+lon2d+" : "+*gcdist*+" : "+dist)

=======
[snip]


























*Variable: gcdistType: floatTotal Size: 24 bytes            6 valuesNumber
of Dimensions: 2Dimensions and sizes:    [2] x [3]Coordinates: Number Of
Attributes: 4  units :    degrees  gclon :    <ARRAY of 12 elements>  gclat
:    <ARRAY of 12 elements>  spacing :    ( 5.50189, 6.191937, 13.16254,
13.33037, 8.464802, 14.25519 )(0,0)    5.50189(0,1)    6.191937(0,2)
13.16254(1,0)    13.33037(1,1)    8.464802(1,2)    14.25519(0)
====(0,0)    23.285  77.276  19.8557  72.6484 : 5.50189 : 5.75974(0,1)
23.285  77.276  19.8659  82.8288 : 6.19194 : 6.52104(0,2)    23.285
77.276  22.4008  63.0198 : 13.1625 : 14.2836(1,0)    23.285  77.276
19.3309  63.6032 : 13.3304 : 14.2331(1,1)    23.285  77.276  20.2951
85.8071 : 8.4648 : 9.03983(1,2)    23.285  77.276  17.3094  63.464 :
14.2552 : 15.0492*

On Mon, Oct 15, 2018 at 3:34 AM Kunal Bali <kunal.bali9 at gmail.com> wrote:

> 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
>>>
>> _______________________________________________
> 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/696a2531/attachment.html>


More information about the ncl-talk mailing list