What are the types and shapes of modelData and dataMin? (it works for me with modelData a (3, 4) numpy array and dataMin a Python float, with numpy 1.6.1)<br><br>-=- Olivier<br><br><div class="gmail_quote">2012/1/27 Howard <span dir="ltr"><<a href="mailto:howard@renci.org">howard@renci.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi all<br>
<br>
I am a fairly recent convert to python and I have got a question
that's got me stumped. I hope this is the right mailing list: here
goes :)<br>
<br>
I am reading some time series data out of a netcdf file a single
timestep at a time. If the data is NaN, I want to reset it to the
minimum of the dataset over all timesteps (which I already know).
The data is in a variable of type numpy.ma.core.MaskedArray called
modelData. <br>
<br>
If I do this:<br>
<br>
for i in range(len(modelData)):<br>
if math.isnan(modelData[i]):<br>
modelData[i] = dataMin<br>
<br>
I get the effect I want, If I do this:<br>
<br>
modelData[np.isnan(modelData)] = dataMin<br>
<br>
it doesn't seem to be working. Of course I could just do the first
one, but len(modelData) is about 3.5 million, and it's taking about
20 seconds to run. This is happening inside of a rendering loop, so
I'd like it to be as fast as possible, and I thought the second one
might be faster, and maybe it is, but it doesn't seem to be working!
:)<br>
<br>
Any ideas would be much appreciated.<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
Howard<br>
<br>
<div>-- <br>
<a href="mailto:howard@renci.org" target="_blank">Howard Lander</a><br>
Senior Research Software Developer<br>
<a href="http://www.renci.org" target="_blank">Renaissance Computing Institute
(RENCI)</a> <br>
The University of North Carolina at Chapel Hill<br>
Duke University<br>
North Carolina State University<br>
100 Europa Drive<br>
Suite 540<br>
Chapel Hill, NC 27517<br>
919-445-9651
</div>
</font></span></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br>