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
133f8d2d
Commit
133f8d2d
authored
Aug 16, 2018
by
LAMBERT Jean-charles
Browse files
some useful programs
parent
8936f358
Changes
4
Hide whitespace changes
Inline
Side-by-side
py/mains/build_metal_simdir.py
0 → 100755
View file @
133f8d2d
#!/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
*
import
argparse
import
os
,
glob
,
subprocess
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
# help
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"
)
parser
.
add_argument
(
'--basedir'
,
help
=
"basedir of sergey''s run with new metalicity"
,
default
=
"/home/seger/data/accretion_project/workspace/untop_runs"
)
parser
.
add_argument
(
'--verbose'
,
help
=
'verbose mode on'
,
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
):
if
not
os
.
path
.
isdir
(
args
.
destdir
):
print
(
"create dir [%s]"
%
(
args
.
destdir
))
os
.
makedirs
(
args
.
destdir
)
mylink
=
args
.
destdir
+
"/run"
metaldir
=
args
.
basedir
+
"/"
+
args
.
srcdir
print
(
"metaldir : "
,
metaldir
)
if
not
os
.
path
.
islink
(
mylink
)
and
os
.
path
.
isdir
(
metaldir
):
print
(
"gonna link :"
,
mylink
,
" on "
,
metaldir
)
os
.
symlink
(
metaldir
,
mylink
)
simname
=
args
.
destdir
.
split
(
'/'
)[
-
1
]
cmd
=
"unsio_sql3_update_info.pl --simname %s --type Gadget --dir %s --base run/untop_run/snapshot"
%
(
simname
,
args
.
destdir
)
print
(
cmd
)
subprocess
.
call
(
cmd
,
shell
=
True
)
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/link_snapshot.py
0 → 100755
View file @
133f8d2d
#!/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
*
import
argparse
import
os
,
glob
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
# help
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
()
# start main funciton
process
(
args
)
# -----------------------------------------------------
# process, is the core function
def
process
(
args
):
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
+
'_???'
))
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
)
if
not
os
.
path
.
islink
(
mylink
):
print
(
mysnap
,
"snapshot_"
+
str
(
cpt
))
os
.
symlink
(
mysnap
,
mylink
)
cpt
=
cpt
+
1
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/mains/op_file_dir.py
0 → 100755
View file @
133f8d2d
#!/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 py_unstools import * # import py_unstools package
from
py_unsio
import
*
from
uns_simu
import
*
from
general.ctools
import
*
import
argparse
import
os
,
subprocess
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# commandLine, parse the command line
def
commandLine
():
dbname
=
None
# help
parser
=
argparse
.
ArgumentParser
(
description
=
"test operation on files and directories"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
# options
parser
.
add_argument
(
'file'
,
help
=
'input file, dir or link name'
)
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
):
r
,
f
=
rotateFile
(
args
.
file
,
debug
=
True
)
print
(
r
,
f
)
# -----------------------------------------------------
# process, is the core function
def
process1
(
args
):
if
os
.
path
.
exists
(
args
.
file
):
print
(
"yes [%s] exist.."
%
(
args
.
file
),
file
=
sys
.
stderr
)
rotateFile
(
args
.
file
)
def
rotate
(
myfile
):
cpt
=
0
stop
=
False
while
not
stop
:
myfile
=
"%s.%d"
%
(
myfile
,
cpt
)
if
not
os
.
path
.
exists
(
myfile
):
stop
=
True
else
:
cpt
=
cpt
+
1
print
(
"Rotate file [%s]"
%
(
myfile
))
# -----------------------------------------------------
# main program
if
__name__
==
'__main__'
:
commandLine
()
py/modules/simulations/corbits.py
0 → 100644
View file @
133f8d2d
#!/usr/bin/python
from
__future__
import
print_function
from
ctree
import
*
from
csnapshot
import
*
from
uns_simu
import
*
import
ccod
as
cod
import
time
import
os
,
sys
import
numpy
as
np
import
math
import
time
#from IPython import embed
#
# ----
#
class
COrbits
:
"""
Compute quantities on orbits
"""
#
# ----
#
__uns
=
None
def
__init__
(
self
,
analysis
=
None
,
snapshot
=
None
,
sname
=
None
,
component
=
"disk"
,
verbose
=
False
,
verbose_debug
=
False
):
# instantiate CSnapshot
#self.__uns=CSnapshot(snapshot,component,verbose_debug=self.__vdebug)
pass
#
# ----
#
def
computeDistance
(
self
,
snapshot
,
component
,
outfile
,
codfile
):
snap
=
CSnapshot
(
snapshot
,
component
)
ok
=
snap
.
nextFrame
(
""
)
if
ok
:
ok1
,
pos
=
snap
.
getData
(
component
,
"pos"
)
ok2
,
id
=
snap
.
getData
(
component
,
"id"
)
ok3
,
tps
=
snap
.
getData
(
"time"
)
if
ok1
and
ok2
and
ok3
:
ok
,
tcxv
=
cod
.
CCod
(
None
).
getCodFromFile
(
codfile
,
tps
)
if
ok
:
x
=
pos
[
0
::
3
]
y
=
pos
[
1
::
3
]
z
=
pos
[
2
::
3
]
d1
=
np
.
sqrt
((
x
-
tcxv
[
1
])
**
2
+
(
y
-
tcxv
[
2
])
**
2
)
d2
=
np
.
sqrt
((
x
-
tcxv
[
1
])
**
2
+
(
y
-
tcxv
[
2
])
**
2
+
(
z
-
tcxv
[
3
])
**
2
)
d3
=
np
.
sqrt
((
x
-
tcxv
[
1
])
**
2
+
(
z
-
tcxv
[
3
])
**
2
)
d4
=
np
.
sqrt
((
y
-
tcxv
[
2
])
**
2
+
(
z
-
tcxv
[
3
])
**
2
)
xc
=
np
.
abs
(
x
-
tcxv
[
1
])
yc
=
np
.
abs
(
x
-
tcxv
[
2
])
zc
=
np
.
abs
(
x
-
tcxv
[
3
])
# time array
ta
=
np
.
zeros
(
1
)
ta
=
tps
np
.
save
(
outfile
+
"_data"
,
np
.
column_stack
((
id
,
d1
,
d2
,
d3
,
d4
,
xc
,
yc
,
zc
)))
np
.
save
(
outfile
+
"_time"
,
ta
)
else
:
print
(
"No cod at time [%f]"
%
(
tps
),
file
=
sys
.
stderr
)
else
:
print
(
"Unable to read all the arrays..."
,
ok1
,
ok2
,
ok3
,
file
=
sys
.
stderr
)
pass
else
:
print
(
"snap.nextFrame() failed....
\n
"
,
file
=
sys
.
stderr
)
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