title: How to find co-ordinates of lowest pixel in thresholded image?
body: <p>I am new to Python and to coding. I have a .fits image that contains pixels with a range of values. I want to find the pixel in this image that follow the requirements:</p>
  
  <p>1) Value of pixel is above threshold value of 6900.</p>
  
  <p>2) If (1) is met, pixel has the lowest possible y co-ordinates.</p>
  
  <p>That is, if I find that my image has 100 pixels with value > 6900, I wish to find the pixel within those 100 that appears closest to the bottom of the image.</p>
  
  <p>I have achieved the first part by adding a thresholding rule that I have included below:</p>
  
  <pre><code>#open .fits file
  hdulist = fits.open(f, ignore_missing_end=True)    
  hdulist.info()
  
  #close file and save data as numpy array
  scidata = hdulist[0].data
  hdulist.close()
  img = np.array(scidata)
  
  #determine threshold value and apply thresholding to image
  threshold = 6900
  test = np.greater_equal(img, threshold)  
  np.count_nonzero(~np.isnan(test))  
  
  #plot image
  plt.imshow(img, cmap='magma')
  plt.show()
  </code></pre>
  
  <p>However, I am having difficulty in achieving (2). Is there a command in numpy that identifies the smallest possible y co-ordinates of pixels above a certain value threshold?</p>
  
  <p>Many thanks!</p>