def test_contour_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields = ("density", "temperature"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_contour("temperature")
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_contour("temperature")
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_contour("temperature") # BREAKS WITH ndarray
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_contour("temperature", ncont=10, factor=8,
            take_log=False, clim=(0.4, 0.6),
            plot_args={'lw':2.0}, label=True,
            text_args={'text-size':'x-large'})
        p.save(prefix)

        p = SlicePlot(ds, "x", "density")
        s2 = ds.slice(0, 0.2)
        p.annotate_contour("temperature", ncont=10, factor=8,
            take_log=False, clim=(0.4, 0.6),
            plot_args={'lw':2.0}, label=True,
            text_args={'text-size':'x-large'},
            data_source=s2)
        p.save(prefix)
示例#2
0
def test_contour_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "temperature"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_contour("temperature")
            yield assert_fname, p.save(prefix)[0]
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_contour("temperature")
            yield assert_fname, p.save(prefix)[0]
            p = SlicePlot(ds, ax, "density")
            p.annotate_contour("temperature")  # BREAKS WITH ndarray
            yield assert_fname, p.save(prefix)[0]
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_contour("temperature",
                           ncont=10,
                           factor=8,
                           take_log=False,
                           clim=(0.4, 0.6),
                           plot_args={'lw': 2.0},
                           label=True,
                           label_args={'text-size': 'x-large'})
        p.save(prefix)

        p = SlicePlot(ds, "x", "density")
        s2 = ds.slice(0, 0.2)
        p.annotate_contour("temperature",
                           ncont=10,
                           factor=8,
                           take_log=False,
                           clim=(0.4, 0.6),
                           plot_args={'lw': 2.0},
                           label=True,
                           label_args={'text-size': 'x-large'},
                           data_source=s2)
        p.save(prefix)
示例#3
0
def test_contour_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "temperature"))
        for ax in 'xyz':
            p = ProjectionPlot(ds, ax, "density")
            p.annotate_contour("temperature")
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(ds, ax, "density", weight_field="density")
            p.annotate_contour("temperature")
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, "density")
            p.annotate_contour("temperature")  # BREAKS WITH ndarray
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", "density")
        p.annotate_contour("temperature",
                           ncont=10,
                           factor=8,
                           take_log=False,
                           clim=(0.4, 0.6),
                           plot_args={'linewidths': 2.0},
                           label=True,
                           text_args={'fontsize': 'x-large'})
        p.save(prefix)

        p = SlicePlot(ds, "x", "density")
        s2 = ds.slice(0, 0.2)
        p.annotate_contour("temperature",
                           ncont=10,
                           factor=8,
                           take_log=False,
                           clim=(0.4, 0.6),
                           plot_args={'linewidths': 2.0},
                           label=True,
                           text_args={'fontsize': 'x-large'},
                           data_source=s2)
        p.save(prefix)

    with _cleanup_fname() as prefix:
        ds = load(cyl_2d)
        slc = SlicePlot(ds, "theta", "plasma_beta")
        slc.annotate_contour("plasma_beta",
                             ncont=2,
                             factor=7.,
                             take_log=False,
                             clim=(1.e-1, 1.e1),
                             label=True,
                             plot_args={
                                 "colors": ("c", "w"),
                                 "linewidths": 1
                             },
                             text_args={"fmt": "%1.1f"})
        assert_fname(slc.save(prefix)[0])

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "temperature"),
                         geometry="spherical")
        p = SlicePlot(ds, "r", "density")
        p.annotate_contour("temperature",
                           ncont=10,
                           factor=8,
                           take_log=False,
                           clim=(0.4, 0.6),
                           plot_args={'linewidths': 2.0},
                           label=True,
                           text_args={'fontsize': 'x-large'})
        assert_raises(YTDataTypeUnsupported, p.save, prefix)
示例#4
0
def test_contour_callback():
    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(fields=("density", "temperature"), units=("g/cm**3", "K"))
        for ax in "xyz":
            p = ProjectionPlot(ds, ax, ("gas", "density"))
            p.annotate_contour(("gas", "temperature"))
            assert_fname(p.save(prefix)[0])
            p = ProjectionPlot(
                ds, ax, ("gas", "density"), weight_field=("gas", "density")
            )
            p.annotate_contour(("gas", "temperature"))
            assert_fname(p.save(prefix)[0])
            p = SlicePlot(ds, ax, ("gas", "density"))
            p.annotate_contour(("gas", "temperature"))  # BREAKS WITH ndarray
            assert_fname(p.save(prefix)[0])
        # Now we'll check a few additional minor things
        p = SlicePlot(ds, "x", ("gas", "density"))
        p.annotate_contour(
            ("gas", "temperature"),
            levels=10,
            factor=8,
            take_log=False,
            clim=(0.4, 0.6),
            plot_args={"linewidths": 2.0},
            label=True,
            text_args={"fontsize": "x-large"},
        )
        p.save(prefix)

        p = SlicePlot(ds, "x", ("gas", "density"))
        s2 = ds.slice(0, 0.2)
        p.annotate_contour(
            ("gas", "temperature"),
            levels=10,
            factor=8,
            take_log=False,
            clim=(0.4, 0.6),
            plot_args={"linewidths": 2.0},
            label=True,
            text_args={"fontsize": "x-large"},
            data_source=s2,
        )
        p.save(prefix)

    with _cleanup_fname() as prefix:
        ds = load(cyl_2d)
        slc = SlicePlot(ds, "theta", ("gas", "plasma_beta"))
        slc.annotate_contour(
            ("gas", "plasma_beta"),
            levels=2,
            factor=7,
            take_log=False,
            clim=(1.0e-1, 1.0e1),
            label=True,
            plot_args={"colors": ("c", "w"), "linewidths": 1},
            text_args={"fmt": "%1.1f"},
        )
        assert_fname(slc.save(prefix)[0])
        check_axis_manipulation(slc, prefix)

    with _cleanup_fname() as prefix:
        ds = fake_amr_ds(
            fields=("density", "temperature"),
            units=("g/cm**3", "K"),
            geometry="spherical",
        )
        p = SlicePlot(ds, "r", ("gas", "density"))
        kwargs = dict(
            levels=10,
            factor=8,
            take_log=False,
            clim=(0.4, 0.6),
            plot_args={"linewidths": 2.0},
            label=True,
            text_args={"fontsize": "x-large"},
        )
        assert_raises(
            YTDataTypeUnsupported, p.annotate_contour, ("gas", "temperature"), **kwargs
        )