[ncl-talk] dividing by zero (Laura Fowler)

Gabriel Medeiros gabriel.abrahao at ufv.br
Mon Nov 7 14:48:10 MST 2016


Hi Laura,

The problem is that "where" evaluates both options and then chooses which
to put where in your ratio_rainc variable. Therefore itll raise the error
even though the value wont be used.

A workaround would be setting a mask first, setting a dummy value, and
masking the variable later, e.g.

msk = where(ismissing(rain),1,0)
rain = where(rain.eq.0,9999,rain)
ratio_rainc = where(rain.gt.5.,rainc/rain,rain at _FillValue)
ratio_rainc = where(msk.eq.1,ratio_rainc at _FIllValue,ratio_rainc)

It's not very elegant or efficient but works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161107/1edd0f7f/attachment.html 


More information about the ncl-talk mailing list