예제 #1
0
    def test_cut_xs_new(self):

        df = pd.read_excel(self.f, 'irregular_multiple_panels')
        level = 15  # at top
        for level in [0, 2, 8, 5, 10, 11, 12, 15, 20]:
            xs = df['offset'].values
            ys = df['Z'].values
            ns = df['roughness_N'].values
            ps = df['new_panel'].values
            lines = river_tools.cut_xs_new(xs, ys, ns, ps, level)
            fig, axes = plt.subplots(2,
                                     sharex=True,
                                     gridspec_kw={
                                         'height_ratios': [1, 3],
                                         'hspace': 0.001
                                     })
            river_tools.plot_xs(df, level, fig, axes)
            axes[1].plot([np.min(df['offset']),
                          np.max(df['offset'])], [level, level],
                         linestyle='--')
            for line in lines:
                axes[1].plot(line['offset'],
                             line['Z'],
                             linewidth=3,
                             linestyle='--',
                             label='a')
                # axes[1].plot([np.min(df['offset']), np.max(df['offset'])], [level, level], linestyle='--')
            plt.legend()

            plt.show()
예제 #2
0
    def test_panel_conveyance15(self):
        # TODO: need to get this one tested using the testing section for single one
        df = pd.read_excel(self.f, 'irregular_multiple_panels')
        rows = []
        for depth in [15]:
            v = river_tools.panel_conveyance(df, depth, 'single')
            # rows.append(v[:-1])
            df_wet = v[-1]
            df_wet.to_csv(
                r'C:\Users\Mel.Meng\Documents\GitHub\SewerAnalysis\source\test\river\wet.csv'
            )
            df_wet['new_panel'] = 0
            print('width:', v[3])

            fig, axes = plt.subplots(2,
                                     sharex=True,
                                     gridspec_kw={
                                         'height_ratios': [1, 3],
                                         'hspace': 0.001
                                     })
            river_tools.plot_xs(df_wet, 'line', fig, axes)

            axes[1].plot(df['offset'], df['Z'], linestyle='--')
            axes[1].plot([np.min(df['offset']),
                          np.max(df['offset'])], [depth, depth],
                         linestyle='--')
            plt.show()

        self.fail()
예제 #3
0
 def test_plot_xs(self):
     csv_path = './test/river/icm/xs.csv'
     output_folder = './test/river/icm/tmp'
     df = pd.read_csv(csv_path)
     xs_name = 'BalzerC_Reach1_4_000'
     fig = river_tools.plot_xs(df, xs_name)
     out_png = os.path.join(output_folder, '%s.png' % 'test')
     fig.savefig(out_png)
     self.fail()
예제 #4
0
    def test_batch_print(self):
        csv_path = './test/river/icm/xs_sample_csv_export/xs_sample_cross_section_survey_section_array.csv'
        output_folder = './test/river/icm/tmp'
        xs_list = river_tools.read_icm_cross_section_survey_section_array_csv(
            csv_path)
        xs_list = river_tools.icm_xs_add_offset(xs_list)

        for k in xs_list:
            out_csv = os.path.join(output_folder,
                                   '%s.csv' % str(k).replace('.', '_'))
            xs_list[k].to_csv(out_csv, index_label='no')
            fig = river_tools.plot_xs(xs_list[k], k)
            out_png = os.path.join(output_folder,
                                   '%s.png' % str(k).replace('.', '_'))
            fig.savefig(out_png)
        self.fail('check output folder for batch conversions')
예제 #5
0
    def test_cut_cross_section_line(self):
        csv_path = './test/river/icm/xs.csv'
        output_folder = './test/river/icm/tmp'
        df = pd.read_csv(csv_path)
        river_tools.plot_xs(df, 'line')
        plt.show()

        xs = df['offset'].values
        ys = df['Z'].values
        ns = df['roughness_N'].values
        ps = df['new_panel'].values
        all_checks = {
            311.8: [{
                'sta': 4.42043478377046,
                'width': 105.24753803024845
            }, {
                'sta': 142.78310982485263,
                'width': 10.481538460915516
            }, {
                'sta': 192.5851427915494,
                'width': 3.1768285709524093
            }],
            312: [{
                'sta': 20.44083333254138,
                'width': 105.24753803024845
            }, {
                'sta': 142.78310982485263,
                'width': 10.481538460915516
            }, {
                'sta': 192.5851427915494,
                'width': 3.1768285709524093
            }],
            311.6: [{
                'sta': 20.44083333254138,
                'width': 105.24753803024845
            }, {
                'sta': 142.78310982485263,
                'width': 10.481538460915516
            }, {
                'sta': 192.5851427915494,
                'width': 3.1768285709524093
            }]
        }
        for level in [
                #     311.8,   # higher than righ
                # 312,  # higher than both left and right
                311.6
        ]:  # below than both sides

            checks = all_checks[level]
            lines = river_tools.cut_cross_section(xs, ys, ns, ps, level)

            fig, axes = plt.subplots(2,
                                     sharex=True,
                                     gridspec_kw={
                                         'height_ratios': [1, 3],
                                         'hspace': 0.001
                                     })
            axes[1].plot(df['offset'], df['Z'])
            axes[1].plot([np.min(df['offset']),
                          np.max(df['offset'])], [level, level])
            for idx, line in enumerate(lines):
                df2 = pd.DataFrame(
                    line, columns=['offset', 'Z', 'roughness_N', 'new_panel'])
                river_tools.plot_xs(df2, 'line', fig, axes)
            plt.show()