import pandas as pd
import matplotlib.pyplot as plt


ivef = pd.read_csv("../results-de/IVEF.csv")

ivef["delta"] = (ivef["end"] - ivef["start"]) / 1000
ivef["velocity"] = ivef["distance"] / ivef["delta"]

sailing = ivef[ivef["location"].isnull()]
mooring = ivef[~ivef["location"].isnull()]

buckets1 = {}
for vel in mooring["velocity"].to_numpy():
	if vel > 0:
		buckets1.setdefault(vel, 0)
		buckets1[vel] += 1

buckets2 = {}
for vel in sailing["velocity"].to_numpy():
	if vel > 0:
		buckets2.setdefault(vel, 0)
		buckets2[vel] += 1

plt.xlabel("velocity (m/s)")
plt.ylabel("number of vessels")
plt.bar(buckets1.keys(), buckets1.values(), 0.01, label="in quay (mooring)")
plt.bar(buckets2.keys(), buckets2.values(), 0.01, label="on canal/river (sailing)")
plt.legend()
plt.show()

# velocity is most likely always 0 and 5 m/s = 18 km/h = 9.71 knots