[ncl-talk] Taking ratio of precipitation dataset

Rick Brownrigg brownrig at ucar.edu
Tue Jan 5 18:41:37 MST 2016

```Hi Amit,

As was pointed out to me by one of my colleagues, you want to remove the
calls to "any()" in the where statement I gave previously; otherwise,
you'll still get differences everywhere.

Rick

On Tue, Jan 5, 2016 at 4:20 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:

> Offhand, it seems like you want to use the where() function, rather than
> an if/else coupled with any():
>
> http://ncl.ucar.edu/Document/Functions/Built-in/where.shtml
>
>
> Something like (untested):
>
> output = where((any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)), d-b, d/b)
>
>
> On Tue, Jan 5, 2016 at 4:10 PM, amit timilsina <
> timilsinaamit87 at huskers.unl.edu> wrote:
>
>> Respected all,
>>
>> I would like to take ratio and differences of variable precipitation(pr)
>> in such way that if both the values for particular day is positive or
>> greater than zero, I want to take ratio. If one of the values, either
>> denominator or numerator, is zero, then I would like to take differences.
>> Here is my code:
>> ncl 0>
>> ncl 1> b=a->pr
>> ncl 3> d=a->pr
>> ncl 4> if (any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)) then
>> ncl 5> output = (d-b)
>> ncl 6> else
>> ncl 7> ouput = d/b
>> ncl 8> end if
>>
>> This output gives me only differences, not a combination of both. Is it
>> possible to put any flag to know whether we have considered differences or
>> ratio at each grid level? I have attached printVarSummary for further
>> information.
>>
>>
>>
>>
>> PhD student
>> School of Natural Resources,UNL
>>
>> _______________________________________________
>> 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/20160105/6ba27c25/attachment.html
```