def test_vcaribu():
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = data_path('par.opt')
    pattern = None
    options = {'infinity': False}
    nrj, status = vcaribu(can, sky, opts, pattern, options)
Exemplo n.º 2
0
    def test_instantiation_from_files():
        can = str(data_path('filterT.can'))
        sky = str(data_path('Turtle16soc.light'))
        opts = map(str, [data_path('par.opt'), data_path('nir.opt')])
        pattern = str(data_path('filter.8'))

        # defaults
        cs = CaribuScene()
        assert cs.scene is None
        assert cs.light == [cs.default_light]
        assert cs.pattern is None
        assert cs.material is None
        assert cs.soil_reflectance[
                   cs.default_band] == cs.default_soil_reflectance

        # complete set of files
        cs = CaribuScene(scene=can, light=sky, opt=opts, pattern=pattern)
        assert len(cs.scene) == 1
        assert len(cs.scene[cs.scene.keys()[0]]) == 192
        assert len(cs.light) == 16
        for band in ('nir', 'par'):
            assert band in cs.material
            assert len(cs.material[band]) == len(cs.scene)
        assert cs.soil_reflectance['par'] != cs.soil_reflectance['nir']
        assert len(cs.pattern) == 4

        # incomplete set of files
        cs = CaribuScene(scene=can)
        assert len(cs.material[cs.default_band]) == len(cs.scene)

        return cs
def test_caribu_inconsistent_case():
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]

    sim = Caribu(canfile=can, skyfile=sky,
                 optfiles=opts, resdir=None, resfile=None)

    sim.direct = False  # NOT direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None

    # radiosity toric scene
    sim.infinity = True
    sim.pattern = data_path('filter.8')
    try:
        sim.run()
        assert False, "This test uses inconsistent options, it should raise an CaribuOptionError"
    except CaribuOptionError:
        assert True

    # nested radiosity non toric scene
    sim.infinity = False
    sim.pattern = None
    sim.sphere_diameter = 1
    sim.nb_layers = 6
    sim.can_height = 21
    try:
        sim.run()
        assert False, "This test uses inconsistent options, it should raise an CaribuOptionError"
    except CaribuOptionError:
        assert True
def test_materials():
    can = data_path('filterT.can')
    cscene = read_can(can)
    path = data_path('par.opt')
    n, s, opts = read_opt(path)
    materials = build_materials(cscene.keys(), opts, s)
    assert len(materials) == len(cscene)
    assert materials[materials.keys()[0]] == (0.1, 0.05)
    return materials
def test_light():
    sky = data_path('zenith.light')
    lights = read_light(sky)
    assert len(lights) == 1
    assert lights[0][0] == 1
    assert lights[0][1] == (0, 0, -1)

    sky = data_path('Turtle16soc.light')
    lights = read_light(sky)
    assert len(lights) == 16

    return lights
def test_case_1_projection_non_toric_scene(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]

    sim = Caribu(canfile=can, skyfile=sky,
                 optfiles=opts, resdir=None, resfile=None, debug=debug)

    sim.infinity = False
    sim.direct = True  # direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None
    sim.run()
    return sim.nrj
def test_sensor(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]
    sensor = data_path('sensor.can')

    sim = Caribu(canfile=can, skyfile=sky,
                 optfiles=opts, sensorfile=sensor, resdir=None, resfile=None, debug=debug)

    sim.infinity = False
    sim.direct = True  # direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None
    sim.run()
    return sim.measures
def test_can():
    can = data_path('filterT.can')
    cscene = read_can(can)
    assert len(cscene) == 1
    triangles = cscene[cscene.keys()[0]]
    assert len(triangles[0]) == 3
    assert len(triangles[0][0]) == 3

    return cscene
def test_opt():
    path = data_path('par.opt')
    n, s, opts = read_opt(path)

    assert n == 2
    assert s == 0.15
    assert opts[1] == (0.1, 0.1, 0.05, 0.1, 0.05)

    return n, s, opts
Exemplo n.º 10
0
def test_case_3_radiosity_non_toric_scene(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]

    sim = Caribu(canfile=can,
                 skyfile=sky,
                 optfiles=opts,
                 resdir=None,
                 resfile=None,
                 debug=debug)

    sim.infinity = False
    sim.direct = False  # NOT direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None

    sim.run()
    return sim.nrj
Exemplo n.º 11
0
def test_sensor(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]
    sensor = data_path('sensor.can')

    sim = Caribu(canfile=can,
                 skyfile=sky,
                 optfiles=opts,
                 sensorfile=sensor,
                 resdir=None,
                 resfile=None,
                 debug=debug)

    sim.infinity = False
    sim.direct = True  # direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None
    sim.run()
    return sim.measures
Exemplo n.º 12
0
def test_caribu_inconsistent_case():
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]

    sim = Caribu(canfile=can,
                 skyfile=sky,
                 optfiles=opts,
                 resdir=None,
                 resfile=None)

    sim.direct = False  # NOT direct light only
    sim.nb_layers = None
    sim.can_height = None
    sim.sphere_diameter = -1
    sim.pattern = None

    # radiosity toric scene
    sim.infinity = True
    sim.pattern = data_path('filter.8')
    try:
        sim.run()
        assert False, "This test uses inconsistent options, it should raise an CaribuOptionError"
    except CaribuOptionError:
        assert True

    # nested radiosity non toric scene
    sim.infinity = False
    sim.pattern = None
    sim.sphere_diameter = 1
    sim.nb_layers = 6
    sim.can_height = 21
    try:
        sim.run()
        assert False, "This test uses inconsistent options, it should raise an CaribuOptionError"
    except CaribuOptionError:
        assert True
Exemplo n.º 13
0
def test_case_5_nested_radiosity_toric_scene(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]
    opts = data_path('par.opt')
    sim = Caribu(canfile=can, skyfile=sky,
                 optfiles=opts, resdir=None, resfile=None, debug=debug)

    sim.infinity = True
    sim.direct = False  # NOT direct light only
    sim.sphere_diameter = 1  # 1, 2, 5, 10, 20 make canestra crash !!!
    sim.nb_layers = 6
    sim.can_height = 21
    sim.pattern = data_path('filter.8')

    sim.run()
    return sim.nrj
Exemplo n.º 14
0
def test_case_5_nested_radiosity_toric_scene(debug=False):
    can = data_path('filterT.can')
    sky = data_path('zenith.light')
    opts = [data_path('par.opt'), data_path('nir.opt')]
    opts = data_path('par.opt')
    sim = Caribu(canfile=can,
                 skyfile=sky,
                 optfiles=opts,
                 resdir=None,
                 resfile=None,
                 debug=debug)

    sim.infinity = True
    sim.direct = False  # NOT direct light only
    sim.sphere_diameter = 1  # 1, 2, 5, 10, 20 make canestra crash !!!
    sim.nb_layers = 6
    sim.can_height = 21
    sim.pattern = data_path('filter.8')

    sim.run()
    return sim.nrj
Exemplo n.º 15
0
def test_pattern():
    path = data_path('filter.8')
    domain = read_pattern(path)
    assert domain == (0, 0, 20, 20)
    return domain