Skip to content

Commit

Permalink
docs updates, widget thread fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Aug 18, 2023
1 parent 546bc48 commit cfc5818
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .napari/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ yt-napari provides plugins to help load data from [yt](https://yt-project.org/)

![](https://raw.githubusercontent.com/data-exp-lab/yt-napari/main/docs/_static/nb_iso_galaxy_T_rho.png)

See the [full documentation](https://yt-napari.readthedocs.io) for more details.
See the [full documentation](https://yt-napari.readthedocs.io/en/stable/) for more details.
5 changes: 4 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## v0.2.0

This release includes some non-backwards compatible changes to the schema. Old
json files will need to be updated to use with yt-napari >= v0.2.0

### New Features
* new widget: yt-napari timeseries slicer
* timeseries loading: a new widget, yt-napari timeseries slicer, is available from the napari gui and json files can also specify timeseries selections. Additionally, there is a new `yt_napari.timeseries` module for jupyter notebook interaction.

### Breaking changes

Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ nbscreenshot(viewer)

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

Additionally, with `yt_napari`>= v0.2.0, you can use the `yt_napari.timeseries` module to help sample and load in selections from across datasets.

### loading a selection from a yt dataset interactively

`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.
Expand All @@ -110,23 +112,30 @@ To use the yt Reader plugin, click on `Plugins -> yt-napari: yt Reader`. From th

You can add multiple selections and load them all at once or adjust values and click "Load" again.

#### using the yt Time Series Reader plugin

To use the yt Time Series Reader plugin, click on `Plugins -> yt-napari: yt Time Series Reader`. Specify your file matching: use `file_pattern` to enter glob expressions or use `file_list` to enter a list of specific files.
Then add a slice or region to sample for each matched dataset file (note: be careful of memory here!):

![Loading timeseries selections from the napari viewer](./assets/images/readme_ex_004_gui_timeseries.gif)

#### using a json file and schema

`yt-napari` also provides the ability to load json that contain specifications for loading a file. Properly formatted files can be loaded from the napari GUI as you would load any image file (`File->Open`). The json file describes the selection process for a dataset as described by a json-schema. The following json file results in similar layers as the above examples:


```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": {"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"
}]
"datasets": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030",
"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
Binary file added assets/images/readme_ex_004_gui_timeseries.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 17 additions & 7 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ loading a json file from the napari gui
.. code-block:: json
{"$schema": "https://yt-napari.readthedocs.io/en/latest/_static/yt-napari_latest.json",
"data": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030",
"selections": {"regions": [{
"fields": [{"field_name": "Temperature", "field_type": "enzo", "take_log": true},
{"field_name": "Density", "field_type": "enzo", "take_log": true}],
"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]
"datasets": [{"filename": "IsolatedGalaxy/galaxy0030/galaxy0030",
"selections": {"regions": [{
"fields": [{"field_name": "Temperature", "field_type": "enzo", "take_log": true},
{"field_name": "Density", "field_type": "enzo", "take_log": true}],
"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]
}]}
}]
}
Expand Down Expand Up @@ -95,6 +95,16 @@ The use the yt Reader plugin, from a Napari viewer, select "Plugins -> yt-napari
The reader plugin does its best to align new selections of data with existing yt-napari image layers and should be able to properly align selections from different yt datasets (please submit a bug report if it fails!).


The yt-napari yt Time Series Reader:
####################################

This reader will apply a spatial selection to a set of files, similar to working with a yt `DataSeries` object. You specify
the spatial selections and a list of files or file pattern to match. Note that while the operation is in a non-blocking
thread, if your simulation data is large it may take a few minutes to load in your selections. Also note that 3D region
selections can easily exceed available memory if you're not careful... for improving load times and working with
bigger-than-memory arrays, you can instead use the jupyter notebook interface for napari with the `yt_napari.timeseries`
module of helper functions to distribute the timestep selections using dask. See the example notebooks for usage.

.. _configfile:

Configuring yt-napari
Expand Down
4 changes: 2 additions & 2 deletions src/yt_napari/_widget_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ def process_timeseries_layers(self, layer_list):


@thread_worker(progress=True)
def time_series_load(model, worker_id):
def time_series_load(model):
_, layer_list = _model_ingestor._process_validated_model(model)
return layer_list, worker_id
return layer_list

Check warning on line 289 in src/yt_napari/_widget_reader.py

View check run for this annotation

Codecov / codecov/patch

src/yt_napari/_widget_reader.py#L288-L289

Added lines #L288 - L289 were not covered by tests

0 comments on commit cfc5818

Please sign in to comment.