Exemplo n.º 1
0
    def _test(self):

        p = '/Users/ross/Pychrondata_demo/data/snapshots/scan6/007.jpg'
        g = Graph()
        g.new_plot()


        for scan_i, z, idxs in [
#                    1,
#                     2,
#                     3, 4, 5,
#                     (6, [20, 30, 40, 50, 60, 70, 80, 90, 100, ],
#                         [2, 3, 4, 5, 6, 7, 8, 9, 10]
#                      ),
                    (6, [10],
                        [1]
                     ),
#                     (6, [100, 90, 80, 70, 60, 50, 40, 30, 20],
#                         [11, 12, 13, 14, 15, 16, 17, 18, 19]
#                     )

                   ]:
            dxs = []
            zs = []
            root = '/Users/ross/Pychrondata_demo/data/snapshots/scan{}'.format(scan_i)
            for  zi, idx in zip(z, idxs):
                pn = os.path.join(root, '{:03n}.jpg'.format(idx))
                d = load_image(pn)

                dx = self._calculate_spacing(d)
                dxs.append(dx)

                zs.append(zi)

            g.new_series(zs, dxs, type='scatter')

            coeffs = polyfit(zs, dxs, 2)
            print 'parabolic intercept {}'.format(coeffs[-1])

            xs = linspace(0, max(zs))
            ys = polyval(coeffs, xs)
            g.new_series(xs, ys)

            fitfunc = lambda p, x: p[0] * exp(p[1] * x) + p[2]
            lr = LeastSquaresRegressor(fitfunc=fitfunc,
                                       initial_guess=[1, 0.1, 0],
                                       xs=zs,
                                       ys=dxs
                                       )
            xs = linspace(0, max(zs))
            ys = lr.predict(xs)
            print 'exponential intercept {}'.format(lr.predict(0))
            g.new_series(xs, ys)

        invoke_in_main_thread(g.edit_traits)
Exemplo n.º 2
0
    def _least_square_regress(self, scatter, r, fit):
        fitfunc, errfunc = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        self._set_regressor(scatter, r)
        r.trait_set(fitfunc=fitfunc,
                    errfunc=errfunc,
                    trait_change_notify=False)
        r.calculate()
        self._set_excluded(scatter, r)
        return r
Exemplo n.º 3
0
    def _least_square_regress(self, r, x, y, ox, oy, index, fit, fod,
                              apply_filter):
        fitfunc, errfunc = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        r.trait_set(xs=x, ys=y, fitfunc=fitfunc, errfunc=errfunc)

        if apply_filter:
            r = self._apply_outlier_filter(r, ox, oy, index, fod)

        return r
Exemplo n.º 4
0
    def _least_square_regress(self, scatter, r, fit):
        from pychron.core.regression.least_squares_regressor import LeastSquaresRegressor
        func, initial_guess = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        self._set_regressor(scatter, r)
        r.trait_set(fitfunc=func,
                    initial_guess=initial_guess,
                    trait_change_notify=False)
        r.calculate()
        self._set_excluded(scatter, r)
        return r
Exemplo n.º 5
0
    def _test(self):

        p = '/Users/ross/Pychrondata_demo/data/snapshots/scan6/007.jpg'
        g = Graph()
        g.new_plot()

        for scan_i, z, idxs in [
                #                    1,
                #                     2,
                #                     3, 4, 5,
                #                     (6, [20, 30, 40, 50, 60, 70, 80, 90, 100, ],
                #                         [2, 3, 4, 5, 6, 7, 8, 9, 10]
                #                      ),
            (6, [10], [1]),
                #                     (6, [100, 90, 80, 70, 60, 50, 40, 30, 20],
                #                         [11, 12, 13, 14, 15, 16, 17, 18, 19]
                #                     )
        ]:
            dxs = []
            zs = []
            root = '/Users/ross/Pychrondata_demo/data/snapshots/scan{}'.format(
                scan_i)
            for zi, idx in zip(z, idxs):
                pn = os.path.join(root, '{:03n}.jpg'.format(idx))
                d = load_image(pn)

                dx = self._calculate_spacing(d)
                dxs.append(dx)

                zs.append(zi)

            g.new_series(zs, dxs, type='scatter')

            coeffs = polyfit(zs, dxs, 2)
            print 'parabolic intercept {}'.format(coeffs[-1])

            xs = linspace(0, max(zs))
            ys = polyval(coeffs, xs)
            g.new_series(xs, ys)

            fitfunc = lambda p, x: p[0] * exp(p[1] * x) + p[2]
            lr = LeastSquaresRegressor(fitfunc=fitfunc,
                                       initial_guess=[1, 0.1, 0],
                                       xs=zs,
                                       ys=dxs)
            xs = linspace(0, max(zs))
            ys = lr.predict(xs)
            print 'exponential intercept {}'.format(lr.predict(0))
            g.new_series(xs, ys)

        invoke_in_main_thread(g.edit_traits)
Exemplo n.º 6
0
    def _least_square_regress(self, r, x, y, ox, oy, index,
                              fit, fod, apply_filter):
        fitfunc, errfunc = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        r.trait_set(xs=x, ys=y,
                    fitfunc=fitfunc,
                    errfunc=errfunc)

        if apply_filter:
            r = self._apply_outlier_filter(r, ox, oy, index, fod)

        return r
Exemplo n.º 7
0
    def _least_square_regress(self, scatter, r, fit):
        fitfunc, errfunc = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        self._set_regressor(scatter, r)
        r.trait_set(fitfunc=fitfunc,
                    errfunc=errfunc,
                    trait_change_notify=False)
        r.calculate()
        self._set_excluded(scatter, r)
        return r
Exemplo n.º 8
0
    def _least_square_regress(self, scatter, r, fit):
        from pychron.core.regression.least_squares_regressor import LeastSquaresRegressor
        func, initial_guess = fit
        if r is None or not isinstance(r, LeastSquaresRegressor):
            r = LeastSquaresRegressor()

        self._set_regressor(scatter, r)
        r.trait_set(fitfunc=func,
                    initial_guess=initial_guess,
                    trait_change_notify=False)
        r.calculate()
        self._set_excluded(scatter, r)
        return r