Beispiel #1
0
    def test_rotation(self):
        ds = fake_random_ds(32)
        ds2 = fake_random_ds(32)
        dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 2)
        dd2 = ds2.sphere(ds2.domain_center, ds2.domain_width[0] / 2)

        im, sc = volume_render(dd, field=('gas', 'density'))
        im.write_png('test.png')

        vol = sc.get_source(0)
        tf = vol.transfer_function
        tf.clear()
        mi, ma = dd.quantities.extrema('density')
        mi = np.log10(mi)
        ma = np.log10(ma)
        mi_bound = ((ma - mi) * (0.10)) + mi
        ma_bound = ((ma - mi) * (0.90)) + mi
        tf.map_to_colormap(mi_bound, ma_bound, scale=0.01, colormap='Blues_r')

        vol2 = VolumeSource(dd2, field=('gas', 'density'))
        sc.add_source(vol2)

        tf = vol2.transfer_function
        tf.clear()
        mi, ma = dd2.quantities.extrema('density')
        mi = np.log10(mi)
        ma = np.log10(ma)
        mi_bound = ((ma - mi) * (0.10)) + mi
        ma_bound = ((ma - mi) * (0.90)) + mi
        tf.map_to_colormap(mi_bound, ma_bound, scale=0.01, colormap='Reds_r')
        sc.render()
        for suffix in ['png', 'eps', 'ps', 'pdf']:
            fname = 'test_scene.{}'.format(suffix)
            sc.save(fname, sigma_clip=6.0)
            assert_fname(fname)

        nrot = 2
        for i in range(nrot):
            sc.camera.pitch(2 * np.pi / nrot)
            sc.render()
            sc.save('test_rot_%04i.png' % i, sigma_clip=6.0)
Beispiel #2
0
    def test_rotation(self):
        ds = fake_random_ds(32)
        ds2 = fake_random_ds(32)
        dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 2)
        dd2 = ds2.sphere(ds2.domain_center, ds2.domain_width[0] / 2)

        im, sc = volume_render(dd, field=("gas", "density"))
        im.write_png("test.png")

        vol = sc.get_source(0)
        tf = vol.transfer_function
        tf.clear()
        mi, ma = dd.quantities.extrema(("gas", "density"))
        mi = np.log10(mi)
        ma = np.log10(ma)
        mi_bound = ((ma - mi) * (0.10)) + mi
        ma_bound = ((ma - mi) * (0.90)) + mi
        tf.map_to_colormap(mi_bound, ma_bound, scale=0.01, colormap="Blues_r")

        vol2 = create_volume_source(dd2, field=("gas", "density"))
        sc.add_source(vol2)

        tf = vol2.transfer_function
        tf.clear()
        mi, ma = dd2.quantities.extrema(("gas", "density"))
        mi = np.log10(mi)
        ma = np.log10(ma)
        mi_bound = ((ma - mi) * (0.10)) + mi
        ma_bound = ((ma - mi) * (0.90)) + mi
        tf.map_to_colormap(mi_bound, ma_bound, scale=0.01, colormap="Reds_r")
        fname = "test_scene.pdf"
        sc.save(fname, sigma_clip=6.0)
        assert_fname(fname)

        fname = "test_rot.png"
        sc.camera.pitch(np.pi)
        sc.render()
        sc.save(fname, sigma_clip=6.0, render=False)
        assert_fname(fname)