code: def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0):
      if type(sx) is not np.ndarray:
          raise ValueError("sx=" + str(sx) + " must be a numpy.ndarray")
      elif sx.ndim is not 1:
          raise ValueError("sx.ndim=" + str(sx.ndim) + " must be 1")
      sx_shape = sx.shape
      nmed = nwinwidth//2
      if debugplot >= 10:
          print('find_peaks_spectrum> sx shape......:', sx_shape)
          print('find_peaks_spectrum> nwinwidth.....:', nwinwidth)
          print('find_peaks_spectrum> nmed..........:', nmed)
          print('find_peaks_spectrum> data_threshold:', threshold)
          print('find_peaks_spectrum> the first and last', nmed,
                'pixels will be ignored')
      xpeaks = []
      if sx_shape[0] < nwinwidth:
          print('find_peaks_spectrum> sx shape......:', sx_shape)
          print('find_peaks_spectrum> nwinwidth.....:', nwinwidth)
          raise ValueError('sx.shape < nwinwidth')
      i = nmed
      while i < sx_shape[0] - nmed:
          if sx[i] > threshold:
              peak_ok = True
              j = 0
              loop = True
              while loop:
                  if sx[i - nmed + j] > sx[i - nmed + j + 1]:
                      peak_ok = False
                  j += 1
                  loop = (j < nmed) and peak_ok
              if peak_ok:
                  j = nmed + 1
                  loop = True
                  while loop:
                      if sx[i - nmed + j - 1] < sx[i - nmed + j]:
                          peak_ok = False
                      j += 1
                      loop = (j < nwinwidth) and peak_ok
              if peak_ok:
                  xpeaks.append(i)
                  i += nwinwidth - 1
              else:
                  i += 1
          else:
              i += 1
      ixpeaks = np.array(xpeaks)
      if debugplot >= 10:
          print('find_peaks_spectrum> number of peaks found:', len(ixpeaks))
          print(ixpeaks)
      return ixpeaks