... }
>>> model = FJC(d_data, info=info, rescale=True)
>>> outqueue = Queue()
- >>> Lp,a = model.fit(outqueue=outqueue)
+ >>> L,a = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Lp) # doctest: +ELLIPSIS
- 3.500...e-08
- >>> a # doctest: +ELLIPSIS
- 2.499...e-10
+ >>> print L
+ 3.5e-08
+ >>> print a
+ 2.5e-10
Fit the example data with a one-parameter fit (`L`). We introduce
some error in our fixed Kuhn length for fun.
>>> info['Kuhn length (m)'] = 2*a
>>> model = FJC(d_data, info=info, rescale=True)
- >>> Lp = model.fit(outqueue=outqueue)
+ >>> L = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Lp) # doctest: +ELLIPSIS
+ >>> print L # doctest: +ELLIPSIS
3.199...e-08
"""
def Lp(self, L):
self._model_data[:] = FJC_fn(x_data, T, L, a)
return self._model_data
+ def fit(self, *args, **kwargs):
+ params = super(FJC, self).fit(*args, **kwargs)
+ if is_iterable(params):
+ params[0] = self.L(params[0]) # convert Lp -> L
+ params[1] = abs(params[1]) # take the absolute value of `a`
+ else: # params is a float
+ params = self.L(params) # convert Lp -> L
+ return params
+
def guess_initial_params(self, outqueue=None):
"""Guess initial fitting parameters.
return [Lp]
return [Lp, a]
- def guess_scale(self, params, outqueue=None):
- """Guess parameter scales.
-
- Returns
- -------
- Lp_scale : float
- A guess at the reparameterized contour length scale in meters.
- a_scale : float (optional)
- A guess at the Kuhn length in meters. If the length of
- `params` is less than 2, `a_scale` is not returned.
- """
- Lp_scale = 1.0
- if len(params) == 1:
- return [Lp_scale]
- return [Lp_scale] + [x/10.0 for x in params[1:]]
-
def inverse_FJC_PEG_fn(F_data, T=300, N=1, k=150., Lp=3.58e-10, Lh=2.8e-10, dG=3., a=7e-10):
"""Inverse poly(ethylene-glycol) adjusted extended FJC model.
... }
>>> model = FJC_PEG(d_data, info=info, rescale=True)
>>> outqueue = Queue()
- >>> Nr,a = model.fit(outqueue=outqueue)
+ >>> N,a = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Nr) # doctest: +ELLIPSIS
- 122.999...
- >>> a # doctest: +ELLIPSIS
- 6.999...e-10
+ >>> print N
+ 123.0
+ >>> print a
+ 7e-10
Fit the example data with a one-parameter fit (`N`). We introduce
some error in our fixed Kuhn length for fun.
>>> info['Kuhn length (m)'] = 2*kwargs['a']
>>> model = FJC_PEG(d_data, info=info, rescale=True)
- >>> Nr = model.fit(outqueue=outqueue)
+ >>> N = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Nr) # doctest: +ELLIPSIS
+ >>> print N # doctest: +ELLIPSIS
96.931...
"""
def Lr(self, L):
self._model_data[:] = FJC_PEG_fn(x_data, N=N, a=a, **kwargs)
return self._model_data
+ def fit(self, *args, **kwargs):
+ params = super(FJC_PEG, self).fit(*args, **kwargs)
+ if is_iterable(params):
+ params[0] = self.L(params[0]) # convert Nr -> N
+ params[1] = abs(params[1]) # take the absolute value of `a`
+ else: # params is a float
+ params = self.L(params) # convert Nr -> N
+ return params
+
def guess_initial_params(self, outqueue=None):
"""Guess initial fitting parameters.
return [Nr]
return [Nr, a]
- def guess_scale(self, params, outqueue=None):
- """Guess parameter scales.
-
- Returns
- -------
- N_scale : float
- A guess at the section count scale in meters.
- a_scale : float (optional)
- A guess at the Kuhn length in meters. If the length of
- `params` is less than 2, `a_scale` is not returned.
- """
- return [x/10.0 for x in params]
-
def WLC_fn(x_data, T, L, p):
"""The worm like chain interpolation model.
... }
>>> model = WLC(d_data, info=info, rescale=True)
>>> outqueue = Queue()
- >>> Lp,p = model.fit(outqueue=outqueue)
+ >>> L,p = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Lp) # doctest: +ELLIPSIS
- 3.500...e-08
- >>> p # doctest: +ELLIPSIS
- 2.500...e-10
+ >>> print L
+ 3.5e-08
+ >>> print p
+ 2.5e-10
Fit the example data with a one-parameter fit (`L`). We introduce
some error in our fixed persistence length for fun.
>>> info['persistence length (m)'] = 2*p
>>> model = WLC(d_data, info=info, rescale=True)
- >>> Lp = model.fit(outqueue=outqueue)
+ >>> L = model.fit(outqueue=outqueue)
>>> fit_info = outqueue.get(block=False)
- >>> model.L(Lp) # doctest: +ELLIPSIS
+ >>> print L # doctest: +ELLIPSIS
3.318...e-08
"""
def Lp(self, L):
self._model_data[:] = WLC_fn(x_data, T, L, p)
return self._model_data
+ def fit(self, *args, **kwargs):
+ params = super(WLC, self).fit(*args, **kwargs)
+ if is_iterable(params):
+ params[0] = self.L(params[0]) # convert Lp -> L
+ params[1] = abs(params[1]) # take the absolute value of `p`
+ else: # params is a float
+ params = self.L(params) # convert Lp -> L
+ return params
+
def guess_initial_params(self, outqueue=None):
"""Guess initial fitting parameters.
return [Lp]
return [Lp, p]
- def guess_scale(self, params, outqueue=None):
- """Guess parameter scales.
-
- Returns
- -------
- Lp_scale : float
- A guess at the reparameterized contour length scale in meters.
- p_scale : float (optional)
- A guess at the persistence length in meters. If the
- length of `params` is less than 2, `p_scale` is not
- returned.
- """
- Lp_scale = 1.0
- if len(params) == 1:
- return [Lp_scale]
- return [Lp_scale] + [x/10.0 for x in params[1:]]
-
class PolymerFitPlugin (Plugin):
"""Polymer model (WLC, FJC, etc.) fitting.