Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
498ebb00
Commit
498ebb00
authored
Mar 20, 2019
by
Benedikt Zoennchen
Browse files
add further zhang-2011 scenarios.
parent
f86292a8
Changes
33
Hide whitespace changes
Inline
Side-by-side
Tools/VadereAnalysisTools/Plots/fundamentalDiagrams/.ipynb_checkpoints/OSM_zhang-2011-checkpoint.ipynb
View file @
498ebb00
...
...
@@ -19,7 +19,8 @@
"def plotEvolution(vproject, ending, yval, ylabel):\n",
" plots = []\n",
" i = 1\n",
" plt.figure(1, figsize=(30, 10))\n",
" rows = len(vproject.output_dirs);\n",
" plt.figure(1, figsize=(30, 10*rows))\n",
" for outStr in project.output_dirs :\n",
" out = project.output_dirs[outStr]\n",
" dataFrames = []\n",
...
...
@@ -34,7 +35,7 @@
" ndf['scenario'] = [out.scenario['name']] * len(df.density)\n",
" dataFrames.append(ndf)\n",
" #concatFrames = pd.concat(dataFrames)\n",
" plt.subplot(
2
, 1, i)\n",
" plt.subplot(
rows
, 1, i)\n",
" plt.title(out.scenario['name'])\n",
" plt.xlabel('timeStep')\n",
" plt.ylabel(ylabel)\n",
...
...
@@ -51,13 +52,18 @@
" df = out.files[fileStr]()\n",
" ndf['density'] = df.density.astype(float)\n",
" ndf['velocity'] = df.velocity.astype(float)\n",
" ndf['scenario'] = [outStr] * len(df.velocity)\n",
" ndf['timeStep'] = df.timeStep.astype(int)\n",
" ndf['scenario'] = [fileStr] * len(df.velocity)\n",
" #ndf = ndf[ndf.timeStep > 100]\n",
" #ndf = ndf[ndf.timeStep < 500]\n",
" ndf = ndf[ndf.density < 4]\n",
" ndf = ndf[ndf.velocity > 0]\n",
" dataFrames.append(ndf)\n",
" concatFrames = pd.concat(dataFrames)\n",
" g = sns.relplot(x=\"density\", y=\"velocity\", hue=\"scenario\", data=concatFrames,\n",
" height=10, aspect=1)\n",
" g.set(xticks=[0,0.5,1,1.5,2,2.5,3,3.5,4], yticks=[0,0.5,1,1.5,2,2.5]);\n",
" g.savefig(\"./\"+vproject.project_name+\"_\"+ending+\"_fd\"+\".pdf\", bbox_inches='tight')\n",
" #axis = g.axes\n",
" #axes.set_xticks([0,1,2,3,4,5,6])\n",
" #axes.set_yticks([0,0.5,1,1.5,2,2.5])\n",
...
...
@@ -85,8 +91,11 @@
" df = out.files[fileStr]()\n",
" ndf['density'] = df.density.astype(float)\n",
" ndf['velocity'] = df.velocity.astype(float)\n",
" ndf['timeStep'] = df.timeStep.astype(int)\n",
" ndf['scenario'] = [out.scenario['name']] * len(df.velocity)\n",
" #ndf = ndf[ndf.density < 7]\n",
" ndf = ndf[ndf.density < 4]\n",
" #ndf = ndf[ndf.timeStep > 100]\n",
" #ndf = ndf[ndf.timeStep < 300]\n",
" #plt.scatter()\n",
" #axes.set_title(out.scenario['name'])\n",
" axes.set_xlabel('density')\n",
...
...
@@ -105,10 +114,10 @@
" axes.legend(['Weidmann', 'regression', 'Simulated data'])\n",
" index = index + 1;\n",
" if sep :\n",
" fig.savefig(\"./\"+out.scenario['name']+\"_
fundamental_diagram
\"+\".p
ng
\", bbox_inches='tight')\n",
" fig.savefig(\"./\"+out.scenario['name']+\"_
\"+ending+\"_fd
\"+\".p
df
\", bbox_inches='tight')\n",
" plt.show()\n",
" if not sep :\n",
" fig.savefig(\"./\"+vproject.project_name+\"_
fundamental_diagrams
\"+\".p
ng
\", bbox_inches='tight')\n",
" fig.savefig(\"./\"+vproject.project_name+\"_
\"+ending+\"_fd
\"+\".p
df
\", bbox_inches='tight')\n",
" "
]
},
...
...
@@ -151,7 +160,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Method B Plots"
"##
##
Method B Plots"
]
},
{
...
...
@@ -214,10 +223,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"
np.linspace(0, 200, num=201).tolist(
)"
"
plotEvolution(project, \"aTimeStep.fundamentalDiagram\", 'density', 'density'
)"
]
},
{
...
...
@@ -287,7 +298,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
5
"
"version": "3.6.
8
"
}
},
"nbformat": 4,
...
...
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
pandas
as
pd
import
seaborn
as
sns
from
vadereanalysistool
import
ScenarioOutput
,
VadereProject
from
scipy.optimize
import
curve_fit
sns
.
set
(
style
=
"whitegrid"
)
sns
.
set_context
(
"notebook"
,
font_scale
=
1.5
,
rc
=
{
"lines.linewidth"
:
2.0
})
def
plotEvolution
(
vproject
,
ending
,
yval
,
ylabel
):
plots
=
[]
i
=
1
plt
.
figure
(
1
,
figsize
=
(
30
,
10
))
rows
=
len
(
vproject
.
output_dirs
);
plt
.
figure
(
1
,
figsize
=
(
30
,
10
*
rows
))
for
outStr
in
project
.
output_dirs
:
out
=
project
.
output_dirs
[
outStr
]
dataFrames
=
[]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
#df = df[df.velocity > 0]
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
out
.
scenario
[
'name'
]]
*
len
(
df
.
density
)
dataFrames
.
append
(
ndf
)
#concatFrames = pd.concat(dataFrames)
plt
.
subplot
(
2
,
1
,
i
)
plt
.
subplot
(
rows
,
1
,
i
)
plt
.
title
(
out
.
scenario
[
'name'
])
plt
.
xlabel
(
'timeStep'
)
plt
.
ylabel
(
ylabel
)
sns
.
lineplot
(
x
=
'timeStep'
,
y
=
yval
,
data
=
pd
.
concat
(
dataFrames
))
i
=
i
+
1
def
plotFundamentalDiagram
(
vproject
,
ending
):
dataFrames
=
[]
for
outStr
in
project
.
output_dirs
:
out
=
project
.
output_dirs
[
outStr
]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'scenario'
]
=
[
outStr
]
*
len
(
df
.
velocity
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
fileStr
]
*
len
(
df
.
velocity
)
#ndf = ndf[ndf.timeStep > 100]
#ndf = ndf[ndf.timeStep < 500]
ndf
=
ndf
[
ndf
.
density
<
4
]
ndf
=
ndf
[
ndf
.
velocity
>
0
]
dataFrames
.
append
(
ndf
)
concatFrames
=
pd
.
concat
(
dataFrames
)
g
=
sns
.
relplot
(
x
=
"density"
,
y
=
"velocity"
,
hue
=
"scenario"
,
data
=
concatFrames
,
height
=
10
,
aspect
=
1
)
g
.
set
(
xticks
=
[
0
,
0.5
,
1
,
1.5
,
2
,
2.5
,
3
,
3.5
,
4
],
yticks
=
[
0
,
0.5
,
1
,
1.5
,
2
,
2.5
]);
g
.
savefig
(
"./"
+
vproject
.
project_name
+
"_"
+
ending
+
"_fd"
+
".pdf"
,
bbox_inches
=
'tight'
)
#axis = g.axes
#axes.set_xticks([0,1,2,3,4,5,6])
#axes.set_yticks([0,0.5,1,1.5,2,2.5])
#axes.set_xlim(0,6)
#axes.set_ylim(0,2.5)
def
plotFundamentalDiagramScatter
(
vproject
,
ending
,
sep
=
False
,
width
=
10
,
height
=
5
):
dataFrames
=
[]
index
=
0
cols
=
3
rows
=
len
(
vproject
.
output_dirs
)
/
cols
+
1
if
not
sep
:
fig
,
axs
=
plt
.
subplots
(
int
(
rows
),
int
(
cols
),
figsize
=
(
height
*
rows
,
width
*
cols
),
sharex
=
False
,
sharey
=
True
)
for
outStr
in
vproject
.
output_dirs
:
out
=
vproject
.
output_dirs
[
outStr
]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
if
not
sep
:
axes
=
axs
[
int
(
index
/
cols
),
int
(
index
%
cols
)]
else
:
fig
=
plt
.
figure
(
1
,
figsize
=
(
width
,
height
))
axes
=
plt
.
axes
()
fig
.
add_axes
(
axes
)
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
out
.
scenario
[
'name'
]]
*
len
(
df
.
velocity
)
#ndf = ndf[ndf.density < 7]
ndf
=
ndf
[
ndf
.
density
<
4
]
#ndf = ndf[ndf.timeStep > 100]
#ndf = ndf[ndf.timeStep < 300]
#plt.scatter()
#axes.set_title(out.scenario['name'])
axes
.
set_xlabel
(
'density'
)
axes
.
set_ylabel
(
'velocity'
)
axes
.
set_xticks
([
0
,
1
,
2
,
3
,
4
,
5
,
6
])
axes
.
set_yticks
([
0
,
0.5
,
1
,
1.5
,
2
,
2.5
])
axes
.
set_xlim
(
0
,
6
)
axes
.
set_ylim
(
0
,
2.5
)
axes
.
scatter
(
ndf
[
'density'
],
ndf
[
'velocity'
],
s
=
0.7
,
marker
=
'*'
,
color
=
'#555555'
)
wm
=
plotWeidmann
(
axes
)
popt
,
pcov
=
curve_fit
(
kladek
,
ndf
[
'density'
],
ndf
[
'velocity'
],
p0
=
(
1.34
,
1.913
,
5.4
))
print
(
str
(
popt
[
0
])
+
","
+
str
(
popt
[
1
])
+
","
+
str
(
popt
[
2
]))
xx
=
np
.
linspace
(
0.1
,
6
,
1000
)
yy
=
kladek
(
xx
,
*
popt
)
axes
.
plot
(
xx
,
yy
,
'--'
,
c
=
sns
.
color_palette
().
as_hex
()[
1
])
axes
.
legend
([
'Weidmann'
,
'regression'
,
'Simulated data'
])
index
=
index
+
1
;
if
sep
:
fig
.
savefig
(
"./"
+
out
.
scenario
[
'name'
]
+
"_
fundamental_diagram
"
+
".p
ng
"
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
"./"
+
out
.
scenario
[
'name'
]
+
"_
"
+
ending
+
"_fd
"
+
".p
df
"
,
bbox_inches
=
'tight'
)
plt
.
show
()
if
not
sep
:
fig
.
savefig
(
"./"
+
vproject
.
project_name
+
"_
fundamental_diagrams
"
+
".p
ng
"
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
"./"
+
vproject
.
project_name
+
"_
"
+
ending
+
"_fd
"
+
".p
df
"
,
bbox_inches
=
'tight'
)
```
%% Cell type:markdown id: tags:
# Load the Vadere project
%% Cell type:code id: tags:
```
python
projectFolder
=
"./../../../../VadereModelCalibration/TestOSM_zhang-2011/"
project
=
VadereProject
(
projectFolder
)
#out = project.named_output.C_050_180_180_2018_11_26_16_30_29_355()
```
%% Cell type:markdown id: tags:
## Method A Plots
%% Cell type:code id: tags:
```
python
# transform data frame
plotFundamentalDiagram
(
project
,
"aTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method B Plots
##
## Method B Plots
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"bPedestrian.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method C Plots (classical density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"cTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method E Plots (voronoi density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"eTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method D Plots (voronoi density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"dTimeStep.fundamentalDiagram"
)
```
%% Cell type:code id: tags:
```
python
np
.
linspace
(
0
,
200
,
num
=
201
).
tolist
(
)
plotEvolution
(
project
,
"aTimeStep.fundamentalDiagram"
,
'density'
,
'density'
)
```
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
coord1
=
[[
23.926582253991363
,
11.311616564587455
],[
24.526824188631515
,
11.346725287186784
],[
24.52439283212948
,
11.89
],[
23.80719398422859
,
11.89
]]
coord1
.
append
(
coord1
[
0
])
coord2
=
[[
22.0
,
10.1
],
[
24.0
,
10.1
],
[
24.0
,
11.9
],
[
22.0
,
11.9
],
[
22.0
,
10.1
]]
coord2
.
append
(
coord2
[
0
])
cap
=
[[
23.926582253991363
,
11.311616564587455
],[
24.000000000000014
,
11.315910838495633
],[
24.000000000000025
,
11.889999999999956
],[
23.80719398422859
,
11.89
]]
cap
.
append
(
cap
[
0
])
xs1
,
ys1
=
zip
(
*
coord1
)
#create lists of x and y values
xs2
,
ys2
=
zip
(
*
coord2
)
xs3
,
ys3
=
zip
(
*
cap
)
plt
.
figure
(
figsize
=
(
10
,
10
))
plt
.
plot
(
xs1
,
ys1
)
plt
.
plot
(
xs2
,
ys2
)
plt
.
plot
(
xs3
,
ys3
)
plt
.
show
()
# if you need...
```
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
coord
=
[[
1
,
1
],
[
2
,
1
],
[
2
,
2
],
[
1
,
2
],
[
0.5
,
1.5
]]
coord
.
append
(
coord
[
0
])
#repeat the first point to create a 'closed loop'
xs
,
ys
=
zip
(
*
coord
)
#create lists of x and y values
plt
.
figure
()
plt
.
plot
(
xs
,
ys
)
plt
.
show
()
# if you need..
```
%% Cell type:code id: tags:
```
python
```
...
...
Tools/VadereAnalysisTools/Plots/fundamentalDiagrams/OSM_calibration.ipynb
View file @
498ebb00
...
...
@@ -307,7 +307,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
5
"
"version": "3.6.
8
"
}
},
"nbformat": 4,
...
...
Tools/VadereAnalysisTools/Plots/fundamentalDiagrams/OSM_zhang-2011.ipynb
View file @
498ebb00
...
...
@@ -19,7 +19,8 @@
"def plotEvolution(vproject, ending, yval, ylabel):\n",
" plots = []\n",
" i = 1\n",
" plt.figure(1, figsize=(30, 10))\n",
" rows = len(vproject.output_dirs);\n",
" plt.figure(1, figsize=(30, 10*rows))\n",
" for outStr in project.output_dirs :\n",
" out = project.output_dirs[outStr]\n",
" dataFrames = []\n",
...
...
@@ -34,7 +35,7 @@
" ndf['scenario'] = [out.scenario['name']] * len(df.density)\n",
" dataFrames.append(ndf)\n",
" #concatFrames = pd.concat(dataFrames)\n",
" plt.subplot(
2
, 1, i)\n",
" plt.subplot(
rows
, 1, i)\n",
" plt.title(out.scenario['name'])\n",
" plt.xlabel('timeStep')\n",
" plt.ylabel(ylabel)\n",
...
...
@@ -51,13 +52,18 @@
" df = out.files[fileStr]()\n",
" ndf['density'] = df.density.astype(float)\n",
" ndf['velocity'] = df.velocity.astype(float)\n",
" ndf['scenario'] = [outStr] * len(df.velocity)\n",
" ndf['timeStep'] = df.timeStep.astype(int)\n",
" ndf['scenario'] = [fileStr] * len(df.velocity)\n",
" #ndf = ndf[ndf.timeStep > 100]\n",
" #ndf = ndf[ndf.timeStep < 500]\n",
" ndf = ndf[ndf.density < 4]\n",
" ndf = ndf[ndf.velocity > 0]\n",
" dataFrames.append(ndf)\n",
" concatFrames = pd.concat(dataFrames)\n",
" g = sns.relplot(x=\"density\", y=\"velocity\", hue=\"scenario\", data=concatFrames,\n",
" height=10, aspect=1)\n",
" g.set(xticks=[0,0.5,1,1.5,2,2.5,3,3.5,4], yticks=[0,0.5,1,1.5,2,2.5]);\n",
" g.savefig(\"./\"+vproject.project_name+\"_\"+ending+\"_fd\"+\".pdf\", bbox_inches='tight')\n",
" #axis = g.axes\n",
" #axes.set_xticks([0,1,2,3,4,5,6])\n",
" #axes.set_yticks([0,0.5,1,1.5,2,2.5])\n",
...
...
@@ -85,8 +91,11 @@
" df = out.files[fileStr]()\n",
" ndf['density'] = df.density.astype(float)\n",
" ndf['velocity'] = df.velocity.astype(float)\n",
" ndf['timeStep'] = df.timeStep.astype(int)\n",
" ndf['scenario'] = [out.scenario['name']] * len(df.velocity)\n",
" #ndf = ndf[ndf.density < 7]\n",
" ndf = ndf[ndf.density < 4]\n",
" #ndf = ndf[ndf.timeStep > 100]\n",
" #ndf = ndf[ndf.timeStep < 300]\n",
" #plt.scatter()\n",
" #axes.set_title(out.scenario['name'])\n",
" axes.set_xlabel('density')\n",
...
...
@@ -105,10 +114,10 @@
" axes.legend(['Weidmann', 'regression', 'Simulated data'])\n",
" index = index + 1;\n",
" if sep :\n",
" fig.savefig(\"./\"+out.scenario['name']+\"_
fundamental_diagram
\"+\".p
ng
\", bbox_inches='tight')\n",
" fig.savefig(\"./\"+out.scenario['name']+\"_
\"+ending+\"_fd
\"+\".p
df
\", bbox_inches='tight')\n",
" plt.show()\n",
" if not sep :\n",
" fig.savefig(\"./\"+vproject.project_name+\"_
fundamental_diagrams
\"+\".p
ng
\", bbox_inches='tight')\n",
" fig.savefig(\"./\"+vproject.project_name+\"_
\"+ending+\"_fd
\"+\".p
df
\", bbox_inches='tight')\n",
" "
]
},
...
...
@@ -151,7 +160,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Method B Plots"
"##
##
Method B Plots"
]
},
{
...
...
@@ -214,10 +223,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"
np.linspace(0, 200, num=201).tolist(
)"
"
plotEvolution(project, \"aTimeStep.fundamentalDiagram\", 'density', 'density'
)"
]
},
{
...
...
@@ -287,7 +298,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
5
"
"version": "3.6.
8
"
}
},
"nbformat": 4,
...
...
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
pandas
as
pd
import
seaborn
as
sns
from
vadereanalysistool
import
ScenarioOutput
,
VadereProject
from
scipy.optimize
import
curve_fit
sns
.
set
(
style
=
"whitegrid"
)
sns
.
set_context
(
"notebook"
,
font_scale
=
1.5
,
rc
=
{
"lines.linewidth"
:
2.0
})
def
plotEvolution
(
vproject
,
ending
,
yval
,
ylabel
):
plots
=
[]
i
=
1
plt
.
figure
(
1
,
figsize
=
(
30
,
10
))
rows
=
len
(
vproject
.
output_dirs
);
plt
.
figure
(
1
,
figsize
=
(
30
,
10
*
rows
))
for
outStr
in
project
.
output_dirs
:
out
=
project
.
output_dirs
[
outStr
]
dataFrames
=
[]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
#df = df[df.velocity > 0]
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
out
.
scenario
[
'name'
]]
*
len
(
df
.
density
)
dataFrames
.
append
(
ndf
)
#concatFrames = pd.concat(dataFrames)
plt
.
subplot
(
2
,
1
,
i
)
plt
.
subplot
(
rows
,
1
,
i
)
plt
.
title
(
out
.
scenario
[
'name'
])
plt
.
xlabel
(
'timeStep'
)
plt
.
ylabel
(
ylabel
)
sns
.
lineplot
(
x
=
'timeStep'
,
y
=
yval
,
data
=
pd
.
concat
(
dataFrames
))
i
=
i
+
1
def
plotFundamentalDiagram
(
vproject
,
ending
):
dataFrames
=
[]
for
outStr
in
project
.
output_dirs
:
out
=
project
.
output_dirs
[
outStr
]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'scenario'
]
=
[
outStr
]
*
len
(
df
.
velocity
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
fileStr
]
*
len
(
df
.
velocity
)
#ndf = ndf[ndf.timeStep > 100]
#ndf = ndf[ndf.timeStep < 500]
ndf
=
ndf
[
ndf
.
density
<
4
]
ndf
=
ndf
[
ndf
.
velocity
>
0
]
dataFrames
.
append
(
ndf
)
concatFrames
=
pd
.
concat
(
dataFrames
)
g
=
sns
.
relplot
(
x
=
"density"
,
y
=
"velocity"
,
hue
=
"scenario"
,
data
=
concatFrames
,
height
=
10
,
aspect
=
1
)
g
.
set
(
xticks
=
[
0
,
0.5
,
1
,
1.5
,
2
,
2.5
,
3
,
3.5
,
4
],
yticks
=
[
0
,
0.5
,
1
,
1.5
,
2
,
2.5
]);
g
.
savefig
(
"./"
+
vproject
.
project_name
+
"_"
+
ending
+
"_fd"
+
".pdf"
,
bbox_inches
=
'tight'
)
#axis = g.axes
#axes.set_xticks([0,1,2,3,4,5,6])
#axes.set_yticks([0,0.5,1,1.5,2,2.5])
#axes.set_xlim(0,6)
#axes.set_ylim(0,2.5)
def
plotFundamentalDiagramScatter
(
vproject
,
ending
,
sep
=
False
,
width
=
10
,
height
=
5
):
dataFrames
=
[]
index
=
0
cols
=
3
rows
=
len
(
vproject
.
output_dirs
)
/
cols
+
1
if
not
sep
:
fig
,
axs
=
plt
.
subplots
(
int
(
rows
),
int
(
cols
),
figsize
=
(
height
*
rows
,
width
*
cols
),
sharex
=
False
,
sharey
=
True
)
for
outStr
in
vproject
.
output_dirs
:
out
=
vproject
.
output_dirs
[
outStr
]
for
fileStr
in
out
.
files
:
if
fileStr
.
endswith
(
ending
)
:
if
not
sep
:
axes
=
axs
[
int
(
index
/
cols
),
int
(
index
%
cols
)]
else
:
fig
=
plt
.
figure
(
1
,
figsize
=
(
width
,
height
))
axes
=
plt
.
axes
()
fig
.
add_axes
(
axes
)
ndf
=
pd
.
DataFrame
();
df
=
out
.
files
[
fileStr
]()
ndf
[
'density'
]
=
df
.
density
.
astype
(
float
)
ndf
[
'velocity'
]
=
df
.
velocity
.
astype
(
float
)
ndf
[
'timeStep'
]
=
df
.
timeStep
.
astype
(
int
)
ndf
[
'scenario'
]
=
[
out
.
scenario
[
'name'
]]
*
len
(
df
.
velocity
)
#ndf = ndf[ndf.density < 7]
ndf
=
ndf
[
ndf
.
density
<
4
]
#ndf = ndf[ndf.timeStep > 100]
#ndf = ndf[ndf.timeStep < 300]
#plt.scatter()
#axes.set_title(out.scenario['name'])
axes
.
set_xlabel
(
'density'
)
axes
.
set_ylabel
(
'velocity'
)
axes
.
set_xticks
([
0
,
1
,
2
,
3
,
4
,
5
,
6
])
axes
.
set_yticks
([
0
,
0.5
,
1
,
1.5
,
2
,
2.5
])
axes
.
set_xlim
(
0
,
6
)
axes
.
set_ylim
(
0
,
2.5
)
axes
.
scatter
(
ndf
[
'density'
],
ndf
[
'velocity'
],
s
=
0.7
,
marker
=
'*'
,
color
=
'#555555'
)
wm
=
plotWeidmann
(
axes
)
popt
,
pcov
=
curve_fit
(
kladek
,
ndf
[
'density'
],
ndf
[
'velocity'
],
p0
=
(
1.34
,
1.913
,
5.4
))
print
(
str
(
popt
[
0
])
+
","
+
str
(
popt
[
1
])
+
","
+
str
(
popt
[
2
]))
xx
=
np
.
linspace
(
0.1
,
6
,
1000
)
yy
=
kladek
(
xx
,
*
popt
)
axes
.
plot
(
xx
,
yy
,
'--'
,
c
=
sns
.
color_palette
().
as_hex
()[
1
])
axes
.
legend
([
'Weidmann'
,
'regression'
,
'Simulated data'
])
index
=
index
+
1
;
if
sep
:
fig
.
savefig
(
"./"
+
out
.
scenario
[
'name'
]
+
"_
fundamental_diagram
"
+
".p
ng
"
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
"./"
+
out
.
scenario
[
'name'
]
+
"_
"
+
ending
+
"_fd
"
+
".p
df
"
,
bbox_inches
=
'tight'
)
plt
.
show
()
if
not
sep
:
fig
.
savefig
(
"./"
+
vproject
.
project_name
+
"_
fundamental_diagrams
"
+
".p
ng
"
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
"./"
+
vproject
.
project_name
+
"_
"
+
ending
+
"_fd
"
+
".p
df
"
,
bbox_inches
=
'tight'
)
```
%% Cell type:markdown id: tags:
# Load the Vadere project
%% Cell type:code id: tags:
```
python
projectFolder
=
"./../../../../VadereModelCalibration/TestOSM_zhang-2011/"
project
=
VadereProject
(
projectFolder
)
#out = project.named_output.C_050_180_180_2018_11_26_16_30_29_355()
```
%% Cell type:markdown id: tags:
## Method A Plots
%% Cell type:code id: tags:
```
python
# transform data frame
plotFundamentalDiagram
(
project
,
"aTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method B Plots
##
## Method B Plots
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"bPedestrian.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method C Plots (classical density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"cTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method E Plots (voronoi density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"eTimeStep.fundamentalDiagram"
)
```
%% Cell type:markdown id: tags:
## Method D Plots (voronoi density)
%% Cell type:code id: tags:
```
python
plotFundamentalDiagram
(
project
,
"dTimeStep.fundamentalDiagram"
)
```
%% Cell type:code id: tags:
```
python
np
.
linspace
(
0
,
200
,
num
=
201
).
tolist
(
)
plotEvolution
(
project
,
"aTimeStep.fundamentalDiagram"
,
'density'
,
'density'
)
```
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
coord1
=
[[
23.926582253991363
,
11.311616564587455
],[
24.526824188631515
,
11.346725287186784
],[
24.52439283212948
,
11.89
],[
23.80719398422859
,
11.89
]]
coord1
.
append
(
coord1
[
0
])
coord2
=
[[
22.0
,
10.1
],
[
24.0
,
10.1
],
[
24.0
,
11.9
],
[
22.0
,
11.9
],
[
22.0
,
10.1
]]
coord2
.
append
(
coord2
[
0
])
cap
=
[[
23.926582253991363
,
11.311616564587455
],[
24.000000000000014
,
11.315910838495633
],[
24.000000000000025
,
11.889999999999956
],[
23.80719398422859
,
11.89
]]
cap
.
append
(
cap
[
0
])
xs1
,
ys1
=
zip
(
*
coord1
)
#create lists of x and y values
xs2
,
ys2
=
zip
(
*
coord2
)
xs3
,
ys3
=
zip
(
*
cap
)
plt
.
figure
(
figsize
=
(
10
,
10
))
plt
.
plot
(
xs1
,
ys1
)
plt
.
plot
(
xs2
,
ys2
)
plt
.
plot
(
xs3
,
ys3
)
plt
.
show
()
# if you need...
```
%% Cell type:code id: tags:
```
python
import
matplotlib.pyplot
as
plt
coord
=
[[
1
,
1
],
[
2
,
1
],
[
2
,
2
],
[
1
,
2
],
[
0.5
,
1.5
]]
coord
.
append
(
coord
[
0
])
#repeat the first point to create a 'closed loop'
xs
,
ys
=
zip
(
*
coord
)
#create lists of x and y values
plt
.
figure
()
plt
.
plot
(
xs
,
ys
)
plt
.
show
()
# if you need..
```
%% Cell type:code id: tags:
```
python
```
...
...
VadereGui/src/org/vadere/gui/components/utils/CLGaussianCalculator.java
View file @
498ebb00
...
...
@@ -49,22 +49,25 @@ public class CLGaussianCalculator {
int
width
=
Math
.
max
(
filterObstacles
.
getMatrixWidth
(),
filterPedestrians
.
getMatrixWidth
());
int
height
=
Math
.
max
(
filterObstacles
.
getMatrixHeight
(),
filterPedestrians
.
getMatrixHeight
());
BufferedImage
image
=
createImage
(
width
,
height
);
int
maxColorValue
=
2
55
*
255
*
255
;
int
maxColorValue
=
2
0
;
ColorHelper
colorHelper
=
new
ColorHelper
(
maxColorValue
);
// double bound = filter.getMaxFilteredValue();
double
max
=
1.00
;
double
factor
=
maxColorValue
/
max
;
//System.out.println(filterPedestrians.getMaxFilteredValue()); // 0.1259
double
maxValue
=
Double
.
MIN_VALUE
;
for
(
int
x
=
0
;
x
<
filterPedestrians
.
getMatrixWidth
();
x
++)
{
for
(
int
y
=
0
;
y
<
filterPedestrians
.
getMatrixHeight
();
y
++)
{
double
pedValue
=
filterPedestrians
.
getFilteredValue
(
x
,
y
);
double
obsValue
=
filterObstacles
.
getFilteredValue
(
x
,
y
);
double
value
=
pedValue
+
obsValue
;
// value = pedValue;
image
.
setRGB
(
x
,
y
,
colorHelper
.
numberToColor
(
value
*
factor
).
getRGB
());
/*
image
.
setRGB
(
x
,
y
,
colorHelper
.
numberToColor
(
value
).
getRGB
());
if
(
maxValue
<
value
)
{
maxValue
=
value
;
}
/*
* if(value <= 0.0) {
* image.setRGB(x, y, Color.WHITE.getRGB());
* } else {
...
...
@@ -73,6 +76,7 @@ public class CLGaussianCalculator {
*/
}
}
System
.
out
.
println
(
maxValue
);
return
image
;
}
...
...
VadereModelCalibration/TestOSM_zhang-2011/scenarios/C-050-180-180.scenario
View file @
498ebb00
...
...
@@ -192,32 +192,32 @@
"targetAttractionStrength" : 1.0,
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "
OBSTACLES
",
"obstacleDensityWeight" :
3.5
,
"type" : "
UNIT
",
"obstacleDensityWeight" :
0.0
,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" :
1.0
,
"queueWidthLoading" :
0.1
,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT"
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" :
4
,
"numberOfCircles" :
1
,
"optimizationType" : "
NELDER_MEAD
",
"stepCircleResolution" :
30
,
"numberOfCircles" :
6
,
"optimizationType" : "
DISCRETE
",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.0,
"movementThreshold" : 0.0,
"minStepLength" : 0.
3
,
"minStepLength" : 0.
1
,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" :
fals
e,
"seeSmallWalls" :
tru
e,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
...
...
@@ -226,12 +226,12 @@
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 5
0
.0,
"pedPotentialHeight" :
3
5.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" :
6
.0,
"intimateSpaceFactor" :
1.2
,
"obstPotentialHeight" :
4
.0,
"intimateSpaceFactor" :
2.0
,
"personalSpacePower" : 1,
"intimateSpacePower" :
1
"intimateSpacePower" :
2
}
},
"attributesSimulation" : {
...
...
@@ -340,12 +340,13 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
"x" : 0.8,
"y" : 6.4,
"width" : 1
5
.0,
"width" : 1
0
.0,
"height" : 8.0,
"type" : "RECTANGLE"
},
...
...
@@ -363,10 +364,10 @@
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.
195
,
"radius" : 0.
2
,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.55,
"speedDistributionStandardDeviation" : 0.
26
,
"speedDistributionStandardDeviation" : 0.
15
,
"minimumSpeed" : 1.37,
"maximumSpeed" : 1.73,
"acceleration" : 2.0
...
...
VadereModelCalibration/TestOSM_zhang-2011/scenarios/C-050-180-180_GNM.scenario
View file @
498ebb00
...
...
@@ -324,6 +324,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
...
...
VadereModelCalibration/TestOSM_zhang-2011/scenarios/C-050-180-180_
long
.scenario
→
VadereModelCalibration/TestOSM_zhang-2011/scenarios/C-050-180-180_
Q
.scenario
View file @
498ebb00
{
"name" : "C-050-180-180_
long
",
"name" : "C-050-180-180_
Q
",
"description" : "",
"release" : "0.7",
"processWriters" : {
...
...
@@ -61,7 +61,7 @@
"attributesType" : "org.vadere.state.attributes.processor.AttributesFundamentalDiagramAProcessor",
"attributes" : {
"pedestrianLineCrossProcessorId" : 8,
"pedestrianVelocityProcessorId" :
13
,
"pedestrianVelocityProcessorId" :
7
,
"deltaTime" : 10.0
}
}, {
...
...
@@ -70,7 +70,7 @@
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianVelocityProcessor",
"attributes" : {
"pedestrianPositionProcessorId" : 1,
"backSteps" :
1
"backSteps" :
3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianLineCrossProcessor",
...
...
@@ -155,7 +155,7 @@
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianVelocityByTrajectoryProcessor",
"attributes" : {