-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataHistogram.py
47 lines (36 loc) · 1.08 KB
/
DataHistogram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Store in a file all the values whose occurrence frequency is going to
be represented in a histogram
Author: Carla Borja Espinosa
Date: July 2019
"""
import matplotlib.pyplot as plt
from scipy import *
import glob, os
from sys import argv
import numpy as np
from progress.bar import Bar
"Input parameters"
path = argv[1] # directory path of the conductance traces files
dataFile = argv[2] # file name where the values will be stored
"Variables"
line = 0 # line number to start reading the data in traces
# files
os.chdir(path)
list_dat = [file for file in sorted(glob.glob("*.dat"))]
def column(array, n):
"""Returns column n from file lines in array"""
c = [float(i)
for i in [(line.split()[n])
for line in array]]
return c
bar = Bar('Completado:', max=len(list_dat))
for i in range(len(list_dat)):
with open(list_dat[i]) as g:
glines = g.readlines()[line:]
y = column(glines,1)
for j in y:
y_cumulative.append(j)
bar.next()
bar.finish()
np.savetxt(dataFile, y_cumulative)