title: How to make video from an updating numpy array in Python
body: <p>I have a loop that modifies elements of a 2D numpy array <code>water_depth</code> with type <code>float</code>. The array contains water depth for each pixel and the range is usually between 0 to 1.5m. I would like to make a video out of this changing array: each iteration can be a frame in the video. I only found <a href="https://stackoverflow.com/questions/9280653/writing-numpy-arrays-using-cv2-videowriter">this link</a> explaining a similar question and suggests using cv2 VideoWriter. The problem is that my numpy array is a float, not integer. Does this mean that I need to do some sort of pre-processing on my array in each iteration? </p>
  
  <pre><code>import numpy as np
  
  water_depth = np.zeros((500,700), dtype=float)
  
  for i in range(1000):
      random_locations = np.random.random_integers(200,450, size=(200, 2))
      for item in random_locations:
          water_depth[item[0], item[1]] += 0.1
          #add this array to the video
  </code></pre>