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
7c6fda7d
Commit
7c6fda7d
authored
Oct 31, 2018
by
LAMBERT Jean-charles
Browse files
refactoring...
parent
3944b8de
Changes
35
Hide whitespace changes
Inline
Side-by-side
py/mains/build_metal_simdir.py
View file @
7c6fda7d
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
from
simulations.cmovie
import
*
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
unsiotools.
simulations.cmovie
import
*
import
argparse
import
os
,
glob
,
subprocess
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
...
...
@@ -16,7 +16,7 @@ def commandLine():
parser
=
argparse
.
ArgumentParser
(
description
=
"Build directory for new metal simulation"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'srcdir'
,
help
=
'src directory ie : 30_idf401_init_gal3_-2_0.45'
)
parser
.
add_argument
(
'destdir'
,
help
=
"dest directory ei: /rydata/mdf/idf401_01"
)
...
...
@@ -26,8 +26,8 @@ def commandLine():
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode on'
,
dest
=
"verbose"
,
action
=
"store_true"
,
default
=
False
)
# parse
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# start main funciton
process
(
args
)
...
...
py/mains/build_rectfile.py
View file @
7c6fda7d
...
...
@@ -5,10 +5,10 @@ import sys
import
argparse
,
textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
simulations.crectify
import
*
from
unsiotools.
simulations.crectify
import
*
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
# help
...
...
@@ -39,11 +39,9 @@ def process(args):
c
.
buildRectFile
(
simname
=
args
.
simname
,
ev_in
=
args
.
ev
,
rect_out
=
args
.
rect
)
except
Exception
as
x
:
print
(
x
.
message
)
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/g3cpu_parse.py
View file @
7c6fda7d
...
...
@@ -5,7 +5,7 @@ import matplotlib.pyplot as plt
# cnd line
import
sys
,
getopt
,
os
.
path
#sys.path.append('/home/jcl/works/SVN/uns_projects/trunk/py/modules/')
from
uns_simu
import
*
from
unsiotools.
uns_simu
import
*
import
argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
...
...
@@ -53,11 +53,11 @@ def main(argv):
#if len(gparam)>1:
# dt = float(gparam['MaxSizeTimestep'])
# print "Overwrite dt from gadget.patam = ",dt
for
f
in
file
.
split
(
","
):
try
:
cpu_file
,
mylegend
=
f
.
split
(
":"
)
# parse filename:legend
except
ValueError
:
f_label
=
f
cpu_file
=
f
...
...
@@ -76,7 +76,7 @@ def main(argv):
else
:
print
"Simulation ["
,
cpu_file
,
"] does not exist in unsio database..."
sys
.
exit
()
time
,
cpu
,
ncores
=
parseCPU
(
cpu_file
,
dt
,
tf
,
tl
)
f_label
=
f_label
+
" cpus=%d"
%
ncores
if
tmax
>
0
and
(
tmax
-
time
[
-
1
])
>
0.01
:
...
...
@@ -100,13 +100,13 @@ def main(argv):
else
:
plt
.
plot
(
time
,
cpu
,
label
=
f_label
)
plt
.
xlabel
(
'Simulation time'
)
plt
.
ylabel
(
'Cpu time (seconds)'
)
plt
.
title
(
'Cpu time every dt='
+
'%f'
%
dt
)
leg
=
plt
.
legend
(
loc
=
'best'
,
fancybox
=
True
)
leg
.
get_frame
().
set_alpha
(
0.5
)
if
(
out
==
''
):
plt
.
show
()
else
:
...
...
@@ -114,7 +114,7 @@ def main(argv):
plt
.
savefig
(
out
)
#, bbox_inches=0)
plt
.
close
(
fig
)
sys
.
exit
()
# Parse gadget.param file and return a dictionary key pair value
...
...
@@ -144,7 +144,7 @@ def getHMS(sec,tag):
mins
=
sec
/
60
sec
-=
60
*
mins
dhms
=
"%s :%dd %dh %dmn %ds"
%
(
tag
,
days
,
hrs
,
mins
,
sec
)
print
dhms
return
dhms
...
...
@@ -163,7 +163,7 @@ def parseCPU(file,dt,tf,tl):
cputotlast
=
0.0
cputot
=
0.0
ncores
=
0
for
line
in
a
:
if
line
.
startswith
(
"Step"
):
# Step line
if
(
tl
!=
-
1
and
t
>
tl
):
# exit if time last reach
...
...
@@ -172,8 +172,8 @@ def parseCPU(file,dt,tf,tl):
if
first
:
ncores
=
int
(
line
.
split
()[
5
])
cputot
=
float
(
a
.
next
().
split
()[
1
])
# get from next line cpu time
if
(
t
>=
tf
and
first
):
# time >= time first and first
if
(
t
>=
tf
and
first
):
# time >= time first and first
tlast
=
t
# save time
cputotlast
=
cputot
# save cpu time
first
=
False
...
...
@@ -220,7 +220,7 @@ def printHelp(prog,file,dt,tf,tl,out,smooth):
smooth : curve fit smoothing.... [%d]
"""
print
help
%
(
prog
,
file
,
dt
,
tf
,
tl
,
out
,
smooth
)
print
help
%
(
prog
,
file
,
dt
,
tf
,
tl
,
out
,
smooth
)
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
0
:])
py/mains/link_continue_snapshot.py
View file @
7c6fda7d
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
import
argparse
import
os
,
glob
import
errno
...
...
py/mains/link_snapshot.py
View file @
7c6fda7d
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
from
simulations.cmovie
import
*
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#
from simulations.cmovie import *
import
argparse
import
os
,
glob
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
...
...
@@ -16,15 +16,15 @@ def commandLine():
parser
=
argparse
.
ArgumentParser
(
description
=
"Link snapshot with one unit incremental"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'snapshot'
,
help
=
'snapshot path, ie : runs/snapshot'
)
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode on'
,
dest
=
"verbose"
,
action
=
"store_true"
,
default
=
False
)
# parse
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# start main funciton
process
(
args
)
...
...
@@ -37,7 +37,7 @@ def process(args):
snap_list
=
snap_list
+
sorted
(
glob
.
glob
(
args
.
snapshot
+
'_???'
))
snap_list
=
snap_list
+
sorted
(
glob
.
glob
(
args
.
snapshot
+
'_????'
))
snap_list
=
snap_list
+
sorted
(
glob
.
glob
(
args
.
snapshot
+
'_?????'
))
cpt
=
0
for
mysnap
in
snap_list
:
mylink
=
"snapshot_"
+
str
(
cpt
)
...
...
py/mains/mdf_build_continue.py
100644 → 100755
View file @
7c6fda7d
#!/usr/bin/env python
import
sys
from
uns_simu
import
*
from
simulations.ccod
import
*
#
from
unsiotools.
uns_simu import *
#
from simulations.ccod import *
import
argparse
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
ncores
=
None
...
...
@@ -32,9 +32,9 @@ def commandLine():
# -----------------------------------------------------
# process, is the core function
def
process
(
args
):
pass
# -----------------------------------------------------
# main program
...
...
py/mains/merging_time.py
View file @
7c6fda7d
...
...
@@ -2,13 +2,13 @@
from
__future__
import
print_function
import
sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
uns_simu
import
*
from
simulations.ccod
import
*
#
from
unsiotools.
uns_simu import *
from
unsiotools.
simulations.ccod
import
*
import
argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
ncores
=
None
...
...
@@ -22,7 +22,7 @@ def commandLine():
parser
=
argparse
.
ArgumentParser
(
description
=
"Display merging time"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'simname'
,
help
=
'Simulation name'
)
parser
.
add_argument
(
'--dmax'
,
help
=
'max distance of separation (kpc)'
,
default
=
dmax
,
type
=
float
)
parser
.
add_argument
(
'--cod1'
,
help
=
'first cod file'
,
default
=
cod1
)
...
...
@@ -39,8 +39,8 @@ def commandLine():
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
pngfile
==
"None"
:
args
.
pngfile
=
None
# start main funciton
...
...
@@ -59,7 +59,7 @@ def process(args):
except
KeyboardInterrupt
:
sys
.
exit
()
# -----------------------------------------------------
# main program
...
...
py/mains/op_file_dir.py
View file @
7c6fda7d
...
...
@@ -2,17 +2,16 @@
from
__future__
import
print_function
import
sys
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from py_unstools import * # import py_unstools package
from
unsio
import
*
from
uns_simu
import
*
from
general.ctools
import
*
#from unsio import *
#from general.ctools import *
import
argparse
import
os
,
subprocess
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
...
...
py/mains/post_build_movie.py
View file @
7c6fda7d
...
...
@@ -2,12 +2,12 @@
from
__future__
import
print_function
import
sys
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
simulations.cmovie
import
*
from
unsiotools.
simulations.cmovie
import
*
import
argparse
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
...
...
@@ -15,7 +15,7 @@ def commandLine():
parser
=
argparse
.
ArgumentParser
(
description
=
"Build simulation movie after smart analysis"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'simname'
,
help
=
'Simulation name'
)
parser
.
add_argument
(
'--dbname'
,
help
=
'UNS database file name'
,
default
=
dbname
)
...
...
@@ -25,7 +25,7 @@ def commandLine():
#parser.add_argument('--no-verbose',help='verbose mode off', dest="verbose", action="store_false", default=True)
# parse
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# start main funciton
process
(
args
)
...
...
@@ -42,7 +42,7 @@ def process(args):
print
(
x
.
message
)
sys
.
exit
()
# -----------------------------------------------------
# main program
...
...
py/mains/print_tbd.py
View file @
7c6fda7d
...
...
@@ -4,10 +4,10 @@ from __future__ import print_function
import
sys
import
numpy
as
np
import
argparse
from
uns_simu
import
*
import
os.path
from
unsiotools.
uns_simu
import
*
import
os.path
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
# help
...
...
@@ -23,11 +23,11 @@ def commandLine():
process
(
args
)
# -----------------------------------------------------
#
#
def
checkSimu
(
simname
):
sql3
=
UnsSimu
()
#sql3.printInfo(simname)
r
=
sql3
.
getInfo
(
simname
)
if
(
r
)
:
tbd_dir
=
r
[
'dir'
]
+
'/ANALYSIS/Tbd'
...
...
@@ -41,7 +41,7 @@ def checkSimu(simname):
# -----------------------------------------------------
# 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
)
...
...
@@ -58,7 +58,7 @@ def process(args):
for
i
in
range
(
data
.
size
/
3
):
print
(
' '
.
join
(
map
(
str
,
data
[:,
i
])))
# -----------------------------------------------------
# main program
...
...
py/mains/process_analysis.py
View file @
7c6fda7d
...
...
@@ -9,14 +9,14 @@ import numpy as np
import
argparse
import
matplotlib
matplotlib
.
use
(
'Agg'
)
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
simulations.cuns_analysis
import
*
from
unsiotools.
simulations.cuns_analysis
import
*
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
ncores
=
None
...
...
@@ -32,7 +32,7 @@ def commandLine():
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode'
,
default
=
False
)
print
(
"Matplotlib backend Using:"
,
matplotlib
.
get_backend
(),
file
=
sys
.
stderr
)
# parse
args
=
parser
.
parse_args
()
...
...
@@ -49,12 +49,9 @@ def process(args):
print
(
x
.
message
)
else
:
analysis
.
compute
(
args
.
ncores
)
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/remove_sim_halo.py
View file @
7c6fda7d
...
...
@@ -2,19 +2,18 @@
from
__future__
import
print_function
import
sys
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
#from py_unstools import * # import py_unstools package
from
unsio
import
*
from
uns_simu
import
*
import
argparse
import
os
,
subprocess
from
simulations.creducesim
import
*
from
unsiotools.
simulations.creducesim
import
*
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
...
...
@@ -49,6 +48,3 @@ def process(args):
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/stat_orbits.py
View file @
7c6fda7d
...
...
@@ -8,12 +8,12 @@ import argparse,textwrap
#sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
import
simulations.corbits
as
orbs
import
unsiotools.
simulations.corbits
as
orbs
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
# help
...
...
@@ -47,8 +47,8 @@ def process(args):
new_data
=
np
.
load
(
mypath
+
"/orbits_"
+
str
(
index
)
+
"_data.npy"
)
new_time
=
np
.
load
(
mypath
+
"/orbits_"
+
str
(
index
)
+
"_time.npy"
)
if
first
:
first
=
False
tab_data
=
np
.
zeros
((
new_data
[:,
0
].
size
,
23
))
# id (0) t/dmax (1-8) t/dmin (9-16) t/|x| (17-18) t/|y| (19-20) t/|z| (21-22)
first
=
False
tab_data
=
np
.
zeros
((
new_data
[:,
0
].
size
,
23
))
# id (0) t/dmax (1-8) t/dmin (9-16) t/|x| (17-18) t/|y| (19-20) t/|z| (21-22)
tab_data
[:,
0
]
=
new_data
[:,
0
]
# ids
tab_data
[:,
index_dmax
]
=
new_data
[:,
1
:
5
]
# dmax
...
...
@@ -62,7 +62,7 @@ def process(args):
print
(
i
)
v
=
np
.
where
(
new_data
[:,
ii
]
>
tab_data
[:,
i
])
tab_data
[
v
,
i
]
=
new_data
[
v
,
ii
]
# copy new dmax
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
ii
=
ii
+
1
# proceed on min
ii
=
1
...
...
@@ -70,7 +70,7 @@ def process(args):
print
(
i
)
v
=
np
.
where
(
new_data
[:,
ii
]
<
tab_data
[:,
i
])
tab_data
[
v
,
i
]
=
new_data
[
v
,
ii
]
# copy new dmin
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
ii
=
ii
+
1
# proceed on |x| |y| |z|
ii
=
1
...
...
@@ -78,7 +78,7 @@ def process(args):
print
(
i
)
v
=
np
.
where
(
new_data
[:,
ii
]
>
tab_data
[:,
i
])
tab_data
[
v
,
i
]
=
new_data
[
v
,
ii
]
# copy new |value|
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
tab_data
[
v
,
i
-
1
]
=
new_time
# copy new time
ii
=
ii
+
1
nn
=
nn
+
1
if
nn
==
-
1
:
...
...
@@ -88,8 +88,8 @@ def process(args):
if
args
.
outfile
is
not
None
:
outfile
=
args
.
outfile
np
.
save
(
outfile
,
tab_data
)
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
...
...
py/mains/uns_2dpgplot.py
View file @
7c6fda7d
...
...
@@ -5,13 +5,13 @@ import numpy as np
import
os
,
time
import
sys
import
argparse
,
textwrap
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
,
'/home/jcl/works/GIT/uns_projects/py/modules/simulations'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/','/home/jcl/works/GIT/uns_projects/py/modules/simulations']+sys.path
from
simulations.c2dpgplot
import
*
from
simulations.csnapshot
import
*
from
unsiotools.
simulations.c2dpgplot
import
*
from
unsiotools.
simulations.csnapshot
import
*
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
# help
...
...
@@ -42,18 +42,19 @@ def process(args):
uns
=
CSnapshot
(
args
.
snapshot
,
args
.
component
,
verbose_debug
=
args
.
verbose
)
ok
=
uns
.
nextFrame
(
""
)
if
ok
:
print
(
"here 0"
)
c
=
C2dpgplot
()
#print("here 1")
c
.
draw
(
uns_snap
=
uns
,
select
=
args
.
component
,
outdev
=
args
.
dev
,
rrange
=
args
.
range
,
\
prop
=
args
.
prop
,
psort
=
args
.
psort
,
pfname
=
args
.
pfname
,
cb
=
args
.
cb
,
cmap
=
args
.
cmap
)
#print("here 2")
else
:
print
(
"[%s] is not a UNS snapshot ..."
%
(
simname
))
except
Exception
as
x
:
print
(
x
.
message
)
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/uns_2dplot.py
View file @
7c6fda7d
...
...
@@ -5,11 +5,11 @@ import numpy as np
import
os
,
time
import
sys
import
argparse
,
textwrap
sys
.
path
=
[
'/home/jcl/works/GIT/uns_projects/py/modules/'
]
+
sys
.
path
#
sys.path=['/home/jcl/works/GIT/uns_projects/py/modules/']+sys.path
#from IPython import embed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
# commandLine, parse the command line
def
commandLine
():
# help
...
...
@@ -38,9 +38,9 @@ def commandLine():
parser
.
add_argument
(
'--nc'
,
help
=
'#levels contour'
,
default
=
20
,
type
=
int
)
parser
.
add_argument
(
'--cpt'
,
help
=
"index of the image (out.cpt.jpg)"
,
default
=
0
,
type
=
int
)
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode'
,
dest
=
"verbose"
,
action
=
"store_true"
,
default
=
False
)
#parser.print_help()
# parse
args
=
parser
.
parse_args
()
...
...
@@ -48,22 +48,22 @@ def commandLine():
import
general.ctools
as
ct
ct
.
displayColormap
()
sys
.
exit
()
# start main funciton
process
(
args
)
# -----------------------------------------------------
# process, is the core function
def
process
(
args
):
# select matplotlib backend
# select matplotlib backend
if
args
.
out
!=
""
:
# non interactive
import
matplotlib
matplotlib
.
use
(
'Agg'
)
# we import this modules here because
# matplotlib.use() must be done before importing matplotlib.pyplot
import
simulations.c2dplot
as
c2d
import
simulations.csnapshot
as
csnap
import
unsiotools.
simulations.c2dplot
as
c2d
import
unsiotools.
simulations.csnapshot
as
csnap
try
:
cpt
=
args
.
cpt
uns
=
csnap
.
CSnapshot
(
args
.
snapshot
,
args
.
component
,
verbose_debug
=
args
.
verbose
)
...
...
@@ -81,11 +81,9 @@ def process(args):
print
(
x
.
message
,
file
=
sys
.
stderr
)
except
KeyboardInterrupt
:
sys
.
exit
()
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
: