-
Notifications
You must be signed in to change notification settings - Fork 0
/
read.py
89 lines (70 loc) · 2.37 KB
/
read.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
# Read routine for analysis pictures
from pskf.tools.plot import specs as sc
from pskf.tools.plot import plotfunctions as pf
from pskf.tools.run import runmodule as rm
from pskf.tools.run import pythonmodule as pm
import pskf.scripts.analysis.arrays as aa
def read(
model_name,
dat,
let,
varname='kz_mean',
befaft='aft',
fdir=None,
fname=None,
nt=10,
):
"""
Reading variable arrays from SHEMAT-Suite.
Parameters
----------
model_name : string
String of model name.
dat : string
String with date of model run.
let : string
String of letter of model run.
varname : string
Variable name for array to be read.
Possibilities: 'kz_mean' 'kz_std','head_mean','lz_mean', 'temp_mean'
befaft : string
Specifies whether the output is read in from
before ('bef') or after ('aft') the EnKF update.
nt : integer
Number inside file name.
fdir : string
Full directory of vtk file.
fname : string
Full name of vtk file.
Returns
-------
numpy_array : array
Array containing the variable array
numpy_array_name : string
Containing proposed saving location for Array.
"""
# Automatic file name generation
if (not fdir and not fname):
# enkf_output_dir
fdir = rm.make_output_dirs(model_name, dat, let)[2]
if befaft == 'aft':
# assim_out_file_aft
fname = rm.make_file_dir_names(model_name, nt)[19]
elif befaft == 'bef':
# assim_out_file_bef
fname = rm.make_file_dir_names(model_name, nt)[18]
# Get vtk_reader ##########################################################
vtk_reader = pf.my_vtk(fdir, fname, varname)
# Debug ###################################################################
print(varname,
vtk_reader.GetOutput().GetCellData().GetArray(0).GetValueRange())
# Numpy Array ############################################################
numpy_array = pf.my_vtk_to_numpy(vtk_reader)
# Numpy Array Name ########################################################
numpy_array_name = pm.py_output_filename(
aa.tag,
varname+'_'+str(nt).zfill(4)+'_'+befaft,
sc.specl(model_name, dat, let),
"npy"
)
return numpy_array, numpy_array_name