Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91181178
gsoftening
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
Fri, Nov 8, 17:33
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Nov 10, 17:33 (2 d)
Engine
blob
Format
Raw Data
Handle
22213950
Attached To
rGTOOLS Gtools
gsoftening
View Options
#!/usr/bin/env python
from
Nbody
import
*
import
sys
import
copy
try
:
from
optparse
import
OptionParser
except
ImportError
:
from
optik
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"-t"
,
action
=
"store"
,
dest
=
"ftype"
,
type
=
"string"
,
default
=
None
,
help
=
"type of the file"
,
metavar
=
" TYPE"
)
parser
.
add_option
(
"--center"
,
action
=
"store_true"
,
dest
=
"center"
,
default
=
0
,
help
=
"center model"
)
parser
.
add_option
(
"-r"
,
action
=
"store"
,
dest
=
"r"
,
type
=
"float"
,
default
=
1
,
help
=
"radius"
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
==
0
:
print
"you must specify a filename"
sys
.
exit
(
0
)
files
=
args
return
files
,
options
######################################################################
# M A I N
######################################################################
# get options
files
,
options
=
parse_options
()
ftype
=
options
.
ftype
center
=
options
.
center
r
=
options
.
r
file
=
files
[
0
]
nb
=
Nbody
(
file
,
ftype
=
ftype
)
if
center
:
nb
.
histocenter
(
rbox
=
2
*
r
)
rs
=
nb
.
rxyz
()
c
=
(
rs
<
r
)
n
=
sum
(
c
.
astype
(
Int
))
print
"
%i
particles in the sphere of radius
%8.3f
"
%
(
n
,
r
)
Event Timeline
Log In to Comment