Re: how to deal with the problem "division by 0 can not continue." using where

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 05 2012 - 10:10:57 MST

Something is not correct here

> dT@_FillValue = -9999.9
> dT = where(dT.ne.0,dT,dT@_FillValue)

[1] printVarSummary(dT)
[2] kzero = num(dT.eq.0) ; count the number od 0s
     print("kzero="+kzero)

Incidentally, you should be able to use:

     FT = 1.0/where(dT.ne.0,dT,dT@_FillValue)

On 03/04/2012 05:00 AM, Jie Tang wrote:
> hi everyone
> I am writing a script that is needed to division..
>
> To avoid the 0 division problem,I used "where " as below.
>
> dT here is data matrix (nt,nz,ny,nx).
>
> dT@_FillValue = -9999.9
> dT = where(dT.ne.0,dT,dT@_FillValue)
> FT = 1.0/dT
>
> But it still says that :
> Copyright (C) 1995-2011 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
>
> fatal:divide: Division by 0, Can't continue
>
> fatal:Div: operator failed, can't continue
>
> fatal:Execute: Error occurred at or near line 15 in file ncl-code.ncl
>
> It seems that "where" does not work. What is wrong with my script?
>
>
>
> --
> TANG Jie
> Email: totangjie@gmail.com <mailto:totangjie@gmail.com>
> Tel: 0086-2154896104
> Shanghai Typhoon Institute,China
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Mar 5 10:11:05 2012

This archive was generated by hypermail 2.1.8 : Mon Mar 05 2012 - 14:12:07 MST