title: find and replace closest values in a numpy array with respect to second array
body: <p>I have a large 2D <code>np.array</code> (<code>vec</code>).
  I would like to replace each value in <code>vec</code> with the closest value from a shorter array <code>vals</code>.</p>
  
  <p>I have tried the following</p>
  
  <pre><code>replaced_vals=vals[np.argmin(np.abs(vec[:, np.newaxis] - vals), axis=0)]
  </code></pre>
  
  <p>but it does not work because the size of <code>vec</code> and <code>vals</code> are different.</p>
  
  <p>Example input</p>
  
  <pre><code>vec = np.array([10.1,10.7,11.4,102,1100]
  vals = np.array([10.0,11.0,100.0])
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>replaced_vals = [10.0,11.0,11.0,100.0,100.0]
  </code></pre>