Ejemplo n.º 1
0
 def test_bad_truth_size(self):
     self.truth.data = self.truth.data[:-1]
     with self.assertRaises(ValueError):
         dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
             truth=self.truth)
     # close uncompleted plot window
     plt.close(plt.gcf())
Ejemplo n.º 2
0
 def test_bad_truth_size(self):
     self.truth.data = self.truth.data[:-1]
     with self.assertRaises(ValueError):
         dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
             truth=self.truth)
     # close uncompleted plot window
     plt.close(plt.gcf())
Ejemplo n.º 3
0
 def test_array_data2(self):
     data = np.column_stack((self.data, self.data))
     self.fig = dcs.plot_time_history(self.time,
                                      data,
                                      self.label,
                                      self.type_,
                                      plot_as_diffs=True)
Ejemplo n.º 4
0
 def test_second_y_scale2(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, type_='percentage', \
         second_y_scale=self.second_y_scale)
Ejemplo n.º 5
0
 def test_group(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         opts=self.opts, plot_indiv=False)
Ejemplo n.º 6
0
 def test_diffs(self):
     self.fig = dcs.plot_time_history(self.time, self.data_matrix, self.label, self.type_, \
         plot_as_diffs=True)
Ejemplo n.º 7
0
 def test_truth1(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         truth=self.truth)
Ejemplo n.º 8
0
                      minstep=0.1))

    # Run code
    if rerun:
        (bpe_results, results) = dcs.run_bpe(opti_opts)
    else:
        bpe_results = dcs.BpeResults.load(
            os.path.join(opti_opts.output_folder, opti_opts.output_results))
        results = sim_model(
            sim_params)  # just re-run, nothing is actually saved by this model

    # Plot results
    if make_plots:
        # build opts
        opts = dcs.Opts()
        opts.case_name = 'Model Results'
        opts.save_path = dcs.get_output_dir()
        opts.save_plot = True

        # make model plots
        dcs.plot_time_history(time,
                              results,
                              description='Output vs. Time',
                              opts=opts,
                              truth=truth)

        # make BPE plots
        bpe_plots = {'innovs': True, 'convergence': False, 'correlation': True, 'info_svd': True, \
            'covariance': False}
        dcs.plot_bpe_results(bpe_results, opts, plots=bpe_plots)
Ejemplo n.º 9
0
 def test_diffs_and_opts(self):
     self.fig = dcs.plot_time_history(self.time, self.data_matrix, self.label, self.type_, \
         opts=self.opts, plot_as_diffs=True)
Ejemplo n.º 10
0
 def test_diffs(self):
     self.fig = dcs.plot_time_history(self.time, self.data_matrix, self.label, self.type_, \
         plot_as_diffs=True)
Ejemplo n.º 11
0
 def test_opts(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, opts=self.opts)
Ejemplo n.º 12
0
 def test_truth2(self):
     self.truth.data_lo = self.truth.data - 0.1
     self.truth.data_hi = self.truth.data + 0.1
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         truth=self.truth)
Ejemplo n.º 13
0
 def test_truth1(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         truth=self.truth)
Ejemplo n.º 14
0
 def test_normal(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_)
Ejemplo n.º 15
0
 def test_plot_empty(self):
     self.fig = dcs.plot_time_history([], [], '')
Ejemplo n.º 16
0
 def test_group(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         opts=self.opts, plot_indiv=False)
Ejemplo n.º 17
0
 def test_no_rms_in_legend1(self):
     self.fig = dcs.plot_time_history(self.time,
                                      self.data,
                                      self.label,
                                      self.type_,
                                      rms_in_legend=False)
Ejemplo n.º 18
0
 def test_colormap(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, colormap='Dark2')
Ejemplo n.º 19
0
 def test_normal(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label,
                                      self.type_)
Ejemplo n.º 20
0
 def test_array_data2(self):
     data = np.column_stack((self.data, self.data))
     self.fig = dcs.plot_time_history(self.time, data, self.label, self.type_, plot_as_diffs=True)
Ejemplo n.º 21
0
 def test_truth2(self):
     self.truth.data_lo = self.truth.data - 0.1
     self.truth.data_hi = self.truth.data + 0.1
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         truth=self.truth)
Ejemplo n.º 22
0
 def test_second_y_scale1(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         second_y_scale=self.second_y_scale)
Ejemplo n.º 23
0
 def test_opts(self):
     self.fig = dcs.plot_time_history(self.time,
                                      self.data,
                                      self.label,
                                      self.type_,
                                      opts=self.opts)
Ejemplo n.º 24
0
 def test_second_y_scale2(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, type_='percentage', \
         second_y_scale=self.second_y_scale)
Ejemplo n.º 25
0
 def test_diffs_and_opts(self):
     self.fig = dcs.plot_time_history(self.time, self.data_matrix, self.label, self.type_, \
         opts=self.opts, plot_as_diffs=True)
Ejemplo n.º 26
0
 def test_simple(self):
     self.fig = dcs.plot_time_history(0, 0, 'Text')
Ejemplo n.º 27
0
 def test_colormap(self):
     self.fig = dcs.plot_time_history(self.time,
                                      self.data,
                                      self.label,
                                      self.type_,
                                      colormap='Dark2')
Ejemplo n.º 28
0
 def test_plot_empty(self):
     self.fig = dcs.plot_time_history([], [], '')
Ejemplo n.º 29
0
 def test_second_y_scale1(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         second_y_scale=self.second_y_scale)
Ejemplo n.º 30
0
 def test_plot_all_nans(self):
     self.fig = dcs.plot_time_history(np.array([np.nan, np.nan]), np.array([np.nan, np.nan]), self.label)
Ejemplo n.º 31
0
 def test_simple(self):
     self.fig = dcs.plot_time_history(0, 0, 'Text')
Ejemplo n.º 32
0
 def test_no_rms_in_legend1(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, rms_in_legend=False)
Ejemplo n.º 33
0
 def test_plot_all_nans(self):
     self.fig = dcs.plot_time_history(np.array([np.nan, np.nan]),
                                      np.array([np.nan, np.nan]),
                                      self.label)
Ejemplo n.º 34
0
 def test_no_rms_in_legend2(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         rms_in_legend=False, plot_as_diffs=True)
Ejemplo n.º 35
0
 def test_no_rms_in_legend2(self):
     self.fig = dcs.plot_time_history(self.time, self.data, self.label, self.type_, \
         rms_in_legend=False, plot_as_diffs=True)
Ejemplo n.º 36
0
    opti_opts.shrink_radius   = 0.5
    opti_opts.trust_radius    = 1.0

    # Parameters to estimate
    opti_opts.params.append(dcs.OptiParam('magnitude', best=2.5, min_=-10, max_=10, typical=5, minstep=0.01))
    opti_opts.params.append(dcs.OptiParam('frequency', best=20, min_=1, max_=1000, typical=60, minstep=0.01))
    opti_opts.params.append(dcs.OptiParam('phase', best=180, min_=0, max_=360, typical=100, minstep=0.1))

    # Run code
    if rerun:
        (bpe_results, results) = dcs.run_bpe(opti_opts)
    else:
        bpe_results = dcs.BpeResults.load(os.path.join(opti_opts.output_folder, opti_opts.output_results))
        results     = sim_model(sim_params) # just re-run, nothing is actually saved by this model

    # Plot results
    if make_plots:
        # build opts
        opts           = dcs.Opts()
        opts.case_name = 'Model Results'
        opts.save_path = dcs.get_output_dir()
        opts.save_plot = True

        # make model plots
        dcs.plot_time_history(time, results, description='Output vs. Time', opts=opts, truth=truth)

        # make BPE plots
        bpe_plots = {'innovs': True, 'convergence': False, 'correlation': True, 'info_svd': True, \
            'covariance': False}
        dcs.plot_bpe_results(bpe_results, opts, plots=bpe_plots)