-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparaview_shell_resources.txt
114 lines (82 loc) · 3.33 KB
/
paraview_shell_resources.txt
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
"""
Source to copy paste-things in the paraview python console
@author: yoav
"""
### main setup ###
if __name__=='__main__':
print("this is not a script, it is a repository for copy-pasting into the paraview shell.")
SOURCE_PATH = r'\\wsl$\Ubuntu-20.04\opt\workspace\msc_project\lab_note_and_py\trisurf-python'
if __name__=='__main__':
raise ImportError("Not A Script!")
# dependencies
from glob import glob
import os
import numpy as np
import sys
sys.path.append(SOURCE_PATH)
try:
import for_paraview as fp
import file
from vtu import PyVtu
import small_functions
SLC=small_functions.Slice
except ImportError as e:
raise ValueError(f"Invalid path {SOURCE_PATH=}: Please update the file with the right path to the modules") from e
# get vtu for the latest file shown (must be on the source!)
def curr_v(): return PyVtu(fp.get_current_file());
loc_sims = r'\\cf-gpfs-fsrv\cf_work\yoavra\sim\bicurvatures\32_engulfing_aligned'
# steal from current path loc_sims/x_####/timetsep_000###.vtu loaded as active source
# loc_sims = os.path.split(os.path.split(fp.get_current_file())[0])[0]
## wait a few minutes to load if remote
frame = file.SimFrame(loc_sims)
keys = [k for k in frame.df.keys() if k not in ['path','timesteps','store']]
if keys!=list(frame.parameters):
print("parameters and frame disagree")
frame.query_subspace('limit your frame e.g. w==0 and k>20 and b==1')
# view specific simulation from frame subspace
# fp.view_simframe_slice(frame, 0, view=None, slc=None, text=None)
# figure out N and M
unique_values = frame.subspace[keys].apply(np.unique,axis=0)
(keyN, N),(keyM, M) = [(k, len(l)) for k,l in unique_values.items() if len(l)!=1]
fast='x'
if N>M:
(N, M, keyN, keyM), fast = (M, N, keyM, keyN), 'y'
print(f"{N}x{M} {keyN}x{keyM}")
grid = fp.GridParaview(N, M) # grid = fp.GridParaview(M, N)
grid.link_views()
# check direction with SetActiveView(grid.views[0,3]) to see where it falls
names = [f'x{x:04}' for x in frame.subspace.index]
params = frame.subspace[keys].to_dict(orient="records")
param_texts = [file.print_params(param) for param in params]
print(param_texts)
views = list(grid.iter_views(fast=fast)) # usually, if inner runs before outer ie 1_f1w0 instead of 1_f0w1
# views = list(grid.iter_views(x=-1, y=-1, fast='y'))
## write text test!###
# param_texts = [file.print_params({keyM: param[keyM],keyN:param[keyN]}) for param in params]
tester = fp.text_test(views, param_texts)
# is it okay?
tester.delete()
for view in views:
view.OrientationAxesVisibility=0
Render(view)
# create load_show:
# a function responsible for loading the ith simulation to the ith view.
time_slc = SLC[:]
load_show_i = fp.make_load_show_i(views, frame, time_slc, names, param_texts)
for i,_ in enumerate(views):
load_show_i(i)
grid.snap_animation()
for view in views:
view.OrientationAxesVisibility = 0
for view, source in grid.sources.items():
GetDisplayProperties(source, view=view).Opacity=0.7
# show some source
# s=GetActiveSource()
# for view in views:
# Show(s,view)
# GetDisplayProperties(s, view=view).AmbientColor=[1/3,1.,1.]
# GetDisplayProperties(s, view=view).DiffuseColor=[1/3,1.,1.]
def transfer(df_old, df_new):
"""To do: fix"""
for source,rpath, path in zip(grid.sources.values(), df_new.path, df_old.path):
source.FileName = [x.replace(rpath,path) for x in source.FileName]