Use numpy.nan to hide unfit portions of polymer tension columns.
[hooke.git] / hooke / plugin / polymer_fit.py
index a5e892e696096ee9b8568e4f44e96e7f767a40be..43ed44ba00d5eb8cb3bff8d64d12a3143d9323e3 100644 (file)
@@ -1032,10 +1032,9 @@ Name (without units) for storing the fit parameters in the `.info` dictionary.
         L = model.L(Lp)
         T = info['temperature (K)']
         fit_info = queue.get(block=False)
-        mask = numpy.zeros(z_data.shape, dtype=numpy.bool)
-        mask[start:stop] = True
-        return [FJC_fn(z_data, T=T, L=L, a=a) * mask,
-                fit_info]
+        f_data = numpy.ones(z_data.shape, dtype=z_data.dtype) * numpy.nan
+        f_data[start:stop] = FJC_fn(z_data[start:stop], T=T, L=L, a=a)
+        return [f_data, fit_info]
 
     def fit_FJC_PEG_model(self, params, z_data, d_data, start, stop,
                           outqueue=None):
@@ -1049,7 +1048,7 @@ Name (without units) for storing the fit parameters in the `.info` dictionary.
         if True:  # TODO: optionally free persistence length
             info['Kuhn length (m)'] = (
                 params['FJC Kuhn length'])
-        model = FJC(d_data[start:stop], info=info, rescale=True)
+        model = FJC_PEG(d_data[start:stop], info=info, rescale=True)
         queue = Queue()
         params = model.fit(outqueue=queue)
         if True:  # TODO: if Kuhn length fixed
@@ -1061,10 +1060,9 @@ Name (without units) for storing the fit parameters in the `.info` dictionary.
         N = model.L(Nr)
         T = info['temperature (K)']
         fit_info = queue.get(block=False)
-        mask = numpy.zeros(z_data.shape, dtype=numpy.bool)
-        mask[start:stop] = True
-        return [FJC_PEG_fn(z_data, **kwargs) * mask,
-                fit_info]
+        f_data = numpy.ones(z_data.shape, dtype=z_data.dtype) * numpy.nan
+        f_data[start:stop] = FJC_PEG_fn(z_data[start:stop], **kwargs)
+        return [f_data, fit_info]
 
     def fit_WLC_model(self, params, z_data, d_data, start, stop,
                       outqueue=None):
@@ -1089,11 +1087,9 @@ Name (without units) for storing the fit parameters in the `.info` dictionary.
         L = model.L(Lp)
         T = info['temperature (K)']
         fit_info = queue.get(block=False)
-        mask = numpy.zeros(z_data.shape, dtype=numpy.bool)
-        mask[start:stop] = True
-        return [WLC_fn(z_data, T=T, L=L, p=p) * mask,
-                fit_info]
-
+        f_data = numpy.ones(z_data.shape, dtype=z_data.dtype) * numpy.nan
+        f_data[start:stop] = WLC_fn(z_data[start:stop], T=T, L=L, p=p)
+        return [f_data, fit_info]
 
 
 class PolymerFitPeaksCommand (Command):