My Project
plotSystemTesting.py
Go to the documentation of this file.
1 from analysisSharedFunctions import loadYaml, loadFile
2 from plotSetUp import setSvgLatexMatplotlibSettings, \
3  colors_diverging_short as colors_short, \
4  linestyles, \
5  createTimeStepValues, \
6  createSliderVelocityStepValues, \
7  choseColourFromDirection
8 import sys
9 from matplotlib import pyplot as plt
10 
12 
13 if("--artistic" in sys.argv):
14  plt.style.use("dark_background")
15 
16 def prettyPlotPhase(
17  position_data,
18  velocity_data,
19  y_label="\$x\$",
20  x_label="\$\\dot{x}\$",
21  alpha=1.0,
22  color_index=0,
23  line_style_index=0,
24  label=""
25 ):
26  plt.plot(position_data, velocity_data,
27  color=colors_short[color_index],
28  linestyle=linestyles[line_style_index],
29  label=label,
30  linewidth=0.4,
31  alpha=alpha
32  )
33  plt.ylabel(y_label)
34  plt.xlabel(x_label)
35 
36 
37 def prettyPlotPad(
38  time_steps,
39  pad_data,
40  yaml_file,
41  y_label="\$x\$",
42  x_label="\$t\$",
43  label="",
44  alpha=1.0,
45  y_lim=[-1.1, 0.15]
46 ):
47  color_index = choseColourFromDirection(yaml_file)
48  plt.plot(time_steps, pad_data,
49  color=colors_short[color_index],
50  linestyle=linestyles[0],
51  label=label,
52  alpha=alpha
53  )
54 
55  plt.ylim(y_lim[0], y_lim[1])
56 
57  plt.ylabel(y_label)
58  plt.xlabel(x_label)
59 
60 
61 def plot_pad(
62  run_name,
63  alpha=1.0,
64  label="Pad"
65 ):
66  yaml_file = loadYaml(run_name)
67  pad_position = loadFile(run_name, yaml_file, file_name="pad_position")
68  pad_velocity = loadFile(run_name, yaml_file, file_name="pad_velocity")
69  time_steps = createTimeStepValues(pad_position, yaml_file)
70 
71  prettyPlotPad(time_steps, pad_position, yaml_file,
72  alpha=alpha,
73  label=label)
74  plt.grid()
75  plt.show()
76  prettyPlotPhase(pad_position, pad_velocity)
77 
78 
79 def plot_single_pad(
80  run_name
81 ):
82  plot_pad(run_name)
83  #plt.legend()
84  plt.show()
85 
86 
87 def run():
88  if(len(sys.argv) == 2 or (len(sys.argv) == 3 and "--artistic" in sys.argv)):
89  plot_single_pad(sys.argv[1])
90  # elif(len(sys.argv) > 2):
91  # if("-m" in sys.argv):
92  # plot_compare_pads(sys.argv[1:-1])
93  # else:
94  # plot_compare_pads(sys.argv[1:])
95 
96 
97 if __name__ == "__main__":
98  run()
def prettyPlotPad(time_steps, pad_data, yaml_file, y_label="\\, x_label="\t\", label="", alpha=1.0, y_lim=[-1.1)
def prettyPlotPhase(position_data, velocity_data, y_label="\\, x_label="\\dot{x}\", alpha=1.0, color_index=0, line_style_index=0, label="")
def createTimeStepValues(block_data, yaml_file)
Definition: plotSetUp.py:40
def loadFile(run_name, shared_names, selected='pad_position.csv')
def plot_single_pad(run_name)
def choseColourFromDirection(yaml_file)
Definition: plotPadStep.py:22
def setSvgLatexMatplotlibSettings(pyplot)
Definition: plotSetUp.py:11
def plot_pad(run_name, alpha=1.0, label="Pad")