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
c8f46758
Commit
c8f46758
authored
Jun 27, 2017
by
LAMBERT Jean-charles
Browse files
new uns_2dplot.py program
parent
6caad3f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/mains/uns_2dplot.py
0 → 100755
View file @
c8f46758
#!/usr/bin/env python
from
__future__
import
print_function
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
from
simulations.c2dplot
import
*
from
simulations.csnapshot
import
*
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def
commandLine
():
# help
parser
=
argparse
.
ArgumentParser
(
description
=
"Display 2D image from UNS data"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'snapshot'
,
help
=
"uns input snapshot"
,
default
=
None
)
parser
.
add_argument
(
'component'
,
help
=
"selected component"
,
default
=
None
)
parser
.
add_argument
(
'--out'
,
help
=
"if blank display on screen, else on given file "
,
default
=
""
,
type
=
str
)
parser
.
add_argument
(
'--range'
,
help
=
"plot range (X or -A:B) "
,
default
=
35
,
type
=
str
)
parser
.
add_argument
(
'--mergers'
,
help
=
"file to center, or @sim to get file automatically "
,
default
=
None
,
type
=
str
)
parser
.
add_argument
(
'--sigma'
,
help
=
"gaussian sigma "
,
default
=
6.
,
type
=
float
)
parser
.
add_argument
(
'--psort'
,
help
=
"sort particles according to properties"
,
default
=
0
,
type
=
int
)
parser
.
add_argument
(
'--prop'
,
help
=
"properties to plot (age,rho)"
,
default
=
""
,
type
=
str
)
parser
.
add_argument
(
'--pfname'
,
help
=
"print filename (1:True, 0:False)"
,
default
=
1
,
type
=
int
)
parser
.
add_argument
(
'--cb'
,
help
=
"display color bar (1:True, 0:False)"
,
default
=
0
,
type
=
int
)
parser
.
add_argument
(
'--cmap'
,
help
=
"color map (see mathplotlib colormap)"
,
default
=
"jet"
)
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode'
,
dest
=
"verbose"
,
action
=
"store_true"
,
default
=
False
)
# parse
args
=
parser
.
parse_args
()
# start main funciton
process
(
args
)
# -----------------------------------------------------
# process, is the core function
def
process
(
args
):
try
:
uns
=
CSnapshot
(
args
.
snapshot
,
args
.
component
,
verbose_debug
=
args
.
verbose
)
ok
=
uns
.
nextFrame
(
""
)
if
ok
:
c
=
C2dplot
(
verbose_debug
=
args
.
verbose
)
c
.
fullProcess
(
uns
=
uns
,
out
=
args
.
out
,
component
=
args
.
component
,
xrange
=
int
(
args
.
range
),
sigma
=
args
.
sigma
,
mergers
=
args
.
mergers
,
cmap
=
args
.
cmap
)
else
:
print
(
"[%s] is not a UNS snapshot ..."
%
(
simname
))
except
Exception
as
x
:
print
(
x
.
message
,
file
=
sys
.
stderr
)
except
KeyboardInterrupt
:
sys
.
exit
()
# -----------------------------------------------------
# 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