def test_velocity_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "velocity_x", "velocity_y",
                                 "velocity_z"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_velocity()
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, "density")
            p.annotate_velocity()
            assert_fname(p.save(prefix)[0])
        # Test for OffAxis Slice
        p = SlicePlot(ds, [1, 1, 0], 'density', north_vector=[0, 0, 1])
        p.annotate_velocity(factor=40, normalize=True)
        assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_velocity(factor=8,
                            scale=0.5,
                            scale_units="inches",
                            normalize=True)
        assert_fname(p.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "velocity_r", "velocity_theta",
                                 "velocity_phi"),
                         geometry="spherical")
        p = ProjectionPlot(ds, "r", "density")
        p.annotate_velocity(factor=40, normalize=True)
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
示例#2
0
def test_velocity_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(
            fields=("density", "velocity_x", "velocity_y", "velocity_z"),
            units=("g/cm**3", "cm/s", "cm/s", "cm/s"),
        )
        for ax in "xyz":
            p = ProjectionPlot(ds,
                               ax, ("gas", "density"),
                               weight_field=("gas", "density"))
            p.annotate_velocity()
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, ("gas", "density"))
            p.annotate_velocity()
            assert_fname(p.save(prefix)[0])
        # Test for OffAxis Slice
        p = SlicePlot(ds, [1, 1, 0], ("gas", "density"),
                      north_vector=[0, 0, 1])
        p.annotate_velocity(factor=40, normalize=True)
        assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", ("gas", "density"))
        p.annotate_velocity(factor=8,
                            scale=0.5,
                            scale_units="inches",
                            normalize=True)
        assert_fname(p.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_hexahedral_ds(fields=[f"velocity_{ax}" for ax in "xyz"])
        sl = SlicePlot(ds, 1, ("connect1", "test"))
        sl.annotate_velocity()
        assert_fname(sl.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = load(cyl_2d)
        slc = SlicePlot(ds, "theta", ("gas", "velocity_magnitude"))
        slc.annotate_velocity()
        assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = load(cyl_3d)
        for ax in ["r", "z", "theta"]:
            slc = SlicePlot(ds, ax, ("gas", "velocity_magnitude"))
            slc.annotate_velocity()
            assert_fname(slc.save(prefix)[0])
            slc = ProjectionPlot(ds, ax, ("gas", "velocity_magnitude"))
            slc.annotate_velocity()
            assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(
            fields=("density", "velocity_r", "velocity_theta", "velocity_phi"),
            units=("g/cm**3", "cm/s", "cm/s", "cm/s"),
            geometry="spherical",
        )
        p = ProjectionPlot(ds, "r", ("gas", "density"))
        p.annotate_velocity(factor=40, normalize=True)
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
def test_velocity_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields =
            ("density", "velocity_x", "velocity_y", "velocity_z"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_velocity()
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_velocity()
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_velocity(factor=8, scale=0.5, scale_units="inches",
                            normalize = True)
        p.save(prefix)
示例#4
0
def test_velocity_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "velocity_x", "velocity_y",
                                 "velocity_z"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_velocity()
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_velocity()
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_velocity(factor=8,
                            scale=0.5,
                            scale_units="inches",
                            normalize=True)
        p.save(prefix)