Re: Mask division by zero.

From: Andrew Dawson <dawson_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 29 2011 - 07:09:18 MDT

In the documentation for the 'where' function there is actually an example
of this:

http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

Look in the 'Description' section for the part labelled 'Caveat:'. Basically
you need to set pdfobsr to a missing value where it is zero and then do the
division, preventing a divide by zero error.

Hope that helps,
Andrew

On 29 March 2011 14:00, gibies george <gibies@tropmet.res.in> wrote:

> Here is some part of my ncl script where pdfobsr, pdffcst, pdfratio and lnpdfrat
> are multi dimensional variables.
>
> pdfobsr = pdf_time(ssnobsr)
> pdffcst = pdf_time(ssnfcst)
> pdfratio = pdffcst/pdfobsr
> lnpdfrat = log(pdfratio)
>
> But (as everybody knows), It will cause problem at some point where pdfobsr
> (denominator) is zero.
>
> Can anybody suggest a way to rewrite this script in order to avoid the
> division by zero ?
>
> Thanking you in advance.
> ____________
>
> Note : pdf_time() used above is my function to find the probability
> density along time dimension at each grid point.
>
> --
> *Gibies George, CSIR-RF,*
> *Monsoon Seasonal Prediction Group,
> Climate and Global Modelling Division,
> Indian Institute of Tropical Meteorology,
> Dr. Homi Bhabha Road,
> NCL (P. O.), Pashan,
> Pune 411008, India.*
>
> *http://sites.google.com/site/gibiesge/*
>
> Please Think about the environment. Save paper; Save Trees; and don't print
> this e-mail unless it is necessary.
>
> _______________________________________________
> 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 Tue Mar 29 07:09:27 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:01:21 MDT