-
Notifications
You must be signed in to change notification settings - Fork 1
/
rezone.py
executable file
·85 lines (67 loc) · 2.08 KB
/
rezone.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
#!/usr/bin/env python3
# #!/usr/bin/python3
import getopt
import os
import sys
from os.path import dirname
import matplotlib.pyplot as plt
from pystella.model.stella import Stella
__author__ = 'bakl'
ROOT_DIRECTORY = dirname(dirname(os.path.abspath(__file__)))
def usage():
print("\n Create hyd- abn-files from res-file.")
print("Usage:")
print(" rezone.py [params]")
print(" -i <model name>. Example: cat_R450_M15_Ni007_E7")
# print(" -n new zon number, default: 100")
print(" -p <model path(directory)>, default: ./")
print(" -s silence mode: no info, no plot")
print(" -t time moment, default: 10")
print(" -h print usage")
def main(name=False):
is_silence = False
t = 1 # days
path = os.getcwd()
try:
opts, args = getopt.getopt(sys.argv[1:], "hsp:i:t:")
except getopt.GetoptError as err:
print(str(err)) # will print something like "option -a not recognized"
usage()
sys.exit(2)
if not name:
if len(opts) == 0:
usage()
sys.exit(2)
for opt, arg in opts:
if opt == '-i':
path = ROOT_DIRECTORY
name = str(arg)
break
for opt, arg in opts:
if opt == '-s':
is_silence = True
continue
if opt == '-t':
t = float(arg)
continue
if opt == '-p':
path = os.path.expanduser(str(arg))
if not (os.path.isdir(path) and os.path.exists(path)):
print("No such directory: " + path)
sys.exit(2)
continue
elif opt == '-h':
usage()
sys.exit(2)
model = Stella(name, path=path)
if not model.is_res:
print("There are no %s in the directory: %s " % (name, path))
res = model.get_res()
block = res.read_at_time(time=t)
print("Len(block) = %i " % len(block))
if not is_silence:
plt.plot(block['M'], block['V8'])
plt.show()
# write_data(res, path, fname=name)
if __name__ == '__main__':
main()