Skip to content

Commit c5a4ba1

Browse files
committed
failed multithread attempt + other fixes
1 parent bc02543 commit c5a4ba1

12 files changed

+14
-6
lines changed

calculate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,4 @@ def bisect(low, high, target, function):
176176
ax.axvline(x=param_max, label=f"T_max = {param_max:.6f}", color='blue')
177177

178178
return param_min, param_max
179+

drive.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def process(indx, ax=None):
6060
inches, logits, logits_err = unwrap(results[indx])
6161
cost_func = lambda T: SSE(inches, T, logits, logits_err, RelativeIntersity)
6262

63-
t, smin = sMinFit(cost_func, lr = 5e-4 if "tissue" == attrs['material'] else 2e-7)
63+
# t, smin = sMinFit(cost_func, lr = 5e-4 if "tissue" == attrs['material'] else 2e-7)
64+
t, smin = sMinFit(cost_func)
6465

6566
# neighborhood = np.arange(0, 0.05, 1/1000) # 200 evenly spaced points
6667
# ax.scatter(neighborhood, list(map(lambda T: SSE(inches, T, logits, logits_err, RelativeIntersity), neighborhood)), color='black', label='S(T)')
@@ -74,7 +75,7 @@ def process(indx, ax=None):
7475
ax.scatter(neighborhood, list(map(cost_func, neighborhood)), color='black', label='S(T)')
7576

7677
ax.set_title(f"{attrs['material']} {attrs['source']}")
77-
ax.set_xlabel(f"T ({results[7].attrs['material']})")
78+
ax.set_xlabel(f"T ({attrs['material']})")
7879
ax.set_ylabel("S(T)")
7980
ax.legend()
8081

@@ -88,8 +89,14 @@ def process(indx, ax=None):
8889

8990
# >>>>>>> 68cb3cc3a83d6f09391e99a4e1cc04d712bebe16
9091

92+
from concurrent.futures import ThreadPoolExecutor
93+
9194
if __name__ == '__main__':
92-
for i in range(0, 9):
93-
fig, ax = plt.subplots()
94-
print(process(i, ax))
95-
plt.savefig(f"out/{i}_{results[i].attrs['material']}_{results[i].attrs['source']}.png")
95+
with open('out/params.tsv', 'w+') as wf, ThreadPoolExecutor(max_workers=10) as exer:
96+
# for i in range(0, 9):
97+
# fig, ax = plt.subplots()
98+
# wf.write(' '.join((results[i].attrs['material'], results[i].attrs['source'], *list(map(lambda x: str(x), process(i, ax))))) + '\n')
99+
# plt.savefig(f"out/{i}_{results[i].attrs['material']}_{results[i].attrs['source']}.png")
100+
res = exer.map(process, range(0, 9))
101+
print(res)
102+

out/0_lead_orange.png

-422 Bytes
Loading

out/1_aluminum_uraniumcup.png

-193 Bytes
Loading

out/2_plastic_orange.png

-122 Bytes
Loading

out/3_aluminum_green.png

-196 Bytes
Loading

out/4_lead_uraniumcup.png

1.73 KB
Loading

out/5_tissue_orange.png

-276 Bytes
Loading

out/6_tissue_uraniumcup.png

26 Bytes
Loading

out/7_tissues_yellow.png

18 Bytes
Loading

0 commit comments

Comments
 (0)