| 219 | |
| 220 | # Plot the comparisons of changes on one point during time: |
| 221 | def plot_point_comparison(ground_truths, model_outputs, comparison_point=(32,32), |
| 222 | path="Figures/", file="point_comparison.png", time_interval=3): |
| 223 | |
| 224 | # Create folder if not exists: |
| 225 | if not os.path.exists(path): |
| 226 | os.makedirs(path) |
| 227 | |
| 228 | # Get x axis that represents time: |
| 229 | x_axis = np.linspace(0, time_interval, len(model_outputs)) |
| 230 | |
| 231 | # Get changes on one point: |
| 232 | dataset_change = ground_truths[:,comparison_point[0], comparison_point[1], :] |
| 233 | model_change = model_outputs[:,comparison_point[0], comparison_point[1], :] |
| 234 | |
| 235 | |
| 236 | # Plotting: |
| 237 | title_list = ["u change on point ({0},{1})".format(comparison_point[0], comparison_point[1]), |
| 238 | "v change on point ({0},{1})".format(comparison_point[0], comparison_point[1])] |
| 239 | fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(9, 6)) |
| 240 | fig.subplots_adjust(hspace=0.25, wspace=0.25) |
| 241 | for plt_x in range(0,2): |
| 242 | c = 0 if plt_x == 0 else 1 # Specify channel to plot |
| 243 | ax[plt_x].plot(x_axis, dataset_change[:,c], "tab:green", label="Reference") |
| 244 | ax[plt_x].plot(x_axis, model_change[:,c], "tab:orange", label="Model") |
| 245 | ax[plt_x].set_title(title_list[plt_x]) |
| 246 | ax[plt_x].set_xlabel('Time') |
| 247 | ax[plt_x].set_ylabel("u" if c == 0 else "v") |
| 248 | ax[plt_x].set_xlim([0, time_interval]) |
| 249 | ax[plt_x].legend() |
| 250 | |
| 251 | # Save plot: |
| 252 | plt.savefig(path+"/"+file) |
| 253 | plt.close("all") |
| 254 | |
| 255 | return True |
| 256 | |
| 257 | |
| 258 | |