evenjc

Plot that step

Oct 27th, 2019
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Oct 25 22:30:56 2019
  4.  
  5. @author: Bruker
  6. """
  7. import matplotlib.pyplot as plt
  8.  
  9. def file_reader():
  10.     data_file = open("ltspice_step_data.txt", "r")
  11.    
  12.     line = data_file.readline()
  13.     values = line.split("\t")
  14.    
  15.    
  16.     file_content = []
  17.     line = data_file.readline()
  18.     while line != "":
  19.    
  20.         file_content.append(line)
  21.          
  22.            
  23.         line = data_file.readline()
  24.        
  25.     return file_content
  26.    
  27.    
  28. contents = file_reader()
  29.  
  30.    
  31.    
  32.  
  33. step_length = 77
  34.  
  35. step_one = contents[1:85]
  36. step_two = contents[86:184]
  37. step_three = contents[185:271]
  38.  
  39. time_s1 = []
  40. time_s2 = []
  41. time_s3 = []
  42.  
  43. v_cap_s1 = []
  44. v_cap_s2 = []
  45. v_cap_s3 = []
  46.  
  47. v_source = []
  48.  
  49. for value in step_one:
  50.     time_s1.append(float(value.split("\t")[0]))
  51.     v_source.append(float(value.split("\t")[2]))
  52.     print(float(value.split("\t")[1].strip("\n")))
  53.     v_cap_s1.append(float(value.split("\t")[1].strip("\n")))
  54.  
  55.    
  56. for value in step_two:
  57.     time_s2.append(float(value.split("\t")[0]))
  58.     v_cap_s2.append(float(value.split("\t")[1].strip("\n")))
  59.  
  60.    
  61. for value in step_three:
  62.     time_s3.append(float(value.split("\t")[0]))
  63.     v_cap_s3.append(float(value.split("\t")[1].strip("\n")))
  64.  
  65. plt.plot(time_s1, v_source)
  66. plt.plot(time_s1, v_cap_s1)
  67. plt.plot(time_s2, v_cap_s2)
  68. plt.plot(time_s3, v_cap_s3)
Advertisement
Add Comment
Please, Sign In to add comment