bib-paper/scripts/calculate_mean_bottle_size.py

46 lines
1.2 KiB
Python

import numpy as np
import pandas as pd
filename_participants = "res/full_participant_measurement.csv"
filename_left = "res/flowrate_left.csv"
filename_right = "res/flowrate_right.csv"
filename_both = "res/flowrate_both.csv"
def main():
# Get bottle fillup times
df_part = pd.read_csv(filename_participants)
times_left = np.array(df_part[df_part["button"] == "left"]["time"])
times_right = np.array(df_part[df_part["button"] == "right"]["time"])
times_both = np.array(df_part[df_part["button"] == "both"]["time"])
# Get mean flowrates
df_left = pd.read_csv(filename_left)
df_right = pd.read_csv(filename_right)
df_both = pd.read_csv(filename_both)
flowrate_left = np.mean(np.array(df_left["flowrate"]))
flowrate_right = np.mean(np.array(df_right["flowrate"]))
flowrate_both = np.mean(np.array(df_both["flowrate"]))
# Calculate mean bottle size
sizes_left = times_left * flowrate_left
sizes_right = times_right * flowrate_right
sizes_both = times_both * flowrate_both
sizes = np.concatenate([sizes_left, sizes_right, sizes_both])
mean_size = np.mean(sizes)
print(f"Mean bottle size: {mean_size}")
if __name__ == "__main__":
main()