def test_qq_plot(self): # Creating test image array hv.qqplot(merged_data_df=self.merged_df, title='Quantile-Quantile Plot of Data', xlabel='SFPT Data Quantiles', ylabel='GLOFAS Data Quantiles', legend=True, figsize=(8, 6)) buf = BytesIO() plt.savefig(buf, format='png') buf.seek(0) img_test = mpimg.imread(buf) buf.close() # Reading original image img_original = mpimg.imread(os.path.join(os.getcwd(), 'baseline_images', 'plot_tests', 'qqplot.png')) # Comparing the images self.assertTrue(np.all(np.isclose(img_test, img_original)))
hv.hist(merged_data_df=merged_df, num_bins=100, legend=('Simulated', 'Observed'), grid=True, title='Histogram of Volume for ' + name + '\n River: ' + rio + '. COMID: ' + str(comid), labels=('Bins', 'Frequency'), figsize=(15, 9)) plt.savefig( path.join(hist_out_dir, '{0}_{1}_histograms.png'.format(str(comid), name))) hv.qqplot(merged_data_df=merged_df, title='Quantile-Quantile Plot of Data for ' + name + '\n River: ' + rio + '. COMID: ' + str(comid), xlabel='Simulated', ylabel='Observed', legend=True, figsize=(15, 9)) plt.savefig( path.join(qqplot_out_dir, '{0}_{1}_qq-plot.png'.format(str(comid), name))) plt.close('all') #Writing the lag table to excel #Stations for the Country to an Excel Spreadsheet all_station_table.to_excel( path.join(table_out_dir, 'Table_of_all_stations.xlsx'))
#title='Histogram of Streamflows for ' + str(id) + ' - ' + name + '\n River: ' + rio + '. COMID: ' + str( # comid), title='Histogram of Streamflows for ' + name + '\n River: ' + rio + '. COMID: ' + str(comid), labels=('Bins', 'Frequency'), figsize=(15, 9)) #plt.savefig(path.join(hist_out_dir, '{0}_{1}_histograms.png'.format(str(id), name))) plt.savefig( path.join(hist_out_dir, '{0}_{1}_histograms.png'.format(str(comid), name))) hv.qqplot( merged_data_df=merged_df, #title='Quantile-Quantile Plot of Data for ' + str( # id) + ' - ' + name + '\n River: ' + rio + '. COMID: ' + str(comid), title='Quantile-Quantile Plot of Data for ' + name + '\n River: ' + rio + '. COMID: ' + str(comid), xlabel='ERA-Interim', ylabel='ERA-5', legend=True, figsize=(15, 9)) #plt.savefig(path.join(qqplot_out_dir, '{0}_{1}_qq-plot.png'.format(str(id), name))) plt.savefig( path.join(qqplot_out_dir, '{0}_{1}_qq-plot.png'.format(str(comid), name))) '''Time Lag Analysis''' time_lag_metrics = [ 'ME', 'MAE', 'MAPE', 'RMSE', 'NRMSE (Mean)', 'NSE', 'KGE (2009)', 'KGE (2012)', 'SA', 'R (Pearson)', 'R (Spearman)', 'r2' ] #station_out_dir = path.join(lag_out_dir, str(id))