Lucas Teske ревизий этого фрагмента 8 years ago. К ревизии
3 files changed, 18 insertions, 2 deletions
generate.py
| @@ -2,11 +2,16 @@ | |||
| 2 | 2 | # -*- coding: utf-8 -*- | |
| 3 | 3 | from __future__ import unicode_literals | |
| 4 | 4 | ||
| 5 | + | ''' | |
| 6 | + | Para geração de histograma dos tempos de queda | |
| 7 | + | ''' | |
| 8 | + | ||
| 5 | 9 | import sys | |
| 6 | 10 | import numpy as np | |
| 7 | 11 | import matplotlib.mlab as mlab | |
| 8 | 12 | import matplotlib.pyplot as plt | |
| 9 | 13 | ||
| 14 | + | # Tamanho da página do histograma | |
| 10 | 15 | width = 20 # cm | |
| 11 | 16 | height = 15 # cm | |
| 12 | 17 | ||
grafa.py
| @@ -2,17 +2,22 @@ | |||
| 2 | 2 | # -*- coding: utf-8 -*- | |
| 3 | 3 | from __future__ import unicode_literals | |
| 4 | 4 | ||
| 5 | + | ''' | |
| 6 | + | Para geração de histograma das acelerações | |
| 7 | + | ''' | |
| 8 | + | ||
| 5 | 9 | import sys | |
| 6 | 10 | import numpy as np | |
| 7 | 11 | import matplotlib.mlab as mlab | |
| 8 | 12 | import matplotlib.pyplot as plt | |
| 9 | 13 | ||
| 14 | + | # Tamanho da página do histograma | |
| 10 | 15 | width = 20 # cm | |
| 11 | 16 | height = 15 # cm | |
| 12 | 17 | ||
| 18 | + | # Altura de queda | |
| 13 | 19 | deltaS = 34 # metros | |
| 14 | 20 | ||
| 15 | - | ||
| 16 | 21 | if len(sys.argv) < 3: | |
| 17 | 22 | print "Usage: generate.py data.txt output" | |
| 18 | 23 | exit(1) | |
| @@ -21,7 +26,7 @@ output = sys.argv[2] | |||
| 21 | 26 | ||
| 22 | 27 | data = np.fromfile(sys.argv[1], sep='\n') | |
| 23 | 28 | ||
| 24 | - | data = (2 * 34) / (data ** 2) | |
| 29 | + | data = (2 * deltaS) / (data ** 2) | |
| 25 | 30 | ||
| 26 | 31 | num_bins = 12 | |
| 27 | 32 | avg = np.average(data) | |
grafv.py
| @@ -2,14 +2,20 @@ | |||
| 2 | 2 | # -*- coding: utf-8 -*- | |
| 3 | 3 | from __future__ import unicode_literals | |
| 4 | 4 | ||
| 5 | + | ''' | |
| 6 | + | Para geração de histograma das velocidades | |
| 7 | + | ''' | |
| 8 | + | ||
| 5 | 9 | import sys | |
| 6 | 10 | import numpy as np | |
| 7 | 11 | import matplotlib.mlab as mlab | |
| 8 | 12 | import matplotlib.pyplot as plt | |
| 9 | 13 | ||
| 14 | + | # Tamanho da página do histograma | |
| 10 | 15 | width = 20 # cm | |
| 11 | 16 | height = 15 # cm | |
| 12 | 17 | ||
| 18 | + | # Altura de queda | |
| 13 | 19 | deltaS = 34 # metros | |
| 14 | 20 | ||
| 15 | 21 | if len(sys.argv) < 3: | |
Lucas Teske ревизий этого фрагмента 8 years ago. К ревизии
3 files changed, 139 insertions
generate.py(файл создан)
| @@ -0,0 +1,44 @@ | |||
| 1 | + | #!/usr/bin/env python | |
| 2 | + | # -*- coding: utf-8 -*- | |
| 3 | + | from __future__ import unicode_literals | |
| 4 | + | ||
| 5 | + | import sys | |
| 6 | + | import numpy as np | |
| 7 | + | import matplotlib.mlab as mlab | |
| 8 | + | import matplotlib.pyplot as plt | |
| 9 | + | ||
| 10 | + | width = 20 # cm | |
| 11 | + | height = 15 # cm | |
| 12 | + | ||
| 13 | + | if len(sys.argv) < 4: | |
| 14 | + | print "Usage: generate.py data.txt title output" | |
| 15 | + | exit(1) | |
| 16 | + | ||
| 17 | + | output = sys.argv[3] | |
| 18 | + | title = sys.argv[2].decode(encoding='UTF-8',errors='strict') | |
| 19 | + | ||
| 20 | + | data = np.fromfile(sys.argv[1], sep='\n') | |
| 21 | + | ||
| 22 | + | num_bins = 12 | |
| 23 | + | avg = np.average(data) | |
| 24 | + | std = np.std(data) | |
| 25 | + | ||
| 26 | + | fig, ax = plt.subplots() | |
| 27 | + | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') | |
| 28 | + | ||
| 29 | + | print "Média: %s Desvio Padrão: %s" %(avg, std) | |
| 30 | + | ||
| 31 | + | ax.axvline(avg, color='red', label="Média = %.2f s" %avg) | |
| 32 | + | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f s" %(avg-std)) | |
| 33 | + | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f s" % (avg+std)) | |
| 34 | + | ||
| 35 | + | ax.set_xlabel('Tempo (s)') | |
| 36 | + | ax.set_ylabel('Contagem (n)') | |
| 37 | + | ax.set_title(title) | |
| 38 | + | ax.set_ylim( None, n.max() * 1.2) | |
| 39 | + | ||
| 40 | + | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) | |
| 41 | + | fig.tight_layout() | |
| 42 | + | ||
| 43 | + | fig.set_size_inches(width / 2.54, height / 2.54) | |
| 44 | + | plt.savefig('%s.png' %output, dpi=100) | |
grafa.py(файл создан)
| @@ -0,0 +1,48 @@ | |||
| 1 | + | #!/usr/bin/env python | |
| 2 | + | # -*- coding: utf-8 -*- | |
| 3 | + | from __future__ import unicode_literals | |
| 4 | + | ||
| 5 | + | import sys | |
| 6 | + | import numpy as np | |
| 7 | + | import matplotlib.mlab as mlab | |
| 8 | + | import matplotlib.pyplot as plt | |
| 9 | + | ||
| 10 | + | width = 20 # cm | |
| 11 | + | height = 15 # cm | |
| 12 | + | ||
| 13 | + | deltaS = 34 # metros | |
| 14 | + | ||
| 15 | + | ||
| 16 | + | if len(sys.argv) < 3: | |
| 17 | + | print "Usage: generate.py data.txt output" | |
| 18 | + | exit(1) | |
| 19 | + | ||
| 20 | + | output = sys.argv[2] | |
| 21 | + | ||
| 22 | + | data = np.fromfile(sys.argv[1], sep='\n') | |
| 23 | + | ||
| 24 | + | data = (2 * 34) / (data ** 2) | |
| 25 | + | ||
| 26 | + | num_bins = 12 | |
| 27 | + | avg = np.average(data) | |
| 28 | + | std = np.std(data) | |
| 29 | + | ||
| 30 | + | fig, ax = plt.subplots() | |
| 31 | + | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') | |
| 32 | + | ||
| 33 | + | print "Média: %s Desvio Padrão: %s" %(avg, std) | |
| 34 | + | ||
| 35 | + | ax.axvline(avg, color='red', label="Média = %.2f m/s²" %avg) | |
| 36 | + | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s²" %(avg-std)) | |
| 37 | + | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s²" % (avg+std)) | |
| 38 | + | ||
| 39 | + | ax.set_xlabel('Aceleração (m/s²)') | |
| 40 | + | ax.set_ylabel('Contagem (n)') | |
| 41 | + | ax.set_title('Histograma das Acelerações Médias') | |
| 42 | + | ax.set_ylim( None, n.max() * 1.2) | |
| 43 | + | ||
| 44 | + | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) | |
| 45 | + | fig.tight_layout() | |
| 46 | + | ||
| 47 | + | fig.set_size_inches(width / 2.54, height / 2.54) | |
| 48 | + | plt.savefig('%s.png' %output, dpi=100) | |
grafv.py(файл создан)
| @@ -0,0 +1,47 @@ | |||
| 1 | + | #!/usr/bin/env python | |
| 2 | + | # -*- coding: utf-8 -*- | |
| 3 | + | from __future__ import unicode_literals | |
| 4 | + | ||
| 5 | + | import sys | |
| 6 | + | import numpy as np | |
| 7 | + | import matplotlib.mlab as mlab | |
| 8 | + | import matplotlib.pyplot as plt | |
| 9 | + | ||
| 10 | + | width = 20 # cm | |
| 11 | + | height = 15 # cm | |
| 12 | + | ||
| 13 | + | deltaS = 34 # metros | |
| 14 | + | ||
| 15 | + | if len(sys.argv) < 3: | |
| 16 | + | print "Usage: generate.py data.txt output" | |
| 17 | + | exit(1) | |
| 18 | + | ||
| 19 | + | output = sys.argv[2] | |
| 20 | + | ||
| 21 | + | data = np.fromfile(sys.argv[1], sep='\n') | |
| 22 | + | ||
| 23 | + | data = deltaS / data | |
| 24 | + | ||
| 25 | + | num_bins = 12 | |
| 26 | + | avg = np.average(data) | |
| 27 | + | std = np.std(data) | |
| 28 | + | ||
| 29 | + | fig, ax = plt.subplots() | |
| 30 | + | n, bins, patches = ax.hist(data, num_bins, color='burlywood', histtype='stepfilled') | |
| 31 | + | ||
| 32 | + | print "Média: %s Desvio Padrão: %s" %(avg, std) | |
| 33 | + | ||
| 34 | + | ax.axvline(avg, color='red', label="Média = %.2f m/s" %avg) | |
| 35 | + | ax.axvline(avg-std, color='lightblue', label="Média - Desvio Padrão = %.2f m/s" %(avg-std)) | |
| 36 | + | ax.axvline(avg+std, color='darkblue', label="Média + Desvio Padrão = %.2f m/s" % (avg+std)) | |
| 37 | + | ||
| 38 | + | ax.set_xlabel('Velocidade (m/s)') | |
| 39 | + | ax.set_ylabel('Contagem (n)') | |
| 40 | + | ax.set_title('Histograma das Velocidades Médias') | |
| 41 | + | ax.set_ylim( None, n.max() * 1.2) | |
| 42 | + | ||
| 43 | + | legend = ax.legend(loc='upper left', shadow=True, prop={'size':10}) | |
| 44 | + | fig.tight_layout() | |
| 45 | + | ||
| 46 | + | fig.set_size_inches(width / 2.54, height / 2.54) | |
| 47 | + | plt.savefig('%s.png' %output, dpi=100) | |