Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93102267
disp_results.py
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
Tue, Nov 26, 05:45
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Nov 28, 05:45 (2 d)
Engine
blob
Format
Raw Data
Handle
22563921
Attached To
R8982 phpc_submit_nbody
disp_results.py
View Options
import
numpy
as
np
import
csv
import
os
,
glob
from
numpy.random
import
normal
as
normal
import
matplotlib.pyplot
as
plt
from
mpl_toolkits.mplot3d
import
Axes3D
import
matplotlib.animation
as
animation
import
matplotlib
def
update
(
ifrm
,
xa
,
ya
,
za
):
sct
.
set_data
(
xa
[
ifrm
],
ya
[
ifrm
])
sct
.
set_3d_properties
(
za
[
ifrm
])
def
read_file
(
pathfile
):
files
=
glob
.
glob
(
pathfile
+
"*.csv"
)
files
.
sort
(
key
=
os
.
path
.
getmtime
)
xs
=
[[]
for
i
in
range
(
len
(
files
))]
ys
=
[[]
for
i
in
range
(
len
(
files
))]
zs
=
[[]
for
i
in
range
(
len
(
files
))]
for
idx
,
f
in
enumerate
(
files
):
with
open
(
pathfile
+
f
,
newline
=
''
)
as
data
:
reader
=
csv
.
reader
(
data
)
for
row
in
reader
:
if
row
[
0
]
!=
'x'
:
xs
[
idx
]
.
append
(
float
(
row
[
0
]))
ys
[
idx
]
.
append
(
float
(
row
[
1
]))
zs
[
idx
]
.
append
(
float
(
row
[
2
]))
return
xs
,
ys
,
zs
if
__name__
==
"__main__"
:
pathfile
=
"../output/"
dirs
=
os
.
listdir
(
pathfile
)
nfr
=
len
(
dirs
)
# Number of frames
fps
=
90
# Frame per sec
side
=
3000
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
,
projection
=
'3d'
)
sct
,
=
ax
.
plot
([],
[],
[],
"o"
,
markersize
=
2
)
# Read file
xs
,
ys
,
zs
=
read_file
(
pathfile
)
ax
.
set_xlim
(
-
side
,
side
/
2
)
ax
.
set_ylim
(
-
side
,
side
/
2
)
ax
.
set_zlim
(
-
side
,
side
/
2
)
ani
=
animation
.
FuncAnimation
(
fig
,
update
,
nfr
,
fargs
=
(
xs
,
ys
,
zs
),
interval
=
1000
/
fps
)
plt
.
rcParams
[
'animation.html'
]
=
'html5'
plt
.
show
()
Event Timeline
Log In to Comment