Beispiel #1
0
 def setUp(self):
     self.logger           = dcs.Logger(10)
     self.opti_opts        = type('Class1', (object, ), {'tol_cosmax_grad': 1, 'tol_delta_step': 2, \
         'tol_delta_cost': 3})
     self.cosmax           = 10
     self.delta_step_len   = 10
     self.pred_func_change = 10
Beispiel #2
0
 def setUp(self):
     self.figs = []
     self.logger = dcs.Logger(10)
     self.bpe_results = dcs.BpeResults()
     self.opts = dcs.Opts()
     self.plots = {'innovs': True, 'convergence': True, 'correlation': True, 'info_svd': True, \
     'covariance': True}
Beispiel #3
0
 def setUp(self):
     self.logger = dcs.Logger(0)
     self.opti_opts = dcs.OptiOpts()
     self.opti_opts.model_func     = str
     self.opti_opts.model_args     = {'a': 1}
     self.opti_opts.cost_func      = str
     self.opti_opts.cost_args      = {'b': 2}
     self.opti_opts.get_param_func = str
     self.opti_opts.set_param_func = repr
     self.opti_opts.output_folder  = ''
     self.opti_opts.output_results = ''
     self.opti_opts.params         = [1, 2]
Beispiel #4
0
    def setUp(self):
        self.logger = dcs.Logger(10)
        time        = np.arange(251)
        sim_params  = SimParams(time, magnitude=3.5, frequency=12, phase=180)
        truth_time  = np.arange(-10, 201)
        truth_data  = 5 * np.sin(2*np.pi*10*time/1000 + 90*np.pi/180)

        self.opti_opts = dcs.OptiOpts()
        self.opti_opts.model_func     = sim_model
        self.opti_opts.model_args     = {'sim_params': sim_params}
        self.opti_opts.cost_func      = cost_wrapper
        self.opti_opts.cost_args      = {'results_time': time, 'truth_time': truth_time, 'truth_data': truth_data}
        self.opti_opts.get_param_func = get_parameter
        self.opti_opts.set_param_func = set_parameter
        self.opti_opts.output_folder  = ''
        self.opti_opts.output_results = ''
        self.opti_opts.params         = []

        # Parameters to estimate
        self.opti_opts.params.append(dcs.OptiParam('magnitude', best=2.5, min_=-10, max_=10, typical=5, minstep=0.01))
        self.opti_opts.params.append(dcs.OptiParam('frequency', best=20, min_=1, max_=1000, typical=60, minstep=0.01))
        self.opti_opts.params.append(dcs.OptiParam('phase', best=180, min_=0, max_=360, typical=100, minstep=0.1))
Beispiel #5
0
 def test_null_instantiation(self):
     level = self.logger.get_level()
     logger = dcs.Logger()
     self.assertEqual(level, logger.get_level())
Beispiel #6
0
 def setUp(self):
     self.level  = 8
     self.logger = dcs.Logger(self.level)
     self.print  = 'Logger(8)'
if __name__ == '__main__':
    # Constants
    rerun = True
    make_plots = True
    time = np.arange(251)

    # Parameters
    sim_params = SimParams(time, magnitude=3.5, frequency=12, phase=180)

    # Truth data
    truth_time = np.arange(-10, 201)
    truth_data = truth(truth_time)
    truth = dcs.TruthPlotter(truth_time, truth_data)

    # Logger
    dcs.Logger().set_level(10)

    # BPE Settings
    opti_opts = dcs.OptiOpts()
    opti_opts.model_func = sim_model
    opti_opts.model_args = {'sim_params': sim_params}
    opti_opts.cost_func = cost_wrapper
    opti_opts.cost_args = {
        'results_time': time,
        'truth_time': truth_time,
        'truth_data': truth_data
    }
    opti_opts.get_param_func = get_parameter
    opti_opts.set_param_func = set_parameter
    opti_opts.output_folder = os.path.join(dcs.get_output_dir(),
                                           datetime.now().strftime('%Y-%m-%d'))