code: def fwhm(x, y, k=10):  # http://stackoverflow.com/questions/10582795/finding-the-full-width-half-maximum-of-a-peak
      
  
      class MultiplePeaks(Exception):
          pass
  
      class NoPeaksFound(Exception):
          pass
  
      half_max = np.amax(y) / 2.0
      s = splrep(x, y - half_max)
      roots = sproot(s)
  
      if len(roots) > 2:
          raise MultiplePeaks("The dataset appears to have multiple peaks, and "
                              "thus the FWHM can't be determined.")
      elif len(roots) < 2:
          raise NoPeaksFound("No proper peaks were found in the data set; likely "
                             "the dataset is flat (e.g. all zeros).")
      else:
          return roots[0], roots[1]
docs: Determine full-with-half-maximum of a peaked set of points, x and y.
  
      Assumes that there is only one peak present in the datasset.  The function
      uses a spline interpolation of order k.