Skip to content

Commit 4afe450

Browse files
authored
Initial files
1 parent 164c596 commit 4afe450

File tree

2 files changed

+251
-0
lines changed

2 files changed

+251
-0
lines changed

dspacing.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import csv
2+
import matplotlib
3+
matplotlib.use('Qt5Agg')
4+
from matplotlib import pyplot as plt
5+
from scipy.signal import find_peaks
6+
import numpy as np
7+
8+
def get_column_data(numcol, numrows, datacsv):
9+
datatotal = []
10+
for i in range(1, numrows):
11+
data = datacsv[i][numcol]
12+
if data != '':
13+
data = float(data)
14+
datatotal.append(data)
15+
return np.asarray(datatotal).astype(float)
16+
17+
datacsv = []
18+
csvfile = open('values.csv')
19+
reader = csv.reader(csvfile, delimiter=',')
20+
for row in reader:
21+
datacsv.append(row)
22+
csvfile.close()
23+
numrows = len(datacsv)
24+
numcolumns = len(datacsv[1])
25+
26+
xdata = get_column_data(0, numrows, datacsv)
27+
ydata = get_column_data(1, numrows, datacsv)
28+
29+
peaks, _ = find_peaks(ydata, height=3)
30+
31+
print(peaks)
32+
print(xdata[peaks])
33+
maxspacings = xdata[peaks]
34+
35+
dspacings = [x - maxspacings[i - 1] for i, x in enumerate(maxspacings)][1:]
36+
print("d spacing (nm): ", np.nanmedian(dspacings))
37+
38+
plt.plot(xdata, ydata)
39+
plt.plot(xdata[peaks], ydata[peaks], "x")
40+
plt.tight_layout()
41+
plt.show()
42+

values.csv

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
X,Y
2+
0.000000,10.907070
3+
0.012782,10.613102
4+
0.025565,7.520391
5+
0.038347,2.834296
6+
0.051130,-2.552690
7+
0.063912,-7.407323
8+
0.076694,-10.679354
9+
0.089477,-11.179690
10+
0.102259,-9.241397
11+
0.115042,-5.216743
12+
0.127824,0.189339
13+
0.140606,5.550748
14+
0.153389,9.610683
15+
0.166171,11.419617
16+
0.178953,10.789305
17+
0.191736,7.380632
18+
0.204518,2.273955
19+
0.217301,-3.343135
20+
0.230083,-8.203490
21+
0.242865,-11.323425
22+
0.255648,-11.632867
23+
0.268430,-9.178819
24+
0.281213,-4.761067
25+
0.293995,0.897293
26+
0.306777,6.369541
27+
0.319560,10.380538
28+
0.332342,11.895137
29+
0.345125,10.783381
30+
0.357907,7.182508
31+
0.370689,1.656898
32+
0.383472,-4.101157
33+
0.396254,-9.001073
34+
0.409036,-11.840195
35+
0.421819,-11.893866
36+
0.434601,-9.056050
37+
0.447384,-4.218425
38+
0.460166,1.635704
39+
0.472948,7.205130
40+
0.485731,10.984091
41+
0.498513,12.330101
42+
0.511296,10.715666
43+
0.524078,6.752540
44+
0.536860,0.993645
45+
0.549643,-4.879798
46+
0.562425,-9.705270
47+
0.575208,-12.287997
48+
0.587990,-11.994219
49+
0.600772,-8.878376
50+
0.613555,-3.625916
51+
0.626337,2.373959
52+
0.639120,8.026006
53+
0.651902,11.559489
54+
0.664684,12.533095
55+
0.677467,10.590510
56+
0.690249,6.207697
57+
0.703031,0.292509
58+
0.715814,-5.667387
59+
0.728596,-10.270343
60+
0.741379,-12.691289
61+
0.754161,-12.038039
62+
0.766943,-8.459915
63+
0.779726,-2.994934
64+
0.792508,3.125965
65+
0.805291,8.671474
66+
0.818073,12.100327
67+
0.830855,12.599496
68+
0.843638,10.395049
69+
0.856420,5.619933
70+
0.869203,-0.444765
71+
0.881985,-6.451529
72+
0.894767,-10.803391
73+
0.907550,-12.825892
74+
0.920332,-11.898313
75+
0.933114,-7.984518
76+
0.945897,-2.316844
77+
0.958679,3.878846
78+
0.971462,9.205568
79+
0.984244,12.600145
80+
0.997026,12.611027
81+
1.009809,9.942707
82+
1.022591,5.001012
83+
1.035374,-1.189602
84+
1.048156,-7.130156
85+
1.060938,-11.296896
86+
1.073721,-12.852524
87+
1.086503,-11.654822
88+
1.099286,-7.467654
89+
1.112068,-1.583192
90+
1.124850,4.619416
91+
1.137633,9.703216
92+
1.150415,12.748083
93+
1.163198,12.569837
94+
1.175980,9.445371
95+
1.188762,4.315717
96+
1.201545,-1.924924
97+
1.214327,-7.731180
98+
1.227109,-11.739455
99+
1.239892,-12.825518
100+
1.252674,-11.160489
101+
1.265457,-6.909673
102+
1.278239,-0.843024
103+
1.291021,5.261453
104+
1.303804,10.155937
105+
1.316586,12.734163
106+
1.329369,12.400212
107+
1.342151,8.913060
108+
1.354933,3.565469
109+
1.367716,-2.639283
110+
1.380498,-8.296566
111+
1.393281,-11.884706
112+
1.406063,-12.746101
113+
1.418845,-10.628045
114+
1.431628,-6.187819
115+
1.444410,-0.110067
116+
1.457193,5.845774
117+
1.469975,10.528338
118+
1.482757,12.667337
119+
1.495540,11.995006
120+
1.508322,8.355940
121+
1.521104,2.817422
122+
1.533887,-3.273780
123+
1.546669,-8.732533
124+
1.559452,-11.977067
125+
1.572234,-12.508467
126+
1.585016,-10.066733
127+
1.597799,-5.402751
128+
1.610581,0.602138
129+
1.623364,6.388247
130+
1.636146,10.650702
131+
1.648928,12.547877
132+
1.661711,11.473623
133+
1.674493,7.666210
134+
1.687276,2.084855
135+
1.700058,-3.861518
136+
1.712840,-9.052910
137+
1.725623,-12.014510
138+
1.738405,-12.066624
139+
1.751187,-9.485630
140+
1.763970,-4.628838
141+
1.776752,1.266561
142+
1.789535,6.878792
143+
1.802317,10.719528
144+
1.815099,12.243865
145+
1.827882,10.874247
146+
1.840664,6.916755
147+
1.853447,1.378619
148+
1.866229,-4.400775
149+
1.879011,-9.169600
150+
1.891794,-11.989264
151+
1.904576,-11.590540
152+
1.917359,-8.739654
153+
1.930141,-3.878417
154+
1.942923,1.877335
155+
1.955706,7.257524
156+
1.968488,10.732113
157+
1.981270,11.771795
158+
1.994053,10.259497
159+
2.006835,6.176327
160+
2.019618,0.681344
161+
2.032400,-4.881877
162+
2.045182,-9.231194
163+
2.057965,-11.628196
164+
2.070747,-11.086453
165+
2.083530,-7.956074
166+
2.096312,-3.151346
167+
2.109094,2.432554
168+
2.121877,7.476367
169+
2.134659,10.686378
170+
2.147442,11.270013
171+
2.160224,9.449578
172+
2.173006,5.408733
173+
2.185789,0.030277
174+
2.198571,-5.249167
175+
2.211354,-9.234616
176+
2.224136,-11.136922
177+
2.236918,-10.560399
178+
2.249701,-7.189146
179+
2.262483,-2.411183
180+
2.275265,2.923437
181+
2.288048,7.592171
182+
2.300830,10.422762
183+
2.313613,10.743511
184+
2.326395,8.630231
185+
2.339177,4.639173
186+
2.351960,-0.564642
187+
2.364742,-5.493975
188+
2.377525,-9.177716
189+
2.390307,-10.619629
190+
2.403089,-9.777955
191+
2.415872,-6.448422
192+
2.428654,-1.725210
193+
2.441437,3.307547
194+
2.454219,7.603526
195+
2.467001,10.056287
196+
2.479784,10.175190
197+
2.492566,7.834643
198+
2.505348,3.847851
199+
2.518131,-1.094920
200+
2.530913,-5.675402
201+
2.543696,-8.905828
202+
2.556478,-10.080226
203+
2.569260,-8.927143
204+
2.582043,-5.695076
205+
2.594825,-1.101802
206+
2.607608,3.595869
207+
2.620390,7.552378
208+
2.633172,9.654628
209+
2.645955,9.408969

0 commit comments

Comments
 (0)