-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_manipulation_routines.py
145 lines (119 loc) · 4.35 KB
/
misc_manipulation_routines.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from Model import Model,Measurement,filt_design_type
import pandas as pd
def get_filtered_list(filters,model):
try:
return [m for m in model.saved_measurements if all(f(m) for f in filters)]
except TypeError: # Likely not passed as list, but as a single filter class instead.
return [m for m in model.saved_measurements if filters(m)]
def change_value(filters, propertyname,value):
model = Model()
model.load()
measurements = get_filtered_list(filters,model)
for m in measurements:
if propertyname in m.__dict__:
setattr(m, propertyname, value)
else:
m[propertyname] = value
model.save()
def change_waferID(filters, old,new):
model = Model()
model.load()
measurements = get_filtered_list(filters,model)
for m in measurements:
s = m.sampleID
m.sampleID = s.replace(old,new)
model.save()
def delete_property(filters,propertyname):
model = Model()
model.load()
measurements = get_filtered_list(filters,model)
for m in measurements:
m.delete_property(propertyname)
model.save()
def add_property(filters, propertyname,value,unit=''):
model = Model()
model.load()
measurements = get_filtered_list(filters, model)
for m in measurements:
m.add_property(propertyname,value,unit)
model.save()
def update_TOT_data():
model = Model()
model.load()
# Correct design type name
filt = filt_design_type('Toplogy Optimized Trampoline')
measurements = [m for m in model.saved_measurements if filt(m)]
for m in measurements:
m.design_type = 'Topology Optimized Trampoline'
# Find topology optimized trampolines
filt = filt_design_type('Topology Optimized Trampoline')
measurements = [m for m in model.saved_measurements if filt(m)]
# Load list of legacy data
df = pd.read_excel("Old list of samples.xlsx",
"Toplogy Optimized Trampoline",
skiprows = 1)
df2 = pd.read_excel("samples.xlsx")
# Update data
unknowns = 0
total = 0
for m in measurements:
total += 1
row = df2.loc[df2['sampleID'] == m.sampleID]
found = True
if len(row):
design = row['designID'].values[0]
else:
row = df.loc[df['sample ID'] == m.sampleID]
if len(row):
design = row['design ID'].values[0]
else:
row = []
design = None
if len(row):
if ("D1" in design) or design == "Design1":
design = "D1"
elif design == "Design1Var":
design = "D1A"
elif ("D2" in design) or design == "Design2":
design = "D2"
elif ("D3" in design) or design == "Design3":
design = "D3"
elif ("D4" in design) or design == "Design4":
design = "D4"
elif ("D5" in design) or design == "Design5":
design = "D5"
elif "TOT115" in m.sampleID:
waferpos = m.sampleID[-2:]
if waferpos in ["21","51","12","42","72","23","53","83","34","64","15","45","75","26","56","86","37","67","28","58"]:
design = "D1"
elif waferpos in ["31","61","22","52","82","33","63","14","44","74","25","55","85","36","66","17","47","77","38","68"]:
design = "D2"
elif waferpos in ["41","71","32","62","13","43","73","24","54","84","35","65","16","46","76","27","57","87","48","78"]:
design = "D3"
else:
raise Exception()
else:
#raise Exception()
found = False
unknowns += 1
print(m.sampleID)
if found:
m.add_property('design', design)
#print(m.sampleID,m['design'])
else:
m.add_property('design', '')
print("Unknowns =", unknowns)
print("Total =", total)
# Save
model.save()
#update_TOT_data()
#Toplogy Optimized Trampoline
def add_property_to_design(design:str,pname:str,pvalue,punit:str):
model = Model()
model.load()
filt = filt_design_type(design)
measurements = [m for m in model.saved_measurements if filt(m)]
for m in measurements:
m.add_property(pname,pvalue,punit)
model.save()
add_property_to_design('Square Membrane Pad','S',1480,'µm')