# [ncl-talk] Coefficient_of Divergence

Dennis Shea shea at ucar.edu
Tue Nov 7 12:48:39 MST 2017

```If you have a one-dimensional array (1D; eg: a 'time series') and a
three-dimensional array (3D; eg: time series at multiple grid points), you
*must* make the arrays 'conformant' for an array calculation

You have:
CoD1 = ((data_single(:) - data_subset(:,:,:))/(data_single(:) +
data_subset(:,:,:)))^2

You did not include a 'printVarSummary' of these variables. Assuming
data_single(ntim) and data_subset(ntim,nlat,mlon) then you must replicate
(aka, propogate) the 1D array to the 3D array size. In NCL, this is called

https://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml
https://www.ncl.ucar.edu/Document/Functions/Built-in/conform_dims.shtml

---
DATA_SINGLE_3D = conform(data_subset, data_single, 0)    ;
(ntim,nlat,mlon)
printVarSummary(DATA_SINGLE_3D)   ; Look at data

Do *not* use (:,:,:) in a computation... this is inefficient.

CoD1 = ((DATA_SINGLE_3D - data_subset)/(DATA_SINGLE_3D+ data_subset))^2
printVarSummary(CoD1)
printMinMax(CoD1, 0)

On Tue, Nov 7, 2017 at 11:15 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:

> Dear NCL user
>
> Suppose, I have 2 datasets
> e.g.
>
> data1 = of single point lat & lon (e.g 28N, 72E) with time steps 365
> (having filling values)
> data2 = of grid box (24-32N, 68-76E) with time steps 365  (having filling
> values)
>
> Now I want to calculate the CoD from one single point to 400km grid box
> area and then lot the spatial map of the calculated product.
>
> Formula for CoD is GIVEN BELOW
> ​
>
> So I calculated in NCL as
>
> CoD1 = ((data1 - data2)/(data1 + data2))^2
> CoD_final = (sqrt(sum(CoD1)))/3
>
> please let me know is it the right way to do?
>
> I tried to plot the final product CoD_final with the attached script, but
> error comes as
>
> fatal:Minus: Number of dimensions do not match, can't continue
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 116 in
> file plot.ncl
>
>
>
> 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...