MCPcopy Create free account
hub / github.com/ardamavi/PI-rCNN / plot_comparisons

Function plot_comparisons

code/Plotting/plotting_procedure.py:173–216  ·  view source on GitHub ↗
(ground_truths, model_outputs, path="Figures/Comparison", frequency=100)

Source from the content-addressed store, hash-verified

171
172# Plot comparisons of dataset and model outputs:
173def plot_comparisons(ground_truths, model_outputs, path="Figures/Comparison", frequency=100):
174
175 # Create folder if not exists:
176 if not os.path.exists(path):
177 os.makedirs(path)
178
179 # Get data shape:
180 data_shape = model_outputs.shape
181
182 # Get grid:
183 x = np.linspace(0, 1, data_shape[2])
184 y = np.linspace(0, 1, data_shape[1])
185 grid_x, grid_y = np.meshgrid(x,y)
186
187 # Plot data with <frequency> gap:
188 for index in range(0, data_shape[0]+1, frequency):
189 # Get couples:
190 index = abs(index-1) # Range: [1,+inf)
191 y_dataset = ground_truths[index]
192 y_model = model_outputs[index]
193
194 # Plotting:
195 title_list = [["Reference u", "Reference v",],
196 ["Model Output u", "Model Output v"]]
197 fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(6, 6))
198 fig.subplots_adjust(hspace=0.25, wspace=0.25)
199 for plt_y in range(0,2):
200 for plt_x in range(0,2):
201 data = y_dataset if plt_y == 0 else y_model # Specify data to plot
202 p = ax[plt_y, plt_x].scatter(grid_x, grid_y, s=1, c=data[:,:,plt_x], marker="s",
203 cmap="coolwarm", vmin=-0.7, vmax=0.7, alpha=1, edgecolors=None)
204 ax[plt_y, plt_x].axis("square")
205 ax[plt_y, plt_x].set_title(title_list[plt_y][plt_x])
206
207 # Draw ColorBar:
208 # Left, bottom, width, and height of the Color Bar:
209 color_bar_coord = fig.add_axes([0.915, 0.3, 0.01, 0.4])
210 fig.colorbar(p, cax=color_bar_coord, orientation="vertical")
211
212 # Save plot:
213 plt.savefig(path+"/Comparisons_t{0}.png".format(index+1))
214 plt.close("all")
215
216 return True
217
218
219

Callers 1

plotting_pipelineFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected