Commit 0c52506b authored by Hippalectryon's avatar Hippalectryon

angle pdf

parent 3db719e7
......@@ -48,7 +48,7 @@ def get_layout(option: str = "default") -> Tuple[Any, Dict[str, Any], Dict[str,
subplots["speed"] = fig.add_subplot(gs[0, 3])
subplots["angle"] = subplots["speed"].twinx()
subplots["polar"] = fig.add_subplot(gs[0, 4], projection='polar')
subplots["angle_pdf"] = fig.add_subplot(gs[0, 5])
subplots["angle_pdf"] = fig.add_subplot(gs[0, 5], projection='polar')
subplots["correlations"] = fig.add_subplot(gs[1, 3])
subplots["correlation_length"] = subplots["correlations"].twinx()
subplots["evolution_group_size"] = fig.add_subplot(gs[1, 4])
......@@ -297,6 +297,7 @@ class Visualiser:
if self.to_draw["angle_pdf"]:
ax_angle_pdf = self.subplots["angle_pdf"]
ax_angle_pdf.set_ylim(0, 1)
ax_angle_pdf.set_title("Angle PDF")
self.layout_artists["angle_pdf"], = ax_angle_pdf.plot([], [], lw=2)
......@@ -313,7 +314,7 @@ class Visualiser:
ax_group_dimension = self.subplots["group_dimension"]
max_group_size = self.options["max_group_size"]
ax_group_dimension.set_xlim(1, max_group_size)
ax_group_dimension.set_ylim(0, L / 5)
ax_group_dimension.set_ylim(0, L**2/100)
self.layout_artists["group_dimension_text"] = ax_group_dimension.text(
0.02, 1.05, '', transform=ax_group_dimension.transAxes)
if self.to_draw["group_dimension"]:
......@@ -388,10 +389,13 @@ class Visualiser:
Plot angle PDF
"""
frame = self.processed_data["_simulation"]["frames"][frame_num]
angles = np.array([np.array(bird[1]) for bird in frame])
kde = gaussian_kde(angles)
dist_space = np.linspace(min(angles), max(angles), 100)
self.layout_artists["angle_pdf"].set_data(dist_space, kde(dist_space))
angles = np.array([bird[1] for bird in frame])
angles_extended = np.concatenate((angles, angles+2*np.pi, angles-2*np.pi))
kde = gaussian_kde(angles_extended)
n_points = 100
dist_space = np.linspace(0, 2*np.pi, n_points)
rescaling = np.sqrt(np.sum(kde(dist_space)**2)*np.pi/n_points)
self.layout_artists["angle_pdf"].set_data(dist_space, kde(dist_space)/rescaling)
def plot_correlations(self, frame_num: int) -> None:
"""
......@@ -511,7 +515,7 @@ class Visualiser:
a, b, r_squared = data
x_data = np.array(range(len(self.processed_data["group_hulls_dimensions_avg"][frame_num]) + 1))
self.layout_artists["group_dimension_avg_fit"].set_data(x_data, fit(x_data, a, b))
self.layout_artists["group_dimension_text"].set_text("$R^2$ = %.5f\n $bx^a$: a=%.2f" % (r_squared, a))
self.layout_artists["group_dimension_text"].set_text("$R^2$ = %.5f\n $bx^a$: a=%.2f, b=%.2f" % (r_squared, a, b))
def plot_evolution_group_size(self, frame_num: int) -> None:
"""
......@@ -528,7 +532,7 @@ class Visualiser:
"""
frame = self.processed_data["_simulation"]["frames"][frame_num]
positions = np.array([np.array(bird[0]) for bird in frame])
angles = np.array([np.array(bird[1]) for bird in frame])
angles = np.array([bird[1] for bird in frame])
if self.options["quiver_color_by_group"]:
groups = self.processed_data["groups"][frame_num]
quiver_colors = []
......
......@@ -38,23 +38,24 @@ def launch_two_groups(output_file: str, L: float, n_birds_1: int, n_birds_2: int
Life.simulate(physics, dt, total_time, verbose_prop=.1, output_file=output_file)
launch_simulation_random("simulation_data/test.json", L=70, n_birds=1000, eta=.3, total_time=5) # , evolve=evolve)
launch_simulation_random("simulation_data/test.json", L=7, n_birds=400, eta=0, total_time=50) # , evolve=evolve)
#
# # launch_two_groups("simulation_data/test.json", L=100, n_birds_1=100, n_birds_2=0, radius_1=5, radius_2=5,
# # total_time=60, center_1=[50, 50], center_2=[80, 50], angle_1=0, angle_2=np.pi, eta=.4)
to_process = ["avg_speed", "avg_angle", "group_size", "group_size_avg", "group_size_avg_fit", "groups", "correlations",
"correlations_fit", "group_to_size", "group_hulls"]
to_process = ["avg_speed", "avg_angle"]
Processor().process("simulation_data/test.json", "processing_data/test", verbose_prop=.1, to_process=to_process,
options={"correlations_stochastic_points": 5000})
to_draw = ["avg_speed", "avg_angle", "avg_polar", "angle_pdf", "correlations", "correlations_fit", "correlation_length",
"group_size", "group_size_avg", "group_size_avg_fit", "group_dimension", "group_dimension_avg", "quiver", "evolution_group_size"]
to_draw = ["avg_speed", "avg_angle", "avg_polar", "angle_pdf", "quiver"]
Visualiser("processing_data/test", "visualisations/test.mp4", simulation_data_file="simulation_data/test.json",
verbose_prop=.1,
to_draw=to_draw,
options={"quiver_color_by_group": True, "quiver_draw_by_group": True, "quiver_color_single": True, "max_group_size": 50,
options={"quiver_color_by_group": False, "quiver_draw_by_group": False, "quiver_color_single": False, "max_group_size": 50,
"max_num_groups": 500}).vizualize()
# N = [10000]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment