Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtexture.py
More file actions
Latest commit
40 lines (33 loc) · 1.76 KB
/
Copy pathtexture.py
File metadata and controls
40 lines (33 loc) · 1.76 KB
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
frommatflowimportload_workflow
frompathlibimportPath
fromdamaskimportVTK
importdamask ; fromdamaskimportGrid
importsys
importmatplotlib.pyplotasplt
fromtqdmimporttqdm
importdefdap
fromdefdap.quatimportQuat
importh5py
importre
importnumpyasnp
importos
importshutil# "
importmatplotlib
defwrite_quat_txts(workflow_path, phase):
"""Extract quaternions from a workflow result dir to a numpy array, write array to .txt file for MTEX"""
workflow=load_workflow(workflow_path)
fortasknuminrange(0, len(workflow.tasks)):
if"simulate_volume_element_loading"instr(workflow.tasks[tasknum].unique_name):
print(f"Extracting quaternions from task_{str(tasknum+1)}_{workflow.tasks[tasknum].name}...")
Path(workflow_path+"/task_"+str(tasknum+1)+"_"+workflow.tasks[tasknum].unique_name+"/"+phase+"_oris/").mkdir(parents=True, exist_ok=True)
oris=workflow.tasks[tasknum].elements[0].outputs.volume_element_response['phase_data'][phase+'_orientations']['data']['quaternions']
n_incs=oris.shape[0] # oris=(n_incs, n_quats, n_quatcomps)
forincinrange(0, n_incs):
quat_txt=open(workflow_path+"/task_"+str(tasknum+1)+"_"+workflow.tasks[tasknum].unique_name+"/"+phase+"_oris/"+phase+"_inc"+str(inc)+"_oris.txt",'w')
quat_txt.write("xyzw\n")
n_quats=oris.shape[1]
forquat_numinrange(0, n_quats):
quat=oris[inc, quat_num]
quat_txt.write(" %.15f %.15f %.15f %.15f\n"\
%(quat[0], quat[1], quat[2], quat[3]))
print(f"Saved to {workflow_path}task_{tasknum+1}_{workflow.tasks[tasknum].name}/{phase}_oris/")