[Numpy-discussion] math range error with Masked Array

Joe Van Andel vanandel at atd.ucar.edu
Wed Jun 6 11:50:50 CDT 2001


I'm trying to use the MA package for numeric computations. 
Unfortunately,  attempting to construct a masked array sometimes fails:

masked_values(values, missingValue,savespace=1)
  File "/usr/lib/python2.1/site-packages/MA/MA.py", line 1299, in
masked_values
    m = Numeric.less_equal(abs(d-value), atol+rtol*abs(value))
OverflowError: math range error

The odd thing is that the floating point calculations that produced the
input Numeric array didn't cause a math range error, but MA's attempt to
find the 'missing' values does cause a range error.

When I switched to Python2.1, I had to find and fix several overflow
problems that didn't cause exceptions under Python1.5.  For example, I
had to use a "protected" exponentation routine to avoid overflow errors:

MIN_EXP = -745
MAX_EXP =  709
def ProtExp(a):
    """ Protected Exponentiation calculation.
 
        Avoid Overflow error on large negative or positive arguments
    """
    min_a  = choose(less(a, MIN_EXP), (a, MIN_EXP))
    return exp(choose(greater(min_a, MAX_EXP), (min_a, MAX_EXP)) )

-------------------
I'm concerned that the math exception handling for Python2.1 under x86
Linux makes it hard to get my work done.

Any ideas on how to fix this error in MA?
(I already tried masked_values(values, missingValue,
rtol=1e-2,atol=1.e-4, savespace=1), which didn't help.)

-- 
Joe VanAndel  	          
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: vanandel at ucar.edu




More information about the Numpy-discussion mailing list