Skip to content

Commit d591cbc

Browse files
clean up
1 parent 74296f9 commit d591cbc

1 file changed

Lines changed: 30 additions & 48 deletions

File tree

PythonGUI_apps/Lifetime_analysis/read_ph_phd.py

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,38 @@
1414

1515

1616
def read_picoharp_phd(datafile):
17-
parser = picoharp_phd.PicoharpParser(datafile)
17+
parser = picoharp.PicoharpParser(datafile)
1818
return parser
1919

20-
def phd_to_csv(datafile):
21-
parser = read_picoharp_phd(datafile)
22-
name, ext = datafile.rsplit('.', 1)
23-
24-
total_curves = parser.no_of_curves()
25-
y = []
26-
for i in range(total_curves):
27-
res, curve = parser.get_curve(i)
28-
time_window = int(numpy.floor(parser.get_time_window_in_ns(curve_no)))
29-
curve = curve[0:time_window]
30-
y.append(curve)
31-
32-
parser = picoharp_phd.PicoharpParser(datafile)
33-
name, ext = datafile.rsplit('.', 1)
34-
35-
#for i in range(parser.no_of_curves()):
20+
#def phd_to_csv(datafile, return_df = False):
21+
# parser = read_picoharp_phd(datafile)
22+
# name, ext = datafile.rsplit('.', 1)
3623
#
37-
# res, curve1 = parser.get_curve(0)
38-
# res, curve2 = parser.get_curve(1)
39-
# res, curve3 = parser.get_curve(2)
40-
# res, curve4 = parser.get_curve(3)
41-
# res, curve5 = parser.get_curve(4)
42-
## res, curve2 = parser.get_curve(1)
43-
# size = len(curve1)
44-
45-
curve_no = 3
46-
47-
res, curve1 = parser.get_curve(curve_no)
48-
time_window = int(numpy.floor(parser.get_time_window_in_ns(curve_no)))
49-
curve1 = curve1[0:time_window]
50-
size = len(curve1)
51-
X = numpy.arange(0, size*res, res, numpy.float)
52-
53-
plt.figure()
54-
plt.plot(X,curve1)
55-
plt.yscale('log')
56-
plt.ylim([1,1e4])
57-
#csvname = '%s.csv' % name
58-
#csv = open(csvname, 'w')
59-
#
60-
#for x, y1, y2, y3, y4, y5 in zip(X, curve1, curve2, curve3, curve4, curve5):
61-
# csv.write('%f,%d,%d,%d,%d,%d\n' % (x, y1, y2, y3,y4,y5))
62-
#
63-
#csv.close()
64-
#
65-
#print('Saved %s.' % csvname)
24+
# total_curves = parser.no_of_curves()
25+
# y = []
26+
# for i in range(total_curves):
27+
# res, curve = parser.get_curve(i)
28+
# time_window = int(np.floor(parser.get_time_window_in_ns(curve_no)))
29+
# curve = curve[0:time_window]
30+
# y.append(curve)
31+
#
32+
# df = pd.DataFrame(y)
33+
# df.T.to_csv(name+".csv", index=False, header=False)
34+
# if return_df == True:
35+
# return df.T
6636

37+
def smooth(curve, boxwidth):
38+
sm_curve = np.convolve(curve, np.ones(boxwidth)/boxwidth, mode="same")
39+
return sm_curve
6740

68-
#if __name__ == '__main__':
69-
# main()
41+
def get_x_y(curve_no, parser, smooth_trace = False, boxwidth = 3):
42+
43+
assert type(parser) == picoharp.PicoharpParser, 'must be picoharp parser'
44+
res, curve = parser.get_curve(curve_no)
45+
time_window = int(np.floor(parser.get_time_window_in_ns(curve_no)))
46+
curve = curve[0:time_window]
47+
size = len(curve)
48+
x = np.arange(0, size*res, res, np.float)
49+
if smooth_trace == True:
50+
curve = smooth(curve, boxwidth=boxwidth)
51+
return x,curve

0 commit comments

Comments
 (0)