コード例 #1
0
 def test_no_logging(self):
     self.logger.set_level(0)
     with dcs.capture_output() as out:
         self.figs = dcs.plot_bpe_results(self.bpe_results, plots=self.plots)
     output = out.getvalue().strip()
     out.close()
     self.assertEqual(output, '')
コード例 #2
0
 def test_nodata(self):
     with dcs.capture_output() as out:
         self.figs = dcs.plot_bpe_results(self.bpe_results, plots=self.plots)
     lines = out.getvalue().strip().split('\n')
     out.close()
     self.assertEqual(lines[0], "Data isn't available for Innovations plot.")
     self.assertEqual(lines[1], "Data isn't available for convergence plot.")
     self.assertEqual(lines[2], "Data isn't available for correlation plot.")
     self.assertEqual(lines[3], "Data isn't available for information SVD plot.")
     self.assertEqual(lines[4], "Data isn't available for covariance plot.")
コード例 #3
0
 def test_nominal(self):
     # add data
     names = ['a', 'b', 'c', 'd']
     matrix = np.random.rand(4, 4)
     self.bpe_results.param_names  = [x.encode('utf-8') for x in names]
     self.bpe_results.begin_innovs = np.array([1, 2, 3, 4], dtype=float)
     self.bpe_results.final_innovs = np.array([0.5, 0.25, 0.1, 0.05])
     self.bpe_results.costs        = np.array([1, 0.1, 0.05, 0.01])
     self.bpe_results.correlation  = matrix.copy()
     self.bpe_results.info_svd     = matrix.copy()
     self.bpe_results.covariance   = matrix.copy()
     self.figs = dcs.plot_bpe_results(self.bpe_results, plots=self.plots)
コード例 #4
0
 def test_only_one_key(self):
     dcs.plot_bpe_results(self.bpe_results, plots={'innovs': False})
コード例 #5
0
 def test_bad_plot(self):
     with self.assertRaises(ValueError):
         dcs.plot_bpe_results(self.bpe_results, plots={'bad_key': False})
コード例 #6
0
 def test_no_plots(self):
     dcs.plot_bpe_results(self.bpe_results, self.opts)
コード例 #7
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)
コード例 #8
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)