Skip to content

Commit

Permalink
updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Jul 7, 2023
1 parent a0ba7c5 commit f239d7f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ To load a different field or section, adjust the values and click "Load" again.
```json
{"$schema": "https://raw.githubusercontent.com/data-exp-lab/yt-napari/main/src/yt_napari/schemas/yt-napari_0.0.1.json",
"data": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030",
"selections": [{
"selections": {"regions": [{
"fields": [{"field_name": "Temperature", "field_type": "enzo", "take_log": true},
{"field_name": "Density", "field_type": "enzo", "take_log": true}],
"left_edge": [460.0, 460.0, 460.0],
"right_edge": [560.0, 560.0, 560.0],
"resolution": [600, 600, 600]
}],
}]},
"edge_units": "kpc"
}]
}
Expand Down
37 changes: 18 additions & 19 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ jupyter notebook interaction
right_edge = ds.domain_center + ds.arr([40, 40, 40], 'kpc')
res = (600, 600, 600)
yt_scene.add_to_viewer(viewer,
ds,
("enzo", "Temperature"),
left_edge = left_edge,
right_edge = right_edge,
resolution = res)
yt_scene.add_region(viewer,
ds,
("enzo", "Temperature"),
left_edge = left_edge,
right_edge = right_edge,
resolution = res)
yt_scene.add_to_viewer(viewer,
ds,
("enzo", "Density"),
left_edge = left_edge,
right_edge = right_edge,
resolution = res)
yt_scene.add_region(viewer,
ds,
("enzo", "Density"),
left_edge = left_edge,
right_edge = right_edge,
resolution = res)
:code:`yt_scene.add_to_viewer` accepts any of the keyword arguments allowed by :code:`viewer.add_image`.
:code:`yt_scene.add_region` accepts any of the keyword arguments allowed by :code:`viewer.add_image`.

See :meth:`yt_napari.viewer.Scene` for all available methods and the :doc:`example notebooks <notebooks>` for further examples.

Expand All @@ -60,16 +60,15 @@ loading a json file from the napari gui

.. code-block:: json
{"$schema": "https://raw.githubusercontent.com/data-exp-lab/yt-napari/main/src/yt_napari/schemas/yt-napari_0.0.1.json",
{"$schema": "https://yt-napari.readthedocs.io/en/latest/_static/yt-napari_latest.json",
"data": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030",
"selections": [{
"selections": {"regions": [{
"fields": [{"field_name": "Temperature", "field_type": "enzo", "take_log": true},
{"field_name": "Density", "field_type": "enzo", "take_log": true}],
"left_edge": [460.0, 460.0, 460.0],
"right_edge": [560.0, 560.0, 560.0],
"left_edge": {"value": [460.0, 460.0, 460.0], "unit": "kpc"},
"right_edge": {"value": [560.0, 560.0, 560.0], "unit": "kpc"},
"resolution": [600, 600, 600]
}],
"edge_units": "kpc"
}]}
}]
}
Expand Down
47 changes: 46 additions & 1 deletion src/yt_napari/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def add_region(
**kwargs,
):
"""
create a uniform sampling of ds and add it to the napari viewer
uniformly sample a region from a yt dataset and add it to a viewer
Parameters
----------
Expand Down Expand Up @@ -242,6 +242,51 @@ def add_slice(
link_to: Optional[Union[str, Layer]] = None,
**kwargs,
):
"""
sample an orthogonal slice from a yt dataset and add it to a viewer
Parameters
----------
viewer: napari.Viewer
the active napari viewer
ds
the yt dataset to sample
normal: str, int
the normal axis of the slice, either an axis name or number
field: Tuple[str, str]
the field tuple to sample e.g., ('enzo', 'Density')
center: unyt_array
the center of the slice (3D)
width: unyt_quantity
the width of the slice
height: unyt_quantity
the height of the slice
resolution: Tuple[int, int]
the sampling resolution in each dimension, e.g., (400, 400)
take_log : Optional[bool]
if True, will take the log of the extracted data. Defaults to the
default behavior for the field set by ds.
periodic: Optional[bool]
use periodic bounds for the slice, default False
colormap : Optional[str]
the color map to use, default is "viridis"
link_to : Optional[Union[str, Layer]]
specify a layer to which the new layer should link
**kwargs :
any keyword argument accepted by Viewer.add_image()
Examples
--------
>>> import napari
>>> import yt
>>> from yt_napari.viewer import Scene
>>> viewer = napari.Viewer()
>>> ds = yt.load_sample("IsolatedGalaxy")
>>> yt_scene = Scene()
>>> yt_scene.add_slice(viewer, ds, "x", ("enzo", "Temperature"))
"""

if take_log is None:
take_log = ds._get_field_info(field).take_log
Expand Down

0 comments on commit f239d7f

Please sign in to comment.