Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LAMBERT Jean-charles
uns_projects
Commits
73214b88
Commit
73214b88
authored
Mar 23, 2017
by
LAMBERT Jean-charles
Browse files
print out *.npy from TB analysis
parent
dc81ab71
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/mains/print_tbd.py
0 → 100755
View file @
73214b88
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
import
numpy
as
np
import
argparse
from
uns_simu
import
*
import
os.path
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def
commandLine
():
# help
parser
=
argparse
.
ArgumentParser
(
description
=
"Print xxx.npy file belonging to TBD analysis directory"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'npy'
,
help
=
'simulation name OR TBD npy file'
)
parser
.
add_argument
(
'--rect'
,
help
=
'rectify (0 or 1)'
,
default
=
1
,
type
=
int
)
args
=
parser
.
parse_args
()
# start main funciton
process
(
args
)
# -----------------------------------------------------
#
def
checkSimu
(
simname
):
sql3
=
UnsSimu
()
#sql3.printInfo(simname)
r
=
sql3
.
getInfo
(
simname
)
if
(
r
)
:
tbd_dir
=
r
[
'dir'
]
+
'/ANALYSIS/Tbd'
tbd_f_yes
=
tbd_dir
+
'/frac_jj_'
+
simname
+
"_rectyes.npy"
tbd_f_no
=
tbd_dir
+
'/frac_jj_'
+
simname
+
"_rect.npy"
return
tbd_dir
,
tbd_f_yes
,
tbd_f_no
else
:
print
(
"
\n
Unknown simulation : ["
,
simname
,
"]
\n
"
)
return
None
,
None
,
None
# -----------------------------------------------------
# process, is the core function
def
process
(
args
):
fnpy
=
args
.
npy
if
(
not
os
.
path
.
exists
(
fnpy
)):
dnpy
,
fnpy_yes
,
fnpy_no
=
checkSimu
(
args
.
npy
)
if
args
.
rect
!=
0
:
fnpy
=
fnpy_yes
else
:
fnpy
=
fnpy_no
try
:
data
=
np
.
load
(
fnpy
)
except
:
print
(
"
\n
Unable to load file [%s]
\n
"
%
(
fnpy
))
sys
.
exit
()
for
i
in
range
(
data
.
size
/
3
):
print
(
' '
.
join
(
map
(
str
,
data
[:,
i
])))
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment