def test_n():
    sph = Sphere(par(.5), 1.6, (5,5,5))
    sch = ImageSchema(shape=[100, 100], spacing=[0.1, 0.1],
                      optics=Optics(wavelen=0.66,
                                    index=1.33,
                                    polarization=[1, 0],
                                    divergence=0.0),
                      origin=[0.0, 0.0, 0.0])

    model = Model(sph, Mie.calc_holo, alpha=1)
    holo = Mie.calc_holo(model.scatterer.guess, sch)
    coster = CostComputer(holo, model, use_random_fraction=.1)
    assert_allclose(coster.flattened_difference({'n' : .5}), 0)
Exemple #2
0
def test_n():
    sph = Sphere(par(.5), 1.6, (5,5,5))
    sch = ImageSchema(shape=[100, 100], spacing=[0.1, 0.1],
                      optics=Optics(wavelen=0.66,
                                    index=1.33,
                                    polarization=[1, 0],
                                    divergence=0.0),
                      origin=[0.0, 0.0, 0.0])

    model = Model(sph, Mie.calc_holo, alpha=1)
    holo = Mie.calc_holo(model.scatterer.guess, sch)
    coster = CostComputer(holo, model, random_subset=.1)
    assert_allclose(coster.flattened_difference({'n' : .5}), 0)
def test_constraint():
    sch = ImageSchema(100)
    with warnings.catch_warnings():
        # TODO: we should really only supress overlap warnings here,
        # but I am too lazy to figure it out right now, and I don't
        # think we are likely to hit warnings here that won't get
        # caught elsewhere -tgd 2013-12-01
        warnings.simplefilter("ignore")
        spheres = Spheres([Sphere(r=.5, center=(0,0,0)),
                           Sphere(r=.5, center=(0,0,par(.2)))])
        model = Model(spheres, Multisphere.calc_holo, constraints=limit_overlaps())
        coster = CostComputer(sch, model)
        cost = coster._calc({'1:Sphere.center[2]' : .2})
        assert_equal(cost, np.ones_like(sch)*np.inf)
Exemple #4
0
def test_constraint():
    sch = ImageSchema(100)
    with warnings.catch_warnings():
        # TODO: we should really only supress overlap warnings here,
        # but I am too lazy to figure it out right now, and I don't
        # think we are likely to hit warnings here that won't get
        # caught elsewhere -tgd 2013-12-01
        warnings.simplefilter("ignore")
        spheres = Spheres([Sphere(r=.5, center=(0,0,0)),
                           Sphere(r=.5, center=(0,0,par(.2)))])
        model = Model(spheres, Multisphere.calc_holo, constraints=limit_overlaps())
        coster = CostComputer(sch, model)
        cost = coster._calc({'1:Sphere.center[2]' : .2})
        assert_equal(cost, np.ones_like(sch)*np.inf)