Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97610540
mockimgs_sb_addfields
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 5, 17:06
Size
4 KB
Mime Type
text/x-python
Expires
Tue, Jan 7, 17:06 (2 d)
Engine
blob
Format
Raw Data
Handle
23366367
Attached To
rARRAKIHS ARRAKIHS
mockimgs_sb_addfields
View Options
#!/usr/bin/python3
import
argparse
import
numpy
as
np
from
pNbody
import
*
####################################################################
# option parser
####################################################################
description
=
""
epilog
=
""""""
parser
=
argparse
.
ArgumentParser
(
description
=
description
,
epilog
=
epilog
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
parser
.
add_argument
(
action
=
"store"
,
dest
=
"files"
,
metavar
=
'FILE'
,
type
=
str
,
default
=
None
,
nargs
=
'*'
,
help
=
'a file name'
)
parser
.
add_argument
(
"-o"
,
action
=
"store"
,
type
=
str
,
dest
=
"outputfilename"
,
default
=
None
,
help
=
"Name of the output file"
)
parser
.
add_argument
(
"--ref"
,
action
=
"store"
,
type
=
str
,
dest
=
"ref"
,
default
=
None
,
help
=
"Name of the reference file"
)
parser
.
add_argument
(
"--minAge"
,
action
=
"store"
,
dest
=
"minAge"
,
metavar
=
'FLOAT'
,
type
=
float
,
default
=
None
,
help
=
'minAge'
)
parser
.
add_argument
(
"--maxAge"
,
action
=
"store"
,
dest
=
"maxAge"
,
metavar
=
'FLOAT'
,
type
=
float
,
default
=
None
,
help
=
'maxAge'
)
parser
.
add_argument
(
"--nngb"
,
action
=
"store"
,
type
=
int
,
dest
=
"nngb"
,
default
=
5
,
help
=
"Number of neighbouring particles to consider to compute RSP(==HSML)"
)
parser
.
add_argument
(
"--do_not_compute_ages"
,
action
=
"store_true"
,
default
=
False
,
help
=
"do not compute ages"
)
parser
.
add_argument
(
"--do_not_compute_rsp"
,
action
=
"store_true"
,
default
=
False
,
help
=
"do not compute rsp"
)
parser
.
add_argument
(
"--ftype"
,
action
=
"store"
,
type
=
str
,
dest
=
"ftype"
,
default
=
"arepo"
,
help
=
"type of file"
)
####################################################################
# main
####################################################################
if
__name__
==
'__main__'
:
opt
=
parser
.
parse_args
()
if
opt
.
ref
is
not
None
:
nbref
=
Nbody
(
opt
.
ref
)
if
opt
.
minAge
is
not
None
:
opt
.
minAge
=
opt
.
minAge
/
1
e3
# to Gyr
nbref
=
nbref
.
selectc
(
nbref
.
age
>
opt
.
minAge
)
if
opt
.
maxAge
is
not
None
:
opt
.
maxAge
=
opt
.
maxAge
/
1
e3
# to Gyr
nbref
=
nbref
.
selectc
(
nbref
.
age
<
opt
.
maxAge
)
for
f
in
opt
.
files
:
nb
=
Nbody
(
f
,
ftype
=
opt
.
ftype
)
if
opt
.
ref
is
not
None
:
# generate
idx
=
np
.
random
.
randint
(
low
=
0
,
high
=
nbref
.
nbody
-
1
,
size
=
nb
.
nbody
)
nb
.
age
=
nbref
.
age
[
idx
]
nb
.
mh
=
nbref
.
mh
[
idx
]
else
:
# generate ages (in Myr)
opt
.
minAge
=
5500
opt
.
maxAge
=
13500
nb
.
age
=
np
.
random
.
uniform
(
opt
.
minAge
,
opt
.
maxAge
,
nb
.
nbody
)
/
1
e3
# in Myr
# generate metallicities
opt
.
minFe
=
-
3
opt
.
maxFe
=
-
2
nb
.
mh
=
np
.
random
.
uniform
(
opt
.
minFe
,
opt
.
maxFe
,
nb
.
nbody
)
###################################
# compute Hsml
###################################
if
opt
.
do_not_compute_rsp
is
False
:
print
(
"Compute Rsp..."
)
#nb.set_tpe(0)
#nb.InitSphParameters(DesNumNgb=32, MaxNumNgbDeviation=2)
#nb.getTree()
#nb.rsp = nb.get_rsp_approximation()
#nb.set_tpe(4)
nb
.
ComputeRsp
(
opt
.
nngb
)
print
(
"done."
)
if
opt
.
outputfilename
:
nb
.
rename
(
opt
.
outputfilename
)
nb
.
write
()
Event Timeline
Log In to Comment