import matplotlib.pyplot as plt GRAVITY_ACC = 9.81 WATER_DENSITY = 997.13 HELP_MESSAGE = """ 'h' - provide help message 'r' - read test data from a file 'p' - {start_relative_elevation, step, no_steps} - print a table showing daily profit and total energy for various values of relative elevation 'q' - terminate the program """ def load_data(directory: str, filename: str): """ Loads the data from a txt file Parameters: directory (str): the directory of the file filename (str): the name of the file Returns: (list): the data from the file """ with open(directory + '/' + filename, 'r') as f: data = [float(i) for i in f.readlines()[0].strip().split(',')] return data def plot_water_height(water_heights: tuple[float, ...], time_inc: float): """ Plots the water height over time Parameters: water_heights (tuple): the water heights time_inc (float): the time increment Returns: None """ time = [i*time_inc for i in range(len(water_heights))] plt.plot(time, water_heights, label='Dam Water Height') plt.plot(time[0], water_heights[0], 'ro', label='Start') plt.plot(time[-1], water_heights[-1], 'ro', label='End') plt.xlabel("Time (s)") plt.ylabel("Water Height (m)") plt.title("Water Height vs Time") plt.legend() plt.show()