<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Atul,<br>
<br>
you have to prevent division by zero.<br>
<br>
B = B2-B1<br>
B = where(B .ne. 0, B, B@_FillValue)<br>
chpOnset = ((A2-A1)/B)<br>
print(chpOnset<br>
<br>
-Karin<br>
<br>
<div class="moz-cite-prefix">Am 10.09.19 um 09:31 schrieb Rashed
Mahmood via ncl-talk:<br>
</div>
<blockquote type="cite"
cite="mid:CAOmfQPpqsGUjtXX6jDrC5qO4qPEuYCnW1_otM66uCt84h9K81Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>The message is clear. You would need to decide what should
happen if any point of your dividing array has 0 value...</div>
<div><br>
</div>
<div>I would suggest that you make the dividing arrays
separately and use "where" function to handle grid points with
0 values. Please read documentation for "where" function:</div>
<div><a
href="https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtmlhttps://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml"
moz-do-not-send="true">https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtmlhttps://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml</a></div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2019 at 8:02
AM Atul Saini <<a href="mailto:atulsainimail@gmail.com"
moz-do-not-send="true">atulsainimail@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="auto">Yes, you are right there was some issues with
the data file now it's working fine. But after executing the
users function it's giving the message having issue you in
dividing by zero.
<div dir="auto">The code is as follows-</div>
<div dir="auto">
<div style="font-family:sans-serif;font-size:12.8px"
dir="auto"><b><span style="color:rgb(0,0,255)"><br>
While running the following code-</span></b></div>
<div style="font-family:sans-serif;font-size:12.8px"
dir="auto"><b><span style="color:rgb(0,0,255)"><br>
</span></b><span style="color:rgb(0,0,255)">a=addfile("Data_File.nc","r")<br>
x=a->tym(0:4,:,:)<br>
X=sqrt(x)<br>
y=a->rf(0:4,:,:)<br>
Y=sqrt(y)<br>
v=a->tym(5:9,:,:)<br>
V=sqrt(v)<br>
w=a->rf(5:9,:,:)<br>
W=sqrt(w)</span></div>
<span
style="font-family:sans-serif;font-size:12.8px;color:rgb(0,0,255)">A1=((dim_sum_n(y,0))*(dim_sum_n(X,0)))-(dim_sum_n(x,0))*(dim_sum_n(x*y,0))/(100*(dim_sum_n(X,0))-(sqrt(dim_sum_n(x,0))))<br>
<br>
A2=((dim_sum_n(w,0))*(dim_sum_n(V,0)))-(dim_sum_n(v,0))*(dim_sum_n(v*w,0))/(100*(dim_sum_n(V,0))-(sqrt(dim_sum_n(v,0))))<br>
<br>
B1=
(100*(dim_sum_n(x*y,0)))-(dim_sum_n(y,0))/(100*(dim_sum_n(X,0))-(sqrt(dim_sum_n(x,0))))<br>
<br>
B2=
(100*(dim_sum_n(v*w,0)))-(dim_sum_n(w,0))/(100*(dim_sum_n(V,0))-(sqrt(dim_sum_n(v,0))))<br>
<br>
chpOnset = ((A1-A2)/(B2-B1))<br>
print(chpOnset)</span>
<div style="font-family:sans-serif;font-size:12.8px"
dir="auto"><span style="color:rgb(255,0,0)"><br>
</span></div>
<div style="font-family:sans-serif;font-size:12.8px"
dir="auto"><b><span style="color:rgb(255,0,0)">I am
receiving the following error-</span></b></div>
<div style="font-family:sans-serif;font-size:12.8px"
dir="auto"><span style="color:rgb(0,0,255)"><span
style="color:rgb(255,0,0)">fatal:divide: Division by
0, Can't continue<br>
fatal:Div: operator failed, can't continue</span></span></div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2019, 17:04
Atul Saini <<a href="mailto:atulsainimail@gmail.com"
rel="noreferrer" target="_blank" moz-do-not-send="true">atulsainimail@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="auto">Ok, I will check and let you know.
<div dir="auto"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Sep 9, 2019,
17:04 Rashed Mahmood <<a
href="mailto:rashidcomsis@gmail.com" rel="noreferrer
noreferrer" target="_blank" moz-do-not-send="true">rashidcomsis@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px
0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div><br>
</div>
<div>Are you sure about the data file? Why got no
values for x min and max? Also why was the min and
max same value for X, 5050?</div>
<div><br>
</div>
<div>There is no problem with function, I am sure.
It's the data file that need to be checked
thoroughly? If you cannot find issue with the file
you would need provide the data file to the list.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> <br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Sep 9,
2019 at 1:26 PM Atul Saini <<a
href="mailto:atulsainimail@gmail.com"
rel="noreferrer noreferrer noreferrer"
target="_blank" moz-do-not-send="true">atulsainimail@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>I got the following answer-</div>
<div><br>
</div>
<div><b>ncl 6> printVarSummary(x)<br>
Variable: x<br>
Type: float<br>
Total Size: 6966000 bytes<br>
1741500 values<br>
Number of Dimensions: 3<br>
Dimensions and sizes: [time | 100] x [lat |
129] x [lon | 135]<br>
Coordinates: <br>
time: [ 1.. 100]<br>
lat: [6.5..38.5]<br>
lon: [66.5..100]<br>
Number Of Attributes: 3<br>
long_name : GRIDDED RAINFALL<br>
_FillValue : -999<br>
missing_value : -999<br>
ncl 7> printVarSummary(X)<br>
<br>
Variable: X<br>
Type: float<br>
Total Size: 69660 bytes<br>
17415 values<br>
Number of Dimensions: 2<br>
Dimensions and sizes: [129] x [135]<br>
Coordinates: <br>
Number Of Attributes: 1<br>
_FillValue : -999<br>
ncl 8> <br>
ncl 9> print(x@_FillValue)<br>
(0) -999<br>
ncl 10> print(X@_FillValue)<br>
(0) -999</b><br>
</div>
<div>
<div>
<div dir="ltr"
class="gmail-m_-3708797581685629908m_-4805696057802406657m_2488239289788832919m_3203185856048880024gmail-m_7355181456855553179m_-7590654089155577504gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div><font
size="4">Regards,</font></div>
<div><br>
</div>
<div><img
src="https://docs.google.com/uc?export=download&id=1flpEpH50fxgPRxFvuyiLu2A70K0UoFx-&revid=0Byj9ykpbAx3od3R4N016WWh0MnlGQ1JHUTg4Nk5HVmVMS2ZNPQ"
moz-do-not-send="true" width="304" height="116"><br>
</div>
<div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Sep 9,
2019 at 4:46 PM Rashed Mahmood <<a
href="mailto:rashidcomsis@gmail.com"
rel="noreferrer noreferrer noreferrer"
target="_blank" moz-do-not-send="true">rashidcomsis@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>Why there are no values for min and max
of x variable?<br>
</div>
<div>I suspect that there is something wrong
with your data file, however, you should
do some more checking... e.g. <br>
</div>
<div><br>
</div>
<div>printVarSummary(x)</div>
<div>printVarSummary(X)<br>
</div>
<div><br>
</div>
<div>print(x@_FillValue)</div>
<div>print(X@_FillValue)</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon,
Sep 9, 2019 at 1:11 PM Atul Saini <<a
href="mailto:atulsainimail@gmail.com"
rel="noreferrer noreferrer noreferrer"
target="_blank" moz-do-not-send="true">atulsainimail@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>Rashed sir,</div>
<div> It gives the
following answer-</div>
<div><br>
</div>
<div><b>ncl 4> printMinMax(x,True)<br>
(0) <br>
(0) GRIDDED RAINFALL<br>
ncl 5> printMinMax(X,True)<br>
(0) <br>
(0) min=5050 max=5050</b></div>
<div><br>
</div>
<div>
<div>
<div dir="ltr"
class="gmail-m_-3708797581685629908m_-4805696057802406657m_2488239289788832919m_3203185856048880024gmail-m_7355181456855553179gmail-m_-7590654089155577504gmail-m_-3405623909130104277gmail-m_-8636779149036519467gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div><font
size="4">Regards,</font></div>
<div><br>
</div>
<div><img
src="https://docs.google.com/uc?export=download&id=1flpEpH50fxgPRxFvuyiLu2A70K0UoFx-&revid=0Byj9ykpbAx3od3R4N016WWh0MnlGQ1JHUTg4Nk5HVmVMS2ZNPQ"
moz-do-not-send="true" width="304" height="116"><br>
</div>
<div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On
Mon, Sep 9, 2019 at 4:38 PM Rashed
Mahmood <<a
href="mailto:rashidcomsis@gmail.com"
rel="noreferrer noreferrer
noreferrer" target="_blank"
moz-do-not-send="true">rashidcomsis@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>I do not see any problem with
the lines you just posted. <br>
</div>
<div>Can you add following in the
above code you wrote and let me
know:</div>
<div><br>
</div>
<div>printMinMax(x,True)</div>
<div>printMinMax(X,True)</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On
Mon, Sep 9, 2019 at 12:18 PM Atul
Saini <<a
href="mailto:atulsainimail@gmail.com"
rel="noreferrer noreferrer
noreferrer" target="_blank"
moz-do-not-send="true">atulsainimail@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>Hello Rashed Sir,</div>
<div>
I used dim_sum_n but it could
not yield the required result
at each grid point. I want to
get the sum of the variable
through time for all the grid
points and therefore I used -</div>
<div><br>
</div>
<div><b>a=addfile("RFIM_1901_1902_days_rf_tym.nc","r")<br>
x=a->tym(0:99,:,:)<br>
X=dim_sum_n(x,0)</b></div>
<div><b>print(X)</b></div>
<div><b><br>
</b></div>
<div>Printing X doesn't provide
the correct result. Please
guide. Your reply is highly
appreciated.<br>
</div>
<div><b><br>
</b></div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr"
class="gmail-m_-3708797581685629908m_-4805696057802406657m_2488239289788832919m_3203185856048880024gmail-m_7355181456855553179gmail-m_-7590654089155577504gmail-m_-3405623909130104277gmail-m_-8636779149036519467gmail-m_587892381589848607gmail-m_-3604341541627214952gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div><font
size="4">Regards,</font></div>
<div><br>
</div>
<div><img
src="https://docs.google.com/uc?export=download&id=1flpEpH50fxgPRxFvuyiLu2A70K0UoFx-&revid=0Byj9ykpbAx3od3R4N016WWh0MnlGQ1JHUTg4Nk5HVmVMS2ZNPQ"
moz-do-not-send="true" width="304" height="116"><br>
</div>
<div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr"
class="gmail_attr">On Mon, Sep
9, 2019 at 2:58 PM Rashed
Mahmood <<a
href="mailto:rashidcomsis@gmail.com"
rel="noreferrer noreferrer
noreferrer" target="_blank"
moz-do-not-send="true">rashidcomsis@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>I think you want to use
dim_sum_n_wrap() or
dim_sum_n() functions
instead of using "sum".
"sum" would result in
total of everything for a
variable. See the docs at
the following link:<br>
</div>
<div><br>
</div>
<div><a
href="https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_sum_n.shtml"
rel="noreferrer
noreferrer noreferrer"
target="_blank"
moz-do-not-send="true">https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_sum_n.shtml</a></div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr"
class="gmail_attr">On Mon,
Sep 9, 2019 at 8:55 AM
Atul Saini via ncl-talk
<<a
href="mailto:ncl-talk@ucar.edu"
rel="noreferrer
noreferrer noreferrer"
target="_blank"
moz-do-not-send="true">ncl-talk@ucar.edu</a>>
wrote:<br>
</div>
<blockquote
class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px
solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>Hi NCL Talk,</div>
<div>
I am trying to
calculate the value
for each grid using
the function as
explained in the
script, but at the end
the result is one
value only. I want the
value at each grid
point.<span
style="background-color:rgb(111,168,220)"><b><span
style="background-color:rgb(252,229,205)"><span style="color:rgb(0,0,0)"></span></span></b></span></div>
<div><font size="2"><span
style="color:rgb(255,0,0)"><b>Script is as follows and datafile is
attached
herewith.</b></span></font></div>
<div><span
style="color:rgb(0,0,255)">;begin<br>
a=addfile("Data_File.nc","r")<br>
x=a->tym(0:4,:,:)<br>
y=a->rf(0:4,:,:)<br>
v=a->tym(5:9,:,:)<br>
w=a->rf(5:9,:,:)<br>
A1=
((sum(y))*(sum(sqrt(x)))-(sum(x))*(sum(x*y)))/(5*(sum(sqrt(x)))-(sqrt(sum(x))))<br>
B1=
(5*(sum(x*y))-(sum(x)*sum(y))/(5*(sum(sqrt(x)))-(sqrt(sum(x)))))<br>
A2=
((sum(w))*(sum(sqrt(v)))-(sum(v))*(sum(v*w)))/(5*(sum(sqrt(v)))-(sqrt(sum(v))))<br>
B2=
(5*(sum(v*w))-(sum(v)*sum(w))/(5*(sum(sqrt(v)))-(sqrt(sum(v)))))<br>
chpOnset =
((A1-A2)/(B2-B1))<br>
print(chpOnset)</span></div>
<div><span
style="color:rgb(0,0,255)"><font
size="2"><span
style="background-color:rgb(217,234,211)"><span
style="color:rgb(255,0,0)"><b>Please, help me to find out the mistake I
am making.
Your reply is
very important
to me. Thanks
in advance.</b></span></span></font></span></div>
<div>
<div dir="ltr"
class="gmail-m_-3708797581685629908m_-4805696057802406657m_2488239289788832919m_3203185856048880024gmail-m_7355181456855553179gmail-m_-7590654089155577504gmail-m_-3405623909130104277gmail-m_-8636779149036519467gmail-m_587892381589848607gmail-m_-3604341541627214952gmail-m_-6323195963944661163gmail-m_-1285333165725487570gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div><font
size="4">Regards,</font></div>
<div><br>
</div>
<div><img
src="https://docs.google.com/uc?export=download&id=1flpEpH50fxgPRxFvuyiLu2A70K0UoFx-&revid=0Byj9ykpbAx3od3R4N016WWh0MnlGQ1JHUTg4Nk5HVmVMS2ZNPQ"
moz-do-not-send="true" width="304" height="116"><br>
</div>
<div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a
href="mailto:ncl-talk@ucar.edu"
rel="noreferrer
noreferrer noreferrer"
target="_blank"
moz-do-not-send="true">ncl-talk@ucar.edu</a><br>
List instructions,
subscriber options,
unsubscribe:<br>
<a
href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk"
rel="noreferrer
noreferrer noreferrer
noreferrer"
target="_blank"
moz-do-not-send="true">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></pre>
</blockquote>
<br>
</body>
</html>