def test_lazy_eval_sets_up_interpolator(self):
        theta = np.linspace(0, 1.5, 10)
        interpolator = mielensfunctions.MieScatteringMatrix(
            parallel_or_perpendicular='perpendicular', lazy=True)
        assert (interpolator._interp is None)
        approx = interpolator(theta)

        other = mielensfunctions.MieScatteringMatrix(
            parallel_or_perpendicular='perpendicular', lazy=False)
        self.assertEqual(type(interpolator._interp), type(other._interp))
        self.assertTrue(interpolator._interp is not None)
    def test_interpolator_maxl_accuracy(self):
        theta = np.linspace(0, 1.5, 1000)
        interpolator_low_l = mielensfunctions.MieScatteringMatrix(
            parallel_or_perpendicular='perpendicular')

        higher_l = np.ceil(interpolator_low_l.size_parameter * 8).astype('int')
        interpolator_higher_l = mielensfunctions.MieScatteringMatrix(
            parallel_or_perpendicular='perpendicular', max_l=higher_l)

        exact = interpolator_low_l._eval(theta)
        approx = interpolator_higher_l._eval(theta)
        rescale = np.abs(exact).max()

        is_ok = np.allclose(exact / rescale, approx / rescale, **MEDTOLS)
        self.assertTrue(is_ok)
Example #3
0
    def test_works_when_large_size_parameter(self):
        theta = np.linspace(0, 1.5, 11)
        interpolator_low_l = mielensfunctions.MieScatteringMatrix(
            index_ratio=1.1,
            size_parameter=1000.0,  # roughly 80 um sphere
            parallel_or_perpendicular='perpendicular')

        out = interpolator_low_l._eval(theta)
        self.assertFalse(np.any(np.isnan(out)))
    def test_parallel_interpolator_accuracy(self):
        theta = np.linspace(0, 1.5, 1000)
        interpolator = mielensfunctions.MieScatteringMatrix(
            parallel_or_perpendicular='parallel')

        exact = interpolator._eval(theta)
        approx = interpolator(theta)
        rescale = np.abs(exact).max()

        is_ok = np.allclose(exact / rescale, approx / rescale, **MEDTOLS)
        self.assertTrue(is_ok)
 def test_raises_error_on_nans(self):
     theta = np.array([np.nan])
     interpolator = mielensfunctions.MieScatteringMatrix(
         parallel_or_perpendicular='perpendicular')
     self.assertRaises(RuntimeError, interpolator._eval, theta)