-
Notifications
You must be signed in to change notification settings - Fork 5
/
pylbo_wrapper.py
57 lines (48 loc) · 1.56 KB
/
pylbo_wrapper.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
import os
import sys
from argparse import ArgumentParser
from pathlib import Path
# Search for Pylbo in $LEGOLASDIR/post_processing.
if "LEGOLASDIR" in os.environ.keys():
_pylbo_path = Path(os.environ["LEGOLASDIR"]).joinpath("post_processing")
if _pylbo_path.is_dir():
sys.path.append(str(_pylbo_path.resolve()))
# Else search for Pylbo in ./post_processing, if possible.
elif "__file__" in globals():
_pylbo_path = Path(__file__).parent.joinpath("post_processing")
if _pylbo_path.is_dir():
sys.path.append(str(_pylbo_path.resolve()))
try:
import pylbo
except ModuleNotFoundError as e:
print("ERROR: Failed to load Pylbo")
print(" ", e.args[0])
print()
print(
"Check if $LEGOLASDIR is configured correctly and all of Pylbo's",
"dependencies are available, or install Pylbo as a package.",
)
exit(1)
def _main():
parser = ArgumentParser()
parser.add_argument("-i", "--datfile", dest="datfile")
args = parser.parse_args()
datfile = args.datfile
if datfile is None:
datfile = Path("output/datfile.dat").resolve()
if not datfile.is_file():
raise FileNotFoundError(datfile)
ds = pylbo.load(datfile)
pylbo.plot_equilibrium(ds)
p = pylbo.plot_spectrum(ds, use_residuals=ds.has_residuals)
p.add_continua()
if ds.has_efs:
p.add_eigenfunctions()
if ds.has_derived_efs:
p2 = pylbo.plot_spectrum(ds)
p2.add_continua()
p2.add_derived_eigenfunctions()
p2.draw()
p.show()
if __name__ == "__main__":
_main()