Esempio n. 1
0
    def test_plot_seasonal(self):
        daily_avg_df = hd.daily_average(df=self.merged_df)
        daily_std_error = hd.daily_std_error(merged_data=self.merged_df)

        # Creating test image array
        hv.plot(merged_data_df=daily_avg_df,
                title='Daily Average Streamflow (Standard Error)',
                legend=('SFPT', 'GLOFAS'),
                x_season=True,
                labels=['Datetime', 'Streamflow (csm)'],
                linestyles=['r-', 'k-'],
                fig_size=(14, 8),
                ebars=daily_std_error,
                ecolor=('r', 'k'),
                tight_xlim=True)
        buf = BytesIO()
        plt.savefig(buf, format='png')
        buf.seek(0)
        img_test = mpimg.imread(buf)
        buf.close()

        # Reading Original Image
        img_original = mpimg.imread(
            r'baseline_images/plot_tests/plot_seasonal.png')

        # Comparing
        self.assertTrue(np.all(np.isclose(img_test, img_original)))
Esempio n. 2
0
    def test_daily_std_error(self):
        original_df = pd.read_csv(r'Comparison_Files/daily_std_error.csv', index_col=0)
        original_df.index = original_df.index.astype(np.object)

        test_df = hd.daily_std_error(self.merged_df)

        self.assertIsNone(pd.testing.assert_frame_equal(original_df, test_df))
Esempio n. 3
0
                ' - ' + name + '. COMID - ' + str(comid) + '.png')

    hv.plot(merged_df,
            legend=('Simulated', 'Observed'),
            grid=True,
            title='Hydrograph for ' + str(id) + ' - ' + name + '\n River: ' +
            rio + '. COMID: ' + str(comid),
            labels=['Datetime', 'Streamflow (m$^3$/s)'],
            linestyles=['b-', 'r-'],
            fig_size=(15, 9))
    plt.savefig(
        path.join(plot_out_dir,
                  '{0}_{1}_hydrographs.png'.format(str(id), name)))

    daily_avg = hd.daily_average(merged_df)
    daily_std_error = hd.daily_std_error(merged_data=merged_df)
    hv.plot(merged_data_df=daily_avg,
            legend=('Simulated', 'Observed'),
            grid=True,
            x_season=True,
            title='Daily Average Streamflow (Standard Error) for ' + str(id) +
            ' - ' + name + '\n River: ' + rio + '. COMID: ' + str(comid),
            labels=['Datetime', 'Streamflow (m$^3$/s)'],
            linestyles=['b-', 'r-'],
            fig_size=(15, 9),
            ebars=daily_std_error,
            ecolor=('b', 'r'),
            tight_xlim=False)
    plt.savefig(
        path.join(daily_average_out_dir,
                  '{0}_{1}_daily_average.png'.format(str(id), name)))