Skip to content

Commit

Permalink
fix NT plots
Browse files Browse the repository at this point in the history
  • Loading branch information
chraibi committed Feb 27, 2024
1 parent 49611be commit 04dca8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 16 additions & 4 deletions analysis_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,26 +323,31 @@ def calculate_nt(
selected_measurement_lines = st.multiselect("Measurement line", options=names, default=names)
fig = Figure()
figname = "NT=" + selected_file.split("/")[-1].split(".txt")[0]
fig1, ax1 = plt.subplots()
for i, (name, color) in enumerate(zip(selected_measurement_lines, colors)):
measurement_line = measurement_lines[i]
nt, _ = pedpy.compute_n_t(
traj_data=trajectory_data,
measurement_line=measurement_line,
)

trace, _ = plots.plot_x_y(
nt["cumulative_pedestrians"],
nt["time"],
nt["cumulative_pedestrians"],
xlabel="time",
ylabel="#pedestrians",
color=color,
title=f"{name}",
)
fig.add_trace(trace)
figname += f"_{name}"
pedpy.plot_nt(nt=nt, title="N-t at bottleneck", axes=ax1, color=color, label=f"{name}")

ax1.legend(loc="best")
c1, c2 = st.columns(2)
c1.pyplot(fig1)
figname += ".pdf"
plots.show_fig(fig, figname=figname)
fig1.savefig(figname)
plots.show_fig(fig, figname=figname, write=False)
plots.download_file(figname)


Expand Down Expand Up @@ -395,12 +400,19 @@ def calculate_profiles(
profiles=gaussian_density_profile,
axes=ax0,
label="$\\rho$ / 1/$m^2$",
title="Density",
)
figname = "density_profile_" + selected_file.split("/")[-1].split(".txt")[0] + str(chose_method) + ".pdf"
st.pyplot(fig)
fig.savefig(figname)
plots.download_file(figname)
# speed
# arithmetic_speed_profile = pedpy.compute_speed_profile(
# data=resorted_profile_data,
# walkable_area=walkable_area,
# grid_intersections_area=grid_cell_intersection_area,
# grid_size=grid_size,
# speed_method=SpeedMethod.ARITHMETIC,
# )


def ui_tab3_analysis() -> Tuple[Optional[str], int, st_column]:
Expand Down
1 change: 0 additions & 1 deletion plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def plot_fundamental_diagram_all(density_dict: Dict[str, pd.DataFrame], speed_di

def plot_x_y(x: pd.Series, y: pd.Series, title: str, xlabel: str, ylabel: str, color: str) -> Tuple[Scatter, Figure]:
"""Plot two arrays and return trace and fig."""
x = np.unique(x)
fig = make_subplots(
rows=1,
cols=1,
Expand Down

0 comments on commit 04dca8f

Please sign in to comment.