title: How to get the data from Tektronix Oscilloscope from a certain peak and then probe it until a certain amount of points with Python
body: <p>I know how to get the plot and save data from the Tektronix oscilloscope with Python. I have some peaks and then they decay (periodic dampings). I want to write a code to capture a peak and go through 2000 points (the end of damping, see the plot) and save the data (because I want to get the damping factor).</p>
  <p>I know how to get the peaks by <code>detect_peaks</code> by this:</p>
  <pre><code>ind = detect_peaks(Volts, mph:1.4, show=True)
  print(ind)
  </code></pre>
  <p>When I <code>print(ind)</code>, it prints time which voltages are peaks, but not voltages. I have a problem because if I use a <code>while</code> loop I can count time from one peak to 2000 points after, but I do not know how can I do it in a way that automatically gives me both Time and Volts.</p>
  <p><img src="https://i.stack.imgur.com/ahOlN.png" alt="enter image description here" /></p>
  <p>Here is the summary:</p>
  <p>I want to get one of the peaks and acquire all the voltages until the end of damped oscillation.</p>
  <p>here is my code:</p>
  <pre><code>import visa
  import numpy as np
  from struct import unpack
  import pylab
  from detecta import detect_peaks
  
  #how to get the plot from Tektronix
  # Establish Connection
  rm = visa.ResourceManager('@py') # Calling PyVisaPy library
  #scope = rm.open_resource('USB0::0x0699::0x0409::C010730::INSTR') # Connecting via USB
  scope = rm.open_resource('USB0::1689::883::C011533::0::INSTR') # Connecting via LAN 
   
  # Setting source as Channel 1
  scope.write('DATA:SOU CH2') 
  scope.write('DATA:WIDTH 1') 
  scope.write('DATA:ENC RPB')
  
  # Getting axis info
  ymult = float(scope.query('WFMPRE:YMULT?')) # y-axis least count
  yzero = float(scope.query('WFMPRE:YZERO?')) # y-axis zero error
  yoff = float(scope.query('WFMPRE:YOFF?')) # y-axis offset
  xincr = float(scope.query('WFMPRE:XINCR?')) # x-axis least count
  
  # Reading Binary Data from instrument
  scope.write('CURVE?')
  data = scope.read_raw() # Reading binary data
  headerlen = 2 + int(data[1]) # Finding header length
  header = data[:headerlen] # Separating header 
  ADC_wave = data[headerlen:-1] # Separating data
  
  # Converting to Binary to ASCII
  ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave))
  
  Volts = (ADC_wave- yoff ) * ymult + yzero
  Time = np.arange(0, xincr * len(Volts), xincr)
  
  #getting  peaks
  ind = detect_peaks(Volts, mph=1.4, show=True)
  print(ind)
  
  #attempt for taking 2000 piint after the first peak
  a2=ind[0] #first peak 
  i=ind[0]
  while i&lt;a2+20:
      print(i)
      i+=1
  
  
  #Plotting Volt Vs. Time
  pylab.plot(Time, Volts) 
  pylab.show()
  
  </code></pre>