Exemplo n.º 1
0
def test_set_units():
    ds = load(tgal)
    sp = ds.sphere("max", (1.0, "Mpc"))
    pp = ParticlePhasePlot(sp, ("Gas", "density"), ("Gas", "temperature"),
                           ("Gas", "particle_mass"))
    # make sure we can set the units using the tuple without erroring out
    pp.set_unit(("Gas", "particle_mass"), "Msun")
Exemplo n.º 2
0
    def test_particle_phase_plot(self):
        test_ds = fake_particle_ds()
        data_sources = [test_ds.region([0.5] * 3, [0.4] * 3, [0.6] * 3),
                        test_ds.all_data()]
        particle_phases = []

        for source in data_sources:
            for x_field, y_field, z_fields in PHASE_FIELDS:
                particle_phases.append(ParticlePhasePlot(source,
                                                         x_field,
                                                         y_field,
                                                         z_fields,
                                                         x_bins=16,
                                                         y_bins=16))

                particle_phases.append(ParticlePhasePlot(source,
                                                         x_field,
                                                         y_field,
                                                         z_fields,
                                                         x_bins=16,
                                                         y_bins=16,
                                                         deposition='cic'))

                pp = create_profile(source, [x_field, y_field], z_fields,
                                    weight_field='particle_ones',
                                    n_bins=[16, 16])

                particle_phases.append(ParticlePhasePlot.from_profile(pp))
        particle_phases[0]._repr_html_()
        for p in particle_phases:
            for fname in TEST_FLNMS:
                assert assert_fname(p.save(fname)[0])
Exemplo n.º 3
0
    def setUpClass(cls):
        test_ds = fake_particle_ds()
        data_sources = [test_ds.region([0.5] * 3, [0.4] * 3, [0.6] * 3),
                        test_ds.all_data()]
        particle_phases = []

        for source in data_sources:
            for x_field, y_field, z_fields in PHASE_FIELDS:
                particle_phases.append(ParticlePhasePlot(source,
                                                         x_field,
                                                         y_field,
                                                         z_fields,
                                                         x_bins=16,
                                                         y_bins=16))

                particle_phases.append(ParticlePhasePlot(source,
                                                         x_field,
                                                         y_field,
                                                         z_fields,
                                                         x_bins=16,
                                                         y_bins=16,
                                                         deposition='cic'))

                pp = create_profile(source, [x_field, y_field], z_fields,
                                    weight_field='particle_ones',
                                    n_bins=[16, 16])

                particle_phases.append(ParticlePhasePlot.from_profile(pp))

        cls.particle_phases = particle_phases
        cls.ds = test_ds
Exemplo n.º 4
0
    def test_particle_phase_plot(self):
        test_ds = fake_particle_ds()
        data_sources = [
            test_ds.region([0.5] * 3, [0.4] * 3, [0.6] * 3),
            test_ds.all_data(),
        ]
        particle_phases = []

        for source in data_sources:
            for x_field, y_field, z_fields in PHASE_FIELDS:
                particle_phases.append(
                    ParticlePhasePlot(
                        source,
                        x_field,
                        y_field,
                        z_fields,
                        x_bins=16,
                        y_bins=16,
                    ))

                particle_phases.append(
                    ParticlePhasePlot(
                        source,
                        x_field,
                        y_field,
                        z_fields,
                        x_bins=16,
                        y_bins=16,
                        deposition="cic",
                    ))

                pp = create_profile(
                    source,
                    [x_field, y_field],
                    z_fields,
                    weight_field=("all", "particle_ones"),
                    n_bins=[16, 16],
                )

                particle_phases.append(ParticlePhasePlot.from_profile(pp))
        particle_phases[0]._repr_html_()

        with mock.patch(
                "yt.visualization._mpl_imports.FigureCanvasAgg.print_figure"
        ), mock.patch(
                "yt.visualization._mpl_imports.FigureCanvasPdf.print_figure"
        ), mock.patch(
                "yt.visualization._mpl_imports.FigureCanvasPS.print_figure"):
            for p in particle_phases:
                for fname in TEST_FLNMS:
                    p.save(fname)