Re: error division by zero

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 02 2013 - 08:49:23 MDT

Hi Lena,

It appears that "psi" contains values equal to 0, so you are going to get a divide-by-zero error if you try to do:

> (psi2-psi)/psi).

Perhaps you want to set psi to _FillValue wherever it is equal to 0 before you do the calculation:

  psi = where(psi.ne.0,psi,psi@_FillValue)

This will cause "Delta" to be missing in those same locations.

--Mary

On Jul 2, 2013, at 8:26 AM, Lena Frey wrote:

> Hi,
>
> I have calculated the absolute deviation for the mean meridional streamfunction. Now I would like to calculate the relative deviaiton, but I get the error message "division by zero".
> I have used the following configuraton:
>
> Delta = ((psi2-psi)/psi)*100
> Delta!0 = "lev"
> Delta!1 = "lat"
> Delta&lat = lat
> Delta&lev = lev_p
> Delta&lev@units = "hPa"
> if(any(ismissing(Delta))) then
> print("Your data contains some missing values. Beware.")
> end if
> if (any(isnan_ieee(Delta))) then
> value = -1.e34
> replace_ieeenan (Delta, value, 0)
> Delta@_FillValue = value
> end if
>
> Has anyone an idea?
>
> Thanks.
>
> Lena
>
> _______________________________________________
> 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 Jul 2 08:49:33 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 05 2013 - 13:06:49 MDT