[ncl-talk] Coefficient_of Divergence

Kunal Bali kunal.bali9 at gmail.com
Tue Nov 7 13:32:09 MST 2017


Thanks for suggesting this.

Actually, I am trying to calculate the COD at each grid cell.

So as you suggested


*DATA_SINGLE_3D = conform(data_subset, data_single, 0)    ; it worked*



*Variable: DATA_SINGLE_3DType: floatTotal Size: 7824960 bytes
1956240 valuesNumber of Dimensions: 3Dimensions and sizes: [3] x [660] x
[988]Coordinates: Number Of Attributes: 1  _FillValue : -28672*
step 1:
CoD1 = ((DATA_SINGLE_3D - data_subset)/(DATA_SINGLE_3D+ data_subset))^2
   printVarSummary(CoD1)
   printMinMax(CoD1, 0)

*Variable: CoD1*
*Type: float*
*Total Size: 7824960 bytes*
*            1956240 values*
*Number of Dimensions: 3*
*Dimensions and sizes: [3] x [660] x [988]*
*Coordinates: *
*Number Of Attributes: 1*
*  _FillValue : -28672*
*(0) min=0   max=0.961394*


step 2:

   CoD2 = sum(CoD1)/3
   printVarSummary(CoD2)
   printMinMax(CoD2, 0)

*Variable: CoD2*
*Type: float*
*Total Size: 4 bytes*
*            1 values*
*Number of Dimensions: 1*
*Dimensions and sizes: [1]*
*Coordinates: *
*(0) min=20691.8   max=20691.8   --------> values are very high? and also
it's not giving at each grid cell, because of that I can't calculate the
sqrt in the next step*


step 3:

  CoD3 = sqrt(CoD2)
 printVarSummary(CoD3)
 printMinMax(CoD2, 0)


The final values are coming very high. It should be less than 0.3 at each
grid cell.

regards
Kunal Bali





On Wed, Nov 8, 2017 at 1:18 AM, Dennis Shea <shea at ucar.edu> wrote:

> 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
> 'array conformance' . Please see and carefully read:
>
> 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...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171108/f8cf1824/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: COD.png
Type: image/png
Size: 34015 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171108/f8cf1824/attachment.png>


More information about the ncl-talk mailing list