Skip to content
Snippets Groups Projects
Commit 9654c01c authored by David Hoese's avatar David Hoese
Browse files

Fixed array_convert so its vectorized and is mask agnostic

Fixed buoy quicklooks so it uses numpy.isnan to mask nans instead of for loops
parent f033c9eb
No related branches found
No related tags found
No related merge requests found
......@@ -317,39 +317,33 @@ def array_convert(arr, sunits, cunits):
"""
if sunits == cunits: return arr
if not isinstance(arr, ndarray): raise ValueError("Array must be of type numpy.ndarray, not %r" % (type(arr),))
shape = arr.shape
a = arr.flatten()
if sunits == 'c':
if cunits == 'f':
a = array([ c2f(x) for x in a ])
return a.reshape(shape)
a = c2f(arr)
return a
elif sunits == 'f':
if cunits == 'c':
a = array([ f2c(x) for x in a ])
return a.reshape(shape)
a = f2c(arr)
return a
elif sunits == 'm/s':
if cunits == 'knots':
a = array([ mps2knots(x) for x in a ])
return a.reshape(shape)
a = mps2knots(arr)
return a
elif sunits == 'knots':
if cunits == 'm/s':
a = array([ knots2mps(x) for x in a ])
return a.reshape(shape)
elif sunits == 'hpa':
return a.reshape(a)
elif sunits == 'deg':
return a.reshape(a)
a = knots2mps(arr)
return a
elif sunits == 'in':
if cunits == 'mm':
a = array([ in2mm(x) for x in a ])
return a.reshape(shape)
a = in2mm(arr)
return a
elif sunits == 'mm':
if cunits == 'in':
a = array([ mm2in(x) for x in a ])
return a.reshape(shape)
elif sunits == 'w/m2':
return a.reshape(a)
a = mm2in(arr)
return a
raise ValueError("sunits or cunits was not an acceptable unit")
if __name__ == '__main__':
import doctest
doctest.testmod()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment