SWIFTSIM / swiftsimio

Python library for reading SWIFT data. Uses unyt and h5py.
GNU Lesser General Public License v3.0
15 stars 12 forks source link

Smoothing length calculation for non-gas particles returns `unyt_array` #143

Closed kyleaoman closed 1 year ago

kyleaoman commented 1 year ago

Some recent changes to the visualisation module check that the smoothing lengths and coordinates have compatible attributes (e.g. both comoving, or both physical). However, visualisation.smoothing_length_generation.generate_smoothing_lengths returns a unyt_array, so these checks always fail with an AttributeError and the smoothing lengths are unusable.

Putting together a PR for this, it includes a test that currently fails:

@requires("cosmological_volume.hdf5")
def test_nongas_smoothing_lengths(filename):
    """
    Test that the visualisation tools to calculate smoothing lengths give usable results.
    """

    data = load(filename)
    data.dark_matter.smoothing_length = generate_smoothing_lengths(
        data.dark_matter.coordinates, data.metadata.boxsize, kernel_gamma=1.8
    )
    project_pixel_grid(
        data.dark_matter,
        boxsize=data.metadata.boxsize,
        resolution=256,
        project="masses",
    )

    # if project_pixel_grid runs without error the smoothing lengths seem usable
    return