Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slice operator #53

Merged
merged 23 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ left_edge = ds.domain_center - ds.arr([40, 40, 40], 'kpc')
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_to_viewer(viewer,
ds,
("enzo", "Density"),
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_region(viewer,
ds,
("enzo", "Density"),
left_edge=left_edge,
right_edge=right_edge,
resolution=res)

nbscreenshot(viewer)
```

![Loading a subset of a yt dataset in napari from a Jupyter notebook](./assets/images/readme_ex_001.png)

`yt_scene.add_to_viewer` accepts any of the keyword arguments allowed by `viewer.add_image`. See the full documentation (https://yt-napari.readthedocs.io/) for more examples, including additional helper methods for linking layer appearance.
`yt_scene.add_to_viewer` accepts any of the keyword arguments allowed by `viewer.add_image`. See the full documentation (https://yt-napari.readthedocs.io/en/stable/) for more examples, including additional helper methods for linking layer appearance.

### loading a selection from a yt dataset interactively

`yt-napari` provides a two ways to sample a yt dataset and load in an image layer into a Napari viewer: the yt Reader plugin and json file specification.
`yt-napari` provides two ways to sample a yt dataset and load in an image layer into a Napari viewer: the yt Reader plugin and json file specification.

#### using the yt Reader plugin

Expand All @@ -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
96 changes: 48 additions & 48 deletions docs/examples/ytnapari_scene_01_intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"name": "stderr",
"output_type": "stream",
"text": [
"yt : [INFO ] 2022-03-08 19:25:04,825 Parameters: current_time = 0.0060000200028298\n",
"yt : [INFO ] 2022-03-08 19:25:04,826 Parameters: domain_dimensions = [32 32 32]\n",
"yt : [INFO ] 2022-03-08 19:25:04,828 Parameters: domain_left_edge = [0. 0. 0.]\n",
"yt : [INFO ] 2022-03-08 19:25:04,829 Parameters: domain_right_edge = [1. 1. 1.]\n",
"yt : [INFO ] 2022-03-08 19:25:04,830 Parameters: cosmological_simulation = 0\n"
"yt : [INFO ] 2023-07-07 12:10:53,595 Parameters: current_time = 0.0060000200028298\n",
"yt : [INFO ] 2023-07-07 12:10:53,596 Parameters: domain_dimensions = [32 32 32]\n",
"yt : [INFO ] 2023-07-07 12:10:53,597 Parameters: domain_left_edge = [0. 0. 0.]\n",
"yt : [INFO ] 2023-07-07 12:10:53,604 Parameters: domain_right_edge = [1. 1. 1.]\n",
"yt : [INFO ] 2023-07-07 12:10:53,605 Parameters: cosmological_simulation = 0\n"
]
}
],
Expand Down Expand Up @@ -77,7 +77,7 @@
"id": "7759684f-8854-4fad-adfb-8004ebf3d01b",
"metadata": {},
"source": [
"The new `yt_scene` object will have a method, `add_to_viewer` that will uniformly sample the dataset and add the new sample to the viewer:"
"The new `yt_scene` object will have a method, `add_region` that will uniformly sample the dataset within a rectalinear region and add the new sample to the viewer:"
]
},
{
Expand All @@ -90,8 +90,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Parsing Hierarchy : 100%|███████████████████| 173/173 [00:00<00:00, 4132.70it/s]\n",
"yt : [INFO ] 2022-03-08 19:25:04,966 Gathering a field list (this may take a moment.)\n"
"Parsing Hierarchy : 100%|██████████████████████████████████████████████████| 173/173 [00:00<00:00, 9528.50it/s]\n",
"yt : [INFO ] 2023-07-07 12:11:31,861 Gathering a field list (this may take a moment.)\n"
]
}
],
Expand All @@ -100,19 +100,19 @@
"right_edge = ds.domain_center + ds.arr([40, 40, 40], 'kpc')\n",
"res = (600, 600, 600)\n",
"\n",
"yt_scene.add_to_viewer(viewer,\n",
" ds,\n",
" (\"enzo\", \"Temperature\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution= res)\n",
"yt_scene.add_region(viewer,\n",
" ds,\n",
" (\"enzo\", \"Temperature\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution= res)\n",
"\n",
"yt_scene.add_to_viewer(viewer,\n",
" ds,\n",
" (\"enzo\", \"Density\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution = res)"
"yt_scene.add_region(viewer,\n",
" ds,\n",
" (\"enzo\", \"Density\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution = res)"
]
},
{
Expand Down Expand Up @@ -151,19 +151,19 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "83009ffe-7675-4431-bf8e-5c13c4fc7d29",
"metadata": {},
"outputs": [],
"source": [
"left_edge = ds.domain_center - ds.arr([20, 20, 20], 'kpc')\n",
"right_edge = ds.domain_center + ds.arr([10, 10, 10], 'kpc')\n",
"yt_scene.add_to_viewer(viewer,\n",
" ds,\n",
" (\"enzo\", \"TotalEnergy\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution=(200, 200, 200))"
"yt_scene.add_region(viewer,\n",
" ds,\n",
" (\"enzo\", \"TotalEnergy\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge,\n",
" resolution=(200, 200, 200))"
]
},
{
Expand Down Expand Up @@ -202,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 7,
"id": "c3302d60-eec4-484c-a1fc-9d534351720b",
"metadata": {},
"outputs": [],
Expand All @@ -212,36 +212,36 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 8,
"id": "c584f4ab-c6c8-4d8d-93b5-8799cd14f8a8",
"metadata": {},
"outputs": [],
"source": [
"left_edge = ds.domain_center - ds.arr([10, 10, 10], 'kpc')\n",
"right_edge = ds.domain_center + ds.arr([10, 10, 10], 'kpc')\n",
"yt_scene.add_to_viewer(viewer,\n",
" ds,\n",
" (\"enzo\", \"Density\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge, \n",
" resolution=(600, 600, 600),\n",
" colormap=\"magma\",\n",
" contrast_limits=(3.4, 6.4))\n",
"yt_scene.add_region(viewer,\n",
" ds,\n",
" (\"enzo\", \"Density\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge, \n",
" resolution=(600, 600, 600),\n",
" colormap=\"magma\",\n",
" contrast_limits=(3.4, 6.4))\n",
"\n",
"yt_scene.add_to_viewer(viewer,\n",
" ds,\n",
" (\"enzo\", \"Temperature\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge, \n",
" resolution=(300, 300, 300),\n",
" colormap=\"yellow\",\n",
" contrast_limits=(4., 6.),\n",
" opacity=0.6)"
"yt_scene.add_region(viewer,\n",
" ds,\n",
" (\"enzo\", \"Temperature\"),\n",
" left_edge = left_edge,\n",
" right_edge = right_edge, \n",
" resolution=(300, 300, 300),\n",
" colormap=\"yellow\",\n",
" contrast_limits=(4., 6.),\n",
" opacity=0.6)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 9,
"id": "b2f04137-fcfa-4504-a0f5-345ed3b6ec14",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -292,7 +292,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Loading