<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body 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<br>
    Howard<br>
    <br>
    <div class="moz-signature">-- <br>
      <a href="mailto:howard@renci.org">Howard Lander</a><br>
      Senior Research Software Developer<br>
      <a href="http://www.renci.org">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>
  </body>
</html>