Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPSreport
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
JuPedSim
JPSreport
Commits
bc2a0392
Commit
bc2a0392
authored
Oct 27, 2017
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP 8 coding style
parent
f6a1802e
Pipeline
#5066
passed with stages
in 1 minute and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
50 deletions
+56
-50
scripts/_Plot_profiles.py
scripts/_Plot_profiles.py
+56
-50
No files found.
scripts/_Plot_profiles.py
View file @
bc2a0392
...
...
@@ -4,26 +4,34 @@ import matplotlib.cm as cm
import
matplotlib.pyplot
as
plt
from
mpl_toolkits.axes_grid1
import
make_axes_locatable
import
argparse
import
sys
,
glob
import
sys
import
glob
import
os
# example usage:
# python scripts/_Plot_profiles.py -p demos/corridor_JPScore/Output/Fundamental_Diagram/Classical_Voronoi/field -b 10 -n trajectory.xml -e 100 -x1 0 -x2 23 -y1 0 -y2 4
def
getParserArgs
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Plot Profiles of density, velocity and flow'
)
parser
.
add_argument
(
"-p"
,
"--pathfile"
,
default
=
"./"
,
help
=
'path to the field directory (some/path/field)'
)
parser
.
add_argument
(
"-n"
,
"--nametraj"
,
required
=
True
,
help
=
'name of the trajectory file'
)
parser
.
add_argument
(
"-b"
,
"--beginsteady"
,
type
=
int
,
required
=
True
,
help
=
'the frame for the beginning of steady state'
)
parser
.
add_argument
(
"-e"
,
"--endsteady"
,
type
=
int
,
required
=
True
,
help
=
'the frame for the ending of steady state'
)
parser
.
add_argument
(
"-x1"
,
"--geominx"
,
type
=
float
,
required
=
True
,
help
=
'the minmum x of the geometry'
)
parser
.
add_argument
(
"-x2"
,
"--geomaxx"
,
type
=
float
,
required
=
True
,
help
=
'the maxmum x of the geometry'
)
parser
.
add_argument
(
"-y1"
,
"--geominy"
,
type
=
float
,
required
=
True
,
help
=
'the minmum y of the geometry'
)
parser
.
add_argument
(
"-y2"
,
"--geomaxy"
,
type
=
float
,
required
=
True
,
help
=
'the maxmum y of the geometry'
)
args
=
parser
.
parse_args
()
return
args
# example usage: python scripts/_Plot_profiles.py -p
# demos/corridor_JPScore/Output/Fundamental_Diagram/Classical_Voronoi/field -b 10 -n trajectory.xml -e 100 -x1 0 -x2
# 23 -y1 0 -y2 4
def
get_parser_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Plot Profiles of density, velocity and flow'
)
parser
.
add_argument
(
"-p"
,
"--pathfile"
,
default
=
"./"
,
help
=
'path to the field directory (some/path/field)'
)
parser
.
add_argument
(
"-n"
,
"--nametraj"
,
required
=
True
,
help
=
'name of the trajectory file'
)
parser
.
add_argument
(
"-b"
,
"--beginsteady"
,
type
=
int
,
required
=
True
,
help
=
'the frame for the beginning of '
'steady state'
)
parser
.
add_argument
(
"-e"
,
"--endsteady"
,
type
=
int
,
required
=
True
,
help
=
'the frame for the ending of '
'steady state'
)
parser
.
add_argument
(
"-x1"
,
"--geominx"
,
type
=
float
,
required
=
True
,
help
=
'the minmum x of the geometry'
)
parser
.
add_argument
(
"-x2"
,
"--geomaxx"
,
type
=
float
,
required
=
True
,
help
=
'the maxmum x of the geometry'
)
parser
.
add_argument
(
"-y1"
,
"--geominy"
,
type
=
float
,
required
=
True
,
help
=
'the minmum y of the geometry'
)
parser
.
add_argument
(
"-y2"
,
"--geomaxy"
,
type
=
float
,
required
=
True
,
help
=
'the maxmum y of the geometry'
)
arguments
=
parser
.
parse_args
()
return
arguments
if
__name__
==
'__main__'
:
args
=
get
ParserA
rgs
()
args
=
get
_parser_a
rgs
()
pathfile
=
args
.
pathfile
sys
.
path
.
append
(
pathfile
)
nametraj
=
args
.
nametraj
...
...
@@ -35,14 +43,14 @@ if __name__ == '__main__':
geomaxY
=
args
.
geomaxy
print
(
"pathfile: %s"
%
pathfile
)
print
(
"namtraj: %s"
%
nametraj
)
print
(
"Steadystate: [%d, %d]"
%
(
beginsteady
,
endsteady
))
print
(
"namtraj: %s"
%
nametraj
)
print
(
"Steadystate: [%d, %d]"
%
(
beginsteady
,
endsteady
))
print
(
"geometry: X [%.1f, %.1f], Y=[%.1f, %.1f]"
%
(
geominX
,
geomaxX
,
geominY
,
geomaxY
))
density_files
=
os
.
path
.
join
(
pathfile
,
"density"
,
"*%s*%d.dat"
%
(
nametraj
,
beginsteady
))
(
nametraj
,
beginsteady
))
print
(
"looking for %s"
%
density_files
)
f_Voronoi
=
glob
.
glob
(
density_files
)
# get the shape of the matrices
...
...
@@ -52,87 +60,85 @@ if __name__ == '__main__':
shape
=
np
.
shape
(
np
.
loadtxt
(
f_Voronoi
[
0
]))
density
=
np
.
zeros
(
shape
)
velocity
=
np
.
zeros
(
shape
)
#-------------------------density profile----------------
#
-------------------------density profile----------------
fig
=
plt
.
figure
(
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
dpi
=
100
)
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
dpi
=
100
)
ax1
=
fig
.
add_subplot
(
111
,
aspect
=
'1'
)
plt
.
rc
(
"font"
,
size
=
40
)
for
j
in
range
(
beginsteady
,
endsteady
):
for
j
in
range
(
beginsteady
,
endsteady
):
density_file
=
os
.
path
.
join
(
pathfile
,
"density"
,
"Prf_d_%s_id_1_%.5d.dat"
%
(
nametraj
,
j
)
)
pathfile
,
"density"
,
"Prf_d_%s_id_1_%.5d.dat"
%
(
nametraj
,
j
))
print
(
"loading: %s"
%
density_file
)
density
+=
np
.
loadtxt
(
density_file
)
density
=
density
/
(
endsteady
-
beginsteady
)
density
=
density
/
(
endsteady
-
beginsteady
)
im
=
plt
.
imshow
(
density
,
cmap
=
cm
.
jet
,
interpolation
=
'nearest'
,
origin
=
'lower'
,
vmin
=
0
,
vmax
=
np
.
amax
(
density
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
interpolation
=
'nearest'
,
origin
=
'lower'
,
vmin
=
0
,
vmax
=
np
.
amax
(
density
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
ax1
.
set_xlabel
(
"x [m]"
)
ax1
.
set_ylabel
(
"y [m]"
)
divider
=
make_axes_locatable
(
ax1
)
cax
=
divider
.
append_axes
(
"right"
,
size
=
"2.5%"
,
pad
=
0.3
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
.
set_label
(
'Density [$m^{-2}$]'
)
density_figname
=
os
.
path
.
join
(
pathfile
,
"profile_rho_%s.png"
%
nametraj
)
density_figname
=
os
.
path
.
join
(
pathfile
,
"profile_rho_%s.png"
%
nametraj
)
plt
.
savefig
(
density_figname
)
plt
.
close
()
#-----------------velocity profile-----------------------------------
#
-----------------velocity profile-----------------------------------
fig
=
plt
.
figure
(
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
dpi
=
100
)
ax1
=
fig
.
add_subplot
(
111
,
aspect
=
'1'
)
plt
.
rc
(
"font"
,
size
=
40
)
for
j
in
range
(
beginsteady
,
endsteady
):
for
j
in
range
(
beginsteady
,
endsteady
):
velocity_file
=
os
.
path
.
join
(
pathfile
,
"velocity"
,
"Prf_v_%s_id_1_%.5d.dat"
%
(
nametraj
,
j
)
)
pathfile
,
"velocity"
,
"Prf_v_%s_id_1_%.5d.dat"
%
(
nametraj
,
j
))
print
(
"loading: %s"
%
velocity_file
)
velocity
+=
np
.
loadtxt
(
velocity_file
)
velocity
=
velocity
/
(
endsteady
-
beginsteady
)
velocity
=
velocity
/
(
endsteady
-
beginsteady
)
im
=
plt
.
imshow
(
velocity
,
cmap
=
cm
.
jet
,
interpolation
=
'nearest'
,
origin
=
'lower'
,
vmin
=
0
,
vmax
=
np
.
amax
(
velocity
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
vmin
=
0
,
vmax
=
np
.
amax
(
velocity
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
ax1
.
set_xlabel
(
"x [m]"
)
ax1
.
set_ylabel
(
"y [m]"
)
divider
=
make_axes_locatable
(
ax1
)
cax
=
divider
.
append_axes
(
"right"
,
size
=
"2.5%"
,
pad
=
0.3
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
.
set_label
(
'Velocity [$m/s$]'
)
velocity_figname
=
os
.
path
.
join
(
pathfile
,
"profile_v_%s.png"
%
nametraj
)
velocity_figname
=
os
.
path
.
join
(
pathfile
,
"profile_v_%s.png"
%
nametraj
)
plt
.
savefig
(
velocity_figname
)
plt
.
close
()
#
-------------------flow profile-------------------------
#
-------------------flow profile-------------------------
fig
=
plt
.
figure
(
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
dpi
=
100
)
figsize
=
(
16
*
(
geomaxX
-
geominX
)
/
(
geomaxY
-
geominY
)
+
2
,
16
),
dpi
=
100
)
ax1
=
fig
.
add_subplot
(
111
,
aspect
=
'1'
)
plt
.
rc
(
"font"
,
size
=
40
)
flow
=
density
*
velocity
flow
=
density
*
velocity
im
=
plt
.
imshow
(
flow
,
cmap
=
cm
.
jet
,
interpolation
=
'nearest'
,
origin
=
'lower'
,
vmin
=
0
,
vmax
=
np
.
amax
(
flow
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
cmap
=
cm
.
jet
,
interpolation
=
'nearest'
,
origin
=
'lower'
,
vmin
=
0
,
vmax
=
np
.
amax
(
flow
),
extent
=
[
geominX
,
geomaxX
,
geominY
,
geomaxY
])
ax1
.
set_xlabel
(
"x [m]"
)
ax1
.
set_ylabel
(
"y [m]"
)
divider
=
make_axes_locatable
(
ax1
)
cax
=
divider
.
append_axes
(
"right"
,
size
=
"2.5%"
,
pad
=
0.3
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
=
plt
.
colorbar
(
im
,
cax
=
cax
)
cb
.
set_label
(
'Specific flow [$1/m \cdot s$]'
)
figname
=
"%s/profile_flux_%s.png"
%
(
pathfile
,
nametraj
)
flux_figname
=
os
.
path
.
join
(
pathfile
,
"profile_flux_%s.png"
%
nametraj
)
figname
=
"%s/profile_flux_%s.png"
%
(
pathfile
,
nametraj
)
flux_figname
=
os
.
path
.
join
(
pathfile
,
"profile_flux_%s.png"
%
nametraj
)
plt
.
savefig
(
flux_figname
)
plt
.
close
()
# print some infos
print
(
"
\n\n
=============
\n
---> %s"
%
density_figname
)
print
(
"---> %s"
%
velocity_figname
)
print
(
"---> %s
\n
============= "
%
flux_figname
)
Write
Preview
Markdown
is supported
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