예제 #1
0
def test_grids_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields = ("density",))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, "density")
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
            draw_ids=True, periodic=False, min_level=2,
            max_level=3, cmap="gist_stern")
        p.save(prefix)

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

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields = ("density",), geometry="spherical")
        p = SlicePlot(ds, "r", "density")
        p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
            draw_ids=True, periodic=False, min_level=2,
            max_level=3, cmap="gist_stern")
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
예제 #2
0
def test_grids_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density",), units=("g/cm**3",))
        for ax in "xyz":
            p = ProjectionPlot(ds, ax, ("gas", "density"))
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(
                ds, ax, ("gas", "density"), weight_field=("gas", "density")
            )
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, ("gas", "density"))
            p.annotate_grids()
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", ("gas", "density"))
        p.annotate_grids(
            alpha=0.7,
            min_pix=10,
            min_pix_ids=30,
            draw_ids=True,
            id_loc="upper right",
            periodic=False,
            min_level=2,
            max_level=3,
            cmap="gist_stern",
        )
        p.save(prefix)

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

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density",), units=("g/cm**3",), geometry="spherical")
        p = SlicePlot(ds, "r", ("gas", "density"))
        kwargs = dict(
            alpha=0.7,
            min_pix=10,
            min_pix_ids=30,
            draw_ids=True,
            id_loc="upper right",
            periodic=False,
            min_level=2,
            max_level=3,
            cmap="gist_stern",
        )
        assert_raises(YTDataTypeUnsupported, p.annotate_grids, **kwargs)