From 1eeb8600aa81a7ac40f113206cc0eb2d0ea554c1 Mon Sep 17 00:00:00 2001 From: Jorge Leitao Date: Sun, 4 Feb 2024 14:46:42 +0100 Subject: [PATCH] More --- analysis.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/analysis.py b/analysis.py index 5ea4c6e..4982cd0 100644 --- a/analysis.py +++ b/analysis.py @@ -312,4 +312,32 @@ def base_analysis(): hours_per_model() per_month() -base_analysis() + +def distribution(): + x = duckdb.sql( + f""" +INSTALL spatial; +LOAD spatial; +SELECT + epoch("end" - "start") / 60 / 60 AS "flying_time_k_hours" + , ST_Distance(ST_Point(from_lat,from_lon),ST_Point(to_lat,to_lon)) +FROM '{PATH}' +USING SAMPLE 10% + """ + ).fetchall() + + y = [x[1] for x in x] + x = [x[0] for x in x] + + plt.figure(figsize=FIG_SIZE) + plt.plot(x, y, '.') + plt.xlabel("Flying time (hours)") + plt.ylabel("Distance (feet)") + plt.grid(linestyle="dotted") + plt.tight_layout() + plt.savefig("results/dist.png", dpi=300) + + +distribution() + +# base_analysis()