code: def calc_lm(d, im=[], pix=(), minmax='max'):
      
  
      if len(pix) == 0:  # default is to get pixel from image
          if minmax == 'max':
              peakl, peakm = n.where(im == im.max())
          elif minmax == 'min':
              peakl, peakm = n.where(im == im.min())
          peakl = peakl[0]; peakm = peakm[0]
      elif len(pix) == 2:   # can also specify
          peakl, peakm = pix
  
      if len(im):
          npixx, npixy = im.shape
      else:
          npixx = d['npixx']
          npixy = d['npixy']
  
      l1 = (npixx/2. - peakl)/(npixx*d['uvres'])
      m1 = (npixy/2. - peakm)/(npixy*d['uvres'])
  
      return l1, m1
docs: Helper function to calculate location of image pixel in (l,m) coords.
      Assumes peak pixel, but input can be provided in pixel units.
      minmax defines whether to look for image maximum or minimum.