[ncl-talk] Taking ratio of precipitation dataset

amit timilsina timilsinaamit87 at huskers.unl.edu
Wed Jan 6 07:50:16 MST 2016


Thank you so much

I tried with following syntax.If it has properly considered first condition expression, the error "fatal:divide: Division by 0" would not have been appeared.


ncl 49> output = where((b(:,:,:).eq.0 .or. d(:,:,:).eq.0), (d-b), (d/b))

fatal:divide: Division by 0, Can't continue

fatal:Div: operator failed, can't continue

fatal:["Execute.c":8573]:Execute: Error occurred at or near line 49



Regards,

Amit Prasad Timilsina

School of Natural Resources,UNL



________________________________
From: Rick Brownrigg <brownrig at ucar.edu>
Sent: Tuesday, January 5, 2016 7:41 PM
To: amit timilsina
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Taking ratio of precipitation dataset

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<mailto: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<mailto: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> a=addfile("pr_day_MRI-CGCM3_decadal2005_r1i1p1_20060101-20351231.nc","r")
ncl 1> b=a->pr
ncl 2> c=addfile("pr_day_MRI-CGCM3_rcp45_r1i1p1_20060101-20351231.nc","r")
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.

Thank you in advance



Amit Prasad Timilsina
PhD student
School of Natural Resources,UNL

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto: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/20160106/139965fa/attachment.html 


More information about the ncl-talk mailing list