Toggle navigation
Fosite
About
Gallery
Documentation
Contact
Download
Impressum
src
tools
plot
bin2dat.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
from
read
import
read
3
import
numpy
as
np
4
import
sys
5
from
string
import
join
6
7
if
__name__==
"__main__"
:
8
if
len(sys.argv) > 1:
9
f =
read
(sys.argv[1])
10
keys = f.keys()
11
12
# filter out directories
13
keys = [ k
for
k
in
keys
if
not
k.endswith(
'/.'
)]
14
15
# get /config directory
16
config = [ k
for
k
in
keys
if
k.startswith(
'/config/'
) ]
17
prefix =
''
18
for
k
in
sorted(config):
19
val = f[k]
20
key = k[7:]
21
p, postfix = key.rsplit(
'/'
,1)
22
p = p[1:]
23
if
prefix!=p:
24
prefix = p
25
print
"# [{0}]"
.format(prefix)
26
print
"#{:>23}:{:>14}"
.format(postfix,val)
27
28
# get all data items (the rest)
29
data = [ k
for
k
in
keys
if
not
k.startswith(
'/config/'
) ]
30
outkeys = list()
31
for
k
in
data:
32
val = f[k]
33
if
type(val) == np.ndarray
and
len(val.shape)==2 \
34
and
val.shape[0]==f[
'/config/mesh/inum'
]
and
val.shape[1]==f[
'/config/mesh/jnum'
]:
35
outkeys.append(k)
36
outkeys = sorted(outkeys)
37
ks = [ i.rsplit(
'/'
,1)[1]
for
i
in
outkeys ]
38
print
"# "
,join(ks,
'\t'
)
39
for
i
in
f:
40
vals = [f[k]
for
k
in
outkeys]
41
for
a
in
np.nditer(vals):
42
a = [
"%.4e"
% np.float64(i)
for
i
in
a ]
43
print
" "
,join(a,
'\t'
)
44
print
"\n"
45
read.read
Definition:
read.py:21
Generated by
1.8.14