Skip to content

Commit

Permalink
Merge pull request #4939 from nastasha-w/sph_proj_backend
Browse files Browse the repository at this point in the history
Sph projections, slices, gridding: backend and off-axis
  • Loading branch information
chummels authored Sep 16, 2024
2 parents 77714f7 + ac30d15 commit cadddb6
Show file tree
Hide file tree
Showing 20 changed files with 1,966 additions and 208 deletions.
12 changes: 8 additions & 4 deletions doc/source/analyzing/generating_processed_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ the transformation of a variable mesh of points consisting of positions and
sizes into a fixed-size array that appears like an image. This process is that
of pixelization, which yt handles transparently internally. You can access
this functionality by constructing a
:class:`~yt.visualization.fixed_resolution.FixedResolutionBuffer` and supplying
:class:`~yt.visualization.fixed_resolution.FixedResolutionBuffer`
and supplying
to it your :class:`~yt.data_objects.data_containers.YTSelectionContainer2D`
object, as well as some information about how you want the final image to look.
You can specify both the bounds of the image (in the appropriate x-y plane) and
the resolution of the output image. You can then have yt pixelize any field
you like.

.. note:: In previous versions of yt, there was a special class of
FixedResolutionBuffer for off-axis slices. This is no longer
necessary.
FixedResolutionBuffer for off-axis slices. This is still used
for off-axis SPH data projections: OffAxisFixedResolutionBuffer.

To create :class:`~yt.data_objects.data_containers.YTSelectionContainer2D` objects, you can
access them as described in :ref:`data-objects`, specifically the section
Expand Down Expand Up @@ -99,7 +100,10 @@ this, see :ref:`saving-grid-data-containers`.
In the FITS case, there is an option for setting the ``units`` of the coordinate system in
the file. If you want to overwrite a file with the same name, set ``clobber=True``.

The :class:`~yt.visualization.fixed_resolution.FixedResolutionBuffer` can even be exported
The :class:`~yt.visualization.fixed_resolution.FixedResolutionBuffer`
(and its
:class:`~yt.visualization.fixed_resolution.OffAxisProjectionFixedResolutionBuffer`
subclass) can even be exported
as a 2D dataset itself, which may be operated on in the same way as any other dataset in yt:

.. code-block:: python
Expand Down
6 changes: 4 additions & 2 deletions doc/source/quickstart/4)_Data_Objects_and_Time_Series.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@
"\n",
"There are two different types of covering grids: unsmoothed and smoothed. Smoothed grids will be filled through a cascading interpolation process; they will be filled at level 0, interpolated to level 1, filled at level 1, interpolated to level 2, filled at level 2, etc. This will help to reduce edge effects. Unsmoothed covering grids will not be interpolated, but rather values will be duplicated multiple times.\n",
"\n",
"For SPH datasets, the covering grid gives the SPH-interpolated value of a field at each grid cell center. This is done for unsmoothed grids; smoothed grids are not available for SPH data.\n",
"\n",
"Here we create an unsmoothed covering grid at level 2, with the left edge at `[0.0, 0.0, 0.0]` and with dimensions equal to those that would cover the entire domain at level 2. We can then ask for the Density field, which will be a 3D array."
]
},
Expand Down Expand Up @@ -385,13 +387,13 @@
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3.9.5 64-bit ('yt-dev': pyenv)",
"metadata": {
"interpreter": {
"hash": "14363bd97bed451d1329fb3e06aa057a9e955a9421c5343dd7530f5497723a41"
}
}
},
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand Down
10 changes: 4 additions & 6 deletions doc/source/visualizing/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ argument. Optionally, a ``north_vector`` can be specified to fix the orientation
of the image plane.

.. note:: Not every data types have support for off-axis slices yet.
Currently, this operation is supported for grid based data with cartesian geometry.
In some cases (like SPH data) an off-axis projection over a thin region might be used instead.
Currently, this operation is supported for grid based and SPH data with cartesian geometry.
In some cases an off-axis projection over a thin region might be used instead.

.. _projection-plots:

Expand Down Expand Up @@ -433,6 +433,8 @@ by applying the
In this use case, the volume renderer casts a set of plane parallel rays, one
for each pixel in the image. The data values along each ray are summed,
creating the final image buffer.
For SPH datsets, the coordinates are instead simply rotated before the axis-aligned
projection function is applied.

.. _off-axis-projection-function:

Expand Down Expand Up @@ -652,10 +654,6 @@ simply pass ``all`` as the first argument of the field tuple:
Additional Notes for Plotting Particle Data
-------------------------------------------

An important caveat when visualizing particle data is that off-axis slice plotting is
not available for any particle data. However, axis-aligned slice plots (as described in
:ref:`slice-plots`) will work.

Since version 4.2.0, off-axis projections ares supported for non-SPH particle data.
Previous to that, this operation was only supported for SPH particles. Two historical
workaround methods were available for plotting non-SPH particles with off-axis
Expand Down
2 changes: 2 additions & 0 deletions nose_ignores.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@
--ignore-file=test_set_log_level\.py
--ignore-file=test_field_parsing\.py
--ignore-file=test_disks\.py
--ignore-file=test_offaxisprojection_pytestonly\.py
--ignore-file=test_sph_pixelization_pytestonly\.py
12 changes: 7 additions & 5 deletions tests/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ answer_tests:
- yt/frontends/amrvac/tests/test_outputs.py:test_riemann_cartesian_175D
- yt/frontends/amrvac/tests/test_outputs.py:test_rmi_cartesian_dust_2D

local_arepo_011: # PR 4419
local_arepo_013: # PR 4939
- yt/frontends/arepo/tests/test_outputs.py:test_arepo_bullet
- yt/frontends/arepo/tests/test_outputs.py:test_arepo_tng59
- yt/frontends/arepo/tests/test_outputs.py:test_arepo_cr
Expand Down Expand Up @@ -92,7 +92,7 @@ answer_tests:
- yt/frontends/flash/tests/test_outputs.py:test_wind_tunnel
- yt/frontends/flash/tests/test_outputs.py:test_fid_1to3_b1

local_gadget_009: # PR 3258
local_gadget_010: # PR 4939
- yt/frontends/gadget/tests/test_outputs.py:test_iso_collapse
- yt/frontends/gadget/tests/test_outputs.py:test_pid_uniqueness
- yt/frontends/gadget/tests/test_outputs.py:test_bigendian_field_access
Expand All @@ -108,7 +108,7 @@ answer_tests:
local_gdf_002:
- yt/frontends/gdf/tests/test_outputs_nose.py:test_sedov_tunnel

local_gizmo_008: # PR 2909
local_gizmo_009: # PR 4939
- yt/frontends/gizmo/tests/test_outputs.py:test_gizmo_64

local_halos_012: # PR 3325
Expand All @@ -118,7 +118,7 @@ answer_tests:
- yt/frontends/gadget_fof/tests/test_outputs.py:test_fields_g5
- yt/frontends/gadget_fof/tests/test_outputs.py:test_fields_g42

local_owls_008: # PR 2909
local_owls_009: # PR 4939
- yt/frontends/owls/tests/test_outputs.py:test_snapshot_033
- yt/frontends/owls/tests/test_outputs.py:test_OWLS_particlefilter

Expand All @@ -130,7 +130,7 @@ answer_tests:
- yt/visualization/tests/test_particle_plot.py:test_particle_phase_answers
- yt/visualization/tests/test_callbacks.py:test_axis_manipulations

local_tipsy_009: # PR 2909
local_tipsy_010: # PR 4939
- yt/frontends/tipsy/tests/test_outputs.py:test_pkdgrav
- yt/frontends/tipsy/tests/test_outputs.py:test_gasoline_dmonly
- yt/frontends/tipsy/tests/test_outputs.py:test_tipsy_galaxy
Expand Down Expand Up @@ -221,5 +221,7 @@ other_tests:
- "--exclude-test=yt.frontends.gdf.tests.test_outputs.TestGDF"
- "--exclude-test=yt.frontends.adaptahop.tests.test_outputs"
- "--exclude-test=yt.frontends.stream.tests.test_stream_particles.test_stream_non_cartesian_particles"
- "--ignore-file=test_offaxisprojection_pytestonly\\.py"
- "--ignore-file=test_sph_pixelization_pytestonly\\.py"
cookbook:
- 'doc/source/cookbook/tests/test_cookbook.py'
9 changes: 7 additions & 2 deletions yt/data_objects/construction_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ class YTCoveringGrid(YTSelectionContainer3D):
level : int
The resolution level data to which data will be gridded. Level
0 is the root grid dx for that dataset.
(The grid resolution will be simulation size / 2**level along
each grid axis.)
left_edge : array_like
The left edge of the region to be extracted. Specify units by supplying
a YTArray, otherwise code length units are assumed.
Expand Down Expand Up @@ -1004,14 +1006,15 @@ def _fill_sph_particles(self, fields):

smoothing_style = getattr(self.ds, "sph_smoothing_style", "scatter")
normalize = getattr(self.ds, "use_sph_normalization", True)
kernel_name = getattr(self.ds, "kernel_name", "cubic")

bounds, size = self._get_grid_bounds_size()

period = self.ds.coordinates.period.copy()
if hasattr(period, "in_units"):
period = period.in_units("code_length").d
# TODO maybe there is a better way of handling this
is_periodic = int(any(self.ds.periodicity))
# check periodicity per dimension
is_periodic = self.ds.periodicity

if smoothing_style == "scatter":
for field in fields:
Expand Down Expand Up @@ -1045,6 +1048,7 @@ def _fill_sph_particles(self, fields):
pbar=pbar,
check_period=is_periodic,
period=period,
kernel_name=kernel_name,
)
if normalize:
pixelize_sph_kernel_arbitrary_grid(
Expand All @@ -1060,6 +1064,7 @@ def _fill_sph_particles(self, fields):
pbar=pbar,
check_period=is_periodic,
period=period,
kernel_name=kernel_name,
)

if normalize:
Expand Down
Loading

0 comments on commit cadddb6

Please sign in to comment.