How to use the plonk.Dump function in plonk

To help you get started, we’ve selected a few plonk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmentipl / plonk / tests / test_dump.py View on Github external
def test_read_header(self):
        """Testing reading Phantom HDF5 dump header."""

        dump = plonk.Dump(TEST_FILE)

        for para in dump.header:
            if isinstance(dump.header[para], np.ndarray):
                np.testing.assert_allclose(dump.header[para], header[para])
            else:
                self.assertEqual(dump.header[para], header[para])

        dump._close_file()
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_read_dump(self):
        """Testing reading Phantom HDF5 dumps."""

        # Read from pathlib.Path
        dump = plonk.Dump(TEST_FILE)
        dump._close_file()

        # Read from str
        dump = plonk.Dump(str(TEST_FILE))
        dump._close_file()

        # Not exists
        self.assertRaises(FileNotFoundError, plonk.Dump, 'does_not_exist.h5')
        dump._close_file()
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_load_arrays_into_memory(self):

        dump = plonk.Dump(TEST_FILE)
        dump._load_arrays('sinks')

        dump._close_file()
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_read_dump(self):
        """Testing reading Phantom HDF5 dumps."""

        # Read from pathlib.Path
        dump = plonk.Dump(TEST_FILE)
        dump._close_file()

        # Read from str
        dump = plonk.Dump(str(TEST_FILE))
        dump._close_file()

        # Not exists
        self.assertRaises(FileNotFoundError, plonk.Dump, 'does_not_exist.h5')
        dump._close_file()
github dmentipl / plonk / tests / test_multiplot.py View on Github external
def test_initialization(self):

        dump = plonk.Dump(TEST_FILE)
        options = list()
        options.append({'render': 'density'})
        options.append({'render': 'divv'})

        plonk.visualization.MultiPlot(dump, options)

        dumps = [dump, dump]
        options = {'render': 'density', 'extent': [-100, 100, -100, 100]}

        plonk.visualization.MultiPlot(dumps, options)
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_extra_quantity(self):

        dump = plonk.Dump(TEST_FILE)

        self.assertAlmostEqual(
            dump.extra_quantity('L', sph_type='particles')[0].mean(),
            6.875907667109459e-05,
        )

        self.assertAlmostEqual(
            dump.extra_quantity('p')[0].mean(), -3.029025112420847e-22
        )

        self.assertAlmostEqual(
            dump.extra_quantity('R', sph_type='sinks')[0].mean(), 3.180317954809203e-15
        )

        dump._close_file()
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_density(self):

        dump = plonk.Dump(TEST_FILE)

        self.assertAlmostEqual(dump.density.mean(), 4.739748038277296e-08)

        dump._close_file()
github dmentipl / plonk / tests / test_dump.py View on Github external
def test_read_particle_arrays(self):
        """Testing reading Phantom HDF5 dump particle arrays."""

        dump = plonk.Dump(TEST_FILE)

        self.assertEqual(set(dump.particles.arrays), array_keys)

        for key, val in dump.particles.arrays.items():
            np.testing.assert_allclose(val[()].mean(), mean_array_values[key])

        dump._close_file()
github dmentipl / plonk / examples / visualize_disc.py View on Github external
import pathlib

import matplotlib.pyplot as plt

import plonk

# ---------------------------------------------------------------------------- #

# --- File

DATA_FILE = pathlib.Path('~/runs/directory/file_12345')

# --- Read dump file

dump = plonk.Dump(DATA_FILE)

position = dump.particles.arrays['xyz'][:]
smoothing_length = dump.particles.arrays['h'][:]
density = dump.density
particle_mass = dump.mass

x_position = position[:, 0]
y_position = position[:, 1]

# --- Options

scalar_options = {'norm': 'linear', 'cmap': 'gist_heat'}
interpolation_options = {'number_of_pixels': (512, 512)}
extent = (-100.0, 100.0, -100.0, 100.0)

# --- Plot image