Package: yt-napari
yt-napariAnapariplugin for loading data fromyt.This readme provides a brief overview including:InstallationQuick StartContributingFull documentation is available atyt-napari.readthedocs.io.Installation1. (optional) installytandnapariIf you skip this step, the installation in the following section will only install the minimal package requirements forytornapari, in which case you will likely need to manually install some packages. So if you are new to either package, or if you are installing in a clean environment, it may be simpler to  install these packages first.Fornapari,pip install napari[all]will installnapariwith the defaultQtbackend (seeherefor how to choose betweenPyQt5orPySide2).Foryt, you will needyt>=4.0.1and any of the optional dependencies for your particular workflow. If you know that you'll need more than the baseytinstall, you can install the full suite of dependent packages withpip install yt[full]See theytdocumentationfor more information. If you're not sure which packages you'll need but don't want the full yt installation, you can proceed to the next step and then install any packages as needed (you will receive error messages when a required package is missing).2. installyt-napariYou can install theyt-napariplugin with:pip install yt-napariIf you are missing eitherytornapari(or they need to be updated), the above installation will fetch and run a minimal installation for both.To install the latest development version of the plugin instead, use:pip install git+https://github.com/data-exp-lab/yt-napari.gitNote that if you are working off the development version, be sure to use the latest documentation
for reference:https://yt-napari.readthedocs.io/en/latest/Quick StartAfterinstallation, there are three modes of usingyt-napari:jupyter notebook interaction (jump down)loading a json file from the napari gui (jump down)napari widget plugins (jump down)jupyter notebook interactionyt-napariprovides a helper class,yt_napari.viewer.Scenethat assists in properly aligning new yt selections in the napari viewer when working in a Jupyter notebook.importnapariimportytfromyt_napari.viewerimportScenefromnapari.utilsimportnbscreenshotviewer=napari.Viewer()ds=yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")yt_scene=Scene()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_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)yt_scene.add_to_vieweraccepts any of the keyword arguments allowed byviewer.add_image. See the full documentation (yt-napari.readthedocs.io) for more examples, including additional helper methods for linking layer appearance.Additionally, withyt_napari>= v0.2.0, you can use theyt_napari.timeseriesmodule to help sample and load in selections from across datasets.loading a selection from a yt dataset interactivelyyt-napariprovides 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 pluginTo use the yt Reader plugin, click onPlugins -> yt-napari: yt Reader. From there, add a region or slice selector then specify a field type and field and bounds to sample  between and then simply click "Load":You can add multiple selections and load them all at once or adjust values and click "Load" again.using the yt Time Series Reader pluginTo use the yt Time Series Reader plugin, click onPlugins -> yt-napari: yt Time Series Reader. Specify your file matching: usefile_patternto enter glob expressions or usefile_listto 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!):using a json file and schemayt-naparialso 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:{"$schema":"https://raw.githubusercontent.com/data-exp-lab/yt-napari/main/src/yt_napari/schemas/yt-napari_0.0.1.json","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"}]}To help in filling out a json file, it is recommended that you use an editor capable of parsing a json schema and displaying hints. For example, in vscode, you will see field suggestions after specifying theyt-naparischema:See the full documentation atyt-napari.readthedocs.iofor a complete specification.ContributingContributions are very welcome! Development follows a fork and pull request workflow. To get started, you'll need a development installation and a testing environment.development environmentTo start developing, fork the repository and clone your fork to get a local copy. You can then install in development mode withpip install -e .tests and style checksBoth bug fixes and new features will need to pass the existing test suite and style checks. While both will be run automatically when you submit a pull request, it is helpful to run the test suites locally and run style checks throughout development. For testing, you can usetoxto test different python versions on your platform.pip install toxAnd then from the top level of theyt-naparidirectory, runtoxTox will then run a series of tests in isolated environments. In addition to checking the terminal output for test results, the tox run will generate a test coverage report: acoverage.xmlfile and ahtmlcovfolder -- to view the results, openhtmlcov/index.htmlin a browser.If you prefer a lighter weight test, you can also usepytestdirectly and rely on the Github CI to test different python versions and systems. To do so, first installpytestand some related plugins:pip install pytest pytest-qt pytest-covNow, to run the tests:pytest -v --cov=yt_napari --cov-report=htmlIn addition to telling you whether or not the tests pass, the above command will write out a code coverage report to thehtmlcovdirectory. You can open uphtmlcov/index.htmlin a browser and check out the lines of code that were missed by existing tests.For style checks, you can usepre-committo run checks as you develop. To set uppre-commit:pip install pre-commit
pre-commit installafter which, every time you rungit commit, some automatic style adjustments and checks will run. The same style checks will run when you submit a pull request, but it's often easier to catch them early.After submitting a pull request, thepre-commit.cibot will run the style checks. If style checks fail, you can have the bot attempt to auto-fix the failures by adding the following in a comment on it's own:pre-commit.ci autofixThe bot will then commit changes to your pull request after which you will want to rungit pulllocally to update your local version of the branch before making further changes to the branch.building documentation locallyDocumentation can be built usingsphinxin two steps. First, update the api mapping withsphinx-apidoc -f -o docs/source src/yt_napari/This will update therstfiles indocs/source/with the latest docstrings inyt_napari. Next, build the html documentation withmake htmlupdating the pydantic models and schemaThe schema versioning follows amajor.minor.microversioning pattern that matches the yt-napari versioning. Each yt-napari release should have an accompanying updated schema file, even if the  contents of the schema file have not changed. On-disk schema are stored insrc/yt_napari/schemas/, with copies in the documentation atdocs/_static.There are a number of utilities to help automate the management of schema inrepo_utilities/. The easiest way to use these utitities is withtaskipyfrom the command line. To list available scripts:task --listBefore a release, runtask validate_release vX.X.XwherevX.X.Xis the version of the upcoming release. This script will run through some checks that ensure:the on-disk schema matches the schema generated by the pydantic modelthe schema files in the documentation match the schema files in the packageIf any of the checks fail, you will be advised to update the schema usingupdate_schema_docs. If you
run without providing a version:task update_schema_docsIt will simply copy over the existing on-disk schema files to the documentation. If you run with a version:task update_schema_docs -v vX.X.XIt will write a schema file for the current pydantic model, overwriting any on-disk schema files for
the provided version.LicenseDistributed under the terms of theBSD-3license,
"yt-napari" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.FundingThe yt-napari plugin project was funded with support from the Chan Zuckerberg Initiative through the napari Plugin Accelerator Grants project,Enabling Access To Multi-resolution Data.Thisnapariplugin was generated withCookiecutterusing@napari'scookiecutter-napari-plugintemplate.