Package qubx :: Module fit_robot :: Class FitRobot
[hide private]
[frames] | no frames]

Class FitRobot

source code

object --+        
         |        
 task.Task --+    
             |    
    task.Robot --+
                 |
                FitRobot

Background thread to operate qubx.fit. Instead of reading instance variables, respond to events. Events are fired in the gobject thread when something changes, or when you request_something(). Stats are given after OnEndFit, or when requested.

Stats:

Instance Methods [hide private]
 
__init__(self, label='Fit')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
dispose(self) source code
 
set_data(self, xx, yy, vvv=[], v_names=[])
Makes available the x, y and variable series.
source code
 
set_weight(self, expr)
Tells how to calculate each sample's weight; ssr = sum( (weight*dy)**2 ).
source code
 
set_curve(self, curve_class, expr=None)
Changes the curve function.
source code
 
set_expr(self, expr)
Changes the curve function.
source code
 
set_param(self, nm, value=None, lo=None, hi=None, can_fit=None)
Changes the value, low bound, high bound, and/or can_fit of a curve param.
source code
 
set_max_iter(self, x)
Changes the max number of param improvements per fit().
source code
 
set_toler(self, x)
Changes the precision of future fit()s.
source code
 
set_strategy(self, x)
Modifies the startup script.
source code
 
add_strategy_line(self)
Repeats the final fit(...) line in strategy script.
source code
 
set_fitter(self, fitter_class)
Replaces the fitter with fitter_class(max_iter, toler) .
source code
 
request_data(self)
Triggers OnData.
source code
 
request_curve(self)
Triggers OnExpr.
source code
 
request_fitparams(self)
Triggers OnMaxIter and OnToler.
source code
 
request_strategy(self)
Triggers OnStrategy.
source code
 
request_fitter_name(self)
Triggers OnFitter.
source code
 
request_stats(self)
Triggers OnStats.
source code
 
fit(self, grab_initial=True)
Improves param values; Triggers OnStartFit, OnIteration, ..., OnEndFit, OnParam, ..., OnStats.
source code
 
robot_request_data(self) source code
 
robot_request_curve(self) source code
 
robot_request_param(self, i) source code
 
robot_request_fitparams(self) source code
 
robot_request_strategy(self) source code
 
robot_request_fitter_name(self) source code
 
robot_request_stats(self, serial) source code
 
robot_do_stats(self) source code
 
robot_locals_lo(self, name) source code
 
robot_locals_hi(self, name) source code
 
robot_set_data(self, xx, yy, vvv=[], v_names=[]) source code
 
robot_set_weight(self, expr) source code
 
robot_set_curve(self, curve_class, expr=None) source code
 
robot_set_expr(self, expr) source code
 
robot_save_params(self) source code
 
robot_re_param(self, old_params) source code
 
robot_set_param(self, nm, value, lo, hi, can_fit) source code
 
robot_set_max_iter(self, max_iter) source code
 
robot_set_toler(self, toler) source code
 
robot_set_fitter(self, fitter_class) source code
 
robot_set_strategy(self, script) source code
 
robot_add_strategy_line(self) source code
 
robot_fit(self, serial, grab_initial)
Fits by running strategy script; "fit" in script refers to robot_strategy_fit, below.
source code
 
robot_strategy_fit(self, variables=None, **params)
Implementation of strategy.locals.fit
source code
 
robot_on_iter(self, param_vals, iter) source code
 
robot_on_status(self, msg) source code
 
__onException(self, robot, typ, val, trace) source code
 
__onInterrupt(self, robot, cancel) source code
 
__onOutput(self, msg) source code
 
__onChangeStrategy(self, strategy, script) source code

Inherited from task.Robot: do, hold_from_task, interrupt, robot_settrace, run, run_one, settrace, stop, sync, trace_func

Inherited from task.Task: __call__, gui_call_recv, idle_wait, join, send_exception, send_progress, send_result, send_status, set_progress, set_status, start, thread_main

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  OnData
WeakEvent(xx, yy, vvv, v_names)
  OnEndFit
WeakEvent()
  OnEndFit_Robot
WeakEvent() called in robot thread
  OnExpr
WeakEvent(curve_name, curve_expr, params, param_vals, lo, hi, can_fit)
  OnFitter
WeakEvent(name_of_fitter)
  OnIteration
WeakEvent(param_vals, iteration)
  OnMaxIter
WeakEvent(max_iter)
  OnOutput
WeakEvent(str) duplication of stdout during strategy
  OnParam
WeakEvent(index, name, value, lo, hi, can_fit)
  OnStartFit
WeakEvent()
  OnStartFit_Robot
WeakEvent() called in robot thread
  OnStats
WeakEvent(correlation, is_pseudo, std_err_est[], ssr, r2, runs_prob)
  OnStatus
qubx.util_types.WeakEvent(Task, status)
  OnStrategy
WeakEvent(strategy_script)
  OnStrategyWarn
WeakEvent(Strategy) when curve has changed and script may reference invalid vars
  OnToler
WeakEvent(toler)
  OnWeight
WeakEvent(weight_expr)
  fitter
Simplex_LM_Fitter instance; replace it if you want

Inherited from task.Task: OnException, OnInterrupt, OnProgress, OnResult, OnTerminate, label, main_hold, progress, status, tid

Properties [hide private]
  curve

Inherited from task.Robot: acting, on_finish_item, on_start_item

Inherited from object: __class__

Method Details [hide private]

__init__(self, label='Fit')
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

set_data(self, xx, yy, vvv=[], v_names=[])

source code 

Makes available the x, y and variable series. Doesn't auto-update-stats.

Parameters:
  • xx - numpy.array(dtype='float32') of x coords
  • yy - numpy.array(dtype='float32') of y coords
  • vvv - list of numpy.array(dtype='float32') per extra variable
  • v_names - list of names corresponding to the vvv; can be used in expr and weight

set_weight(self, expr)

source code 

Tells how to calculate each sample's weight; ssr = sum( (weight*dy)**2 ).

Parameters:
  • expr - python expression (str) in terms of x and v_names

set_curve(self, curve_class, expr=None)

source code 

Changes the curve function.

Parameters:

set_expr(self, expr)

source code 

Changes the curve function.

Parameters:
  • expr - either the right-hand side of "y=something+f(other)", or a system of ODEs; see acceptODEs.

set_param(self, nm, value=None, lo=None, hi=None, can_fit=None)

source code 

Changes the value, low bound, high bound, and/or can_fit of a curve param.

Parameters:
  • nm - name of curve param
  • value - new value, or None to leave unchanged
  • lo - new lower bound, or UNSET_VALUE, or None to leave unchanged
  • hi - new upper bound, or UNSET_VALUE, or None to leave unchanged
  • can_fit - True if the fitter can change it

request_stats(self)

source code 

Triggers OnStats. If multiple stats requests are pending, only the newest one is honored.

fit(self, grab_initial=True)

source code 

Improves param values; Triggers OnStartFit, OnIteration, ..., OnEndFit, OnParam, ..., OnStats. If multiple fit requests are pending, only the newest one is honored.


Property Details [hide private]

curve

Get Method:
unreachable(self)