示例#1
0
def test_quiver_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")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_quiver("velocity_x", "velocity_y", factor=8, scale=0.5,
            scale_units="inches", normalize = True,
            bv_x = 0.5 * u.cm / u.s,
            bv_y = 0.5 * u.cm / u.s)
        yield assert_fname, p.save(prefix)[0]

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields = 
            ("density", "velocity_x", "velocity_theta", "velocity_phi"),
            geometry="spherical")
        p = ProjectionPlot(ds, "r", "density")
        p.annotate_quiver("velocity_theta", "velocity_phi", factor=8, scale=0.5,
            scale_units="inches", normalize = True,
            bv_x = 0.5 * u.cm / u.s,
            bv_y = 0.5 * u.cm / u.s)
        yield assert_raises, YTDataTypeUnsupported, p.save, prefix
def test_quiver_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")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_quiver("velocity_x", "velocity_y")
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_quiver("velocity_x", "velocity_y", factor=8, scale=0.5,
            scale_units="inches", normalize = True,
            bv_x = 0.5 * u.cm / u.s,
            bv_y = 0.5 * u.cm / u.s)
        p.save(prefix)
示例#3
0
def test_quiver_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")
            p.annotate_quiver("velocity_x", "velocity_y")
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_quiver("velocity_x", "velocity_y")
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, "density")
            p.annotate_quiver("velocity_x", "velocity_y")
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_quiver(
            "velocity_x",
            "velocity_y",
            factor=8,
            scale=0.5,
            scale_units="inches",
            normalize=True,
            bv_x=0.5 * u.cm / u.s,
            bv_y=0.5 * u.cm / u.s,
        )
        assert_fname(p.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = load(cyl_2d)
        slc = SlicePlot(ds, "theta", "density")
        slc.annotate_quiver("velocity_r", "velocity_z")
        assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = load(cyl_3d)
        slc = SlicePlot(ds, "r", "velocity_magnitude")
        slc.annotate_quiver("velocity_theta", "velocity_z")
        assert_fname(slc.save(prefix)[0])
        slc = SlicePlot(ds, "z", "velocity_magnitude")
        slc.annotate_quiver("velocity_cartesian_x", "velocity_cartesian_y")
        assert_fname(slc.save(prefix)[0])
        slc = SlicePlot(ds, "theta", "velocity_magnitude")
        slc.annotate_quiver("velocity_r", "velocity_z")
        assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(
            fields=("density", "velocity_x", "velocity_theta", "velocity_phi"),
            geometry="spherical",
        )
        p = ProjectionPlot(ds, "r", "density")
        p.annotate_quiver(
            "velocity_theta",
            "velocity_phi",
            factor=8,
            scale=0.5,
            scale_units="inches",
            normalize=True,
            bv_x=0.5 * u.cm / u.s,
            bv_y=0.5 * u.cm / u.s,
        )
        assert_raises(YTDataTypeUnsupported, p.save, prefix)