예제 #1
0
def calck(filename, f_min, f_max,
        quality_factor, spring_constant, resonance_frequency, temperature):
    """Base function for the command line interface. TODO: Add numpy style
    param strings."""
    est_cant = Cantilever(f_c=resonance_frequency*u.Hz,
                          k_c=spring_constant*u.N/u.m,
                          Q=quality_factor*u.dimensionless)

    data = get_data(filename)
    bmf = BrownianMotionFitter(*data, T=temperature, est_cant=est_cant)
    bmf.calc_fit(f_min, f_max)
    return bmf
예제 #2
0
class testBrownianMotionFitter_fitting(unittest.TestCase):
    def setUp(self):
        self.bmf = BrownianMotionFitter(f, PSDx, PSD_wgt, T, est_cant)

    def test_guess_P_detector(self):
        self.bmf._guess_P_detector()
        assert_almost_equal(self.bmf.P_detector0_raw, 6.5209499999999999e-09)

    def test_scale_data(self):
        self.bmf.P_detector0_raw = 6.5209499999999999e-09
        self.bmf._scale_data()
        np.testing.assert_allclose(ex_scaled_PSD, self.bmf.PSD)
        assert self.bmf.P_detector0 == 1

    def test_calc_initial_params(self):
        self.bmf.P_detector0_raw = 6.5209499999999999e-09
        self.bmf.P_detector0 = 1
        self.bmf.PSD = ex_scaled_PSD
        self.bmf._calc_initial_params()

        ex_initial_params = [8.917375e-05, 63700, 20000]

        np.testing.assert_allclose(ex_initial_params, self.bmf.initial_params)
예제 #3
0
 def setUp(self):
     self.bmf = BrownianMotionFitter(f, PSDx, PSD_wgt, T, est_cant)