sdf-xarray 0.4.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/.github/workflows/build_publish.yml +7 -0
  2. sdf_xarray-0.6.0/.github/workflows/lint.yml +30 -0
  3. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/.github/workflows/tests.yml +7 -1
  4. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/.gitignore +48 -0
  5. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/CITATION.cff +4 -0
  6. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/CONTRIBUTING.md +18 -10
  7. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/PKG-INFO +6 -6
  8. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/README.md +2 -2
  9. sdf_xarray-0.6.0/docs/_static/jupyter_padding.css +3 -0
  10. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/animation.rst +65 -67
  11. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/conf.py +2 -3
  12. sdf_xarray-0.6.0/docs/getting_started.rst +75 -0
  13. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/key_functionality.rst +101 -25
  14. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/unit_conversion.rst +7 -8
  15. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/pyproject.toml +18 -11
  16. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/__init__.py +418 -36
  17. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/_version.py +3 -3
  18. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/dataset_accessor.py +53 -0
  19. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/download.py +3 -2
  20. sdf_xarray-0.6.0/src/sdf_xarray/plotting.py +567 -0
  21. sdf_xarray-0.4.0/tests/test_basic.py → sdf_xarray-0.6.0/tests/test_dataset.py +179 -143
  22. sdf_xarray-0.6.0/tests/test_datatree.py +376 -0
  23. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/tests/test_epoch_dataarray_accessor.py +29 -32
  24. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/tests/test_epoch_dataset_accessor.py +107 -7
  25. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/uv.lock +148 -706
  26. sdf_xarray-0.4.0/.github/workflows/black.yml +0 -40
  27. sdf_xarray-0.4.0/.github/workflows/lint.yml +0 -11
  28. sdf_xarray-0.4.0/docs/getting_started.rst +0 -86
  29. sdf_xarray-0.4.0/src/sdf_xarray/plotting.py +0 -293
  30. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/.gitmodules +0 -0
  31. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/.readthedocs.yaml +0 -0
  32. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/BEAM.png +0 -0
  33. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/CMakeLists.txt +0 -0
  34. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/LICENCE +0 -0
  35. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/PlasmaFAIR.svg +0 -0
  36. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/.gitignore +0 -0
  37. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/_static/force_render_dark_xarray_objects.css +0 -0
  38. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/_templates/custom-class-template.rst +0 -0
  39. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/_templates/custom-module-template.rst +0 -0
  40. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/api.rst +0 -0
  41. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/contributing.rst +0 -0
  42. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/index.rst +0 -0
  43. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/known_issues.rst +0 -0
  44. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/docs/make.bat +0 -0
  45. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/csdf.pxd +0 -0
  46. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/src/sdf_xarray/sdf_interface.pyx +0 -0
  47. {sdf_xarray-0.4.0 → sdf_xarray-0.6.0}/tests/test_cython.py +0 -0
@@ -19,6 +19,13 @@ jobs:
19
19
  fetch-depth: 0
20
20
  submodules: "recursive"
21
21
 
22
+ - name: Cache Zenodo datasets
23
+ uses: actions/cache@v4
24
+ with:
25
+ enableCrossOsArchive: true
26
+ path: ~/.cache/sdf_datasets
27
+ key: sdf-datasets-17991042
28
+
22
29
  - name: Setup uv
23
30
  id: setup-uv
24
31
  uses: astral-sh/setup-uv@v3
@@ -0,0 +1,30 @@
1
+ name: lint
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - '**.py'
7
+ pull_request:
8
+ paths:
9
+ - '**.py'
10
+
11
+ jobs:
12
+ lint:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+
19
+ # Providing 'args' prevents the action from running 'ruff check .'
20
+ # immediately after installing ruff.
21
+ - name: Install Ruff
22
+ uses: astral-sh/ruff-action@v3
23
+ with:
24
+ args: "--version"
25
+
26
+ - name: Check
27
+ run: ruff check --output-format=github src tests
28
+
29
+ - name: Format
30
+ run: ruff format --check --diff src tests
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
11
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v4
@@ -30,5 +30,11 @@ jobs:
30
30
  uv python install ${{ matrix.python-version }}
31
31
  uv sync --python ${{ matrix.python-version }} --frozen
32
32
 
33
+ - name: Cache Zenodo datasets
34
+ uses: actions/cache@v4
35
+ with:
36
+ path: ~/.cache/sdf_datasets
37
+ key: sdf-datasets-17991042
38
+
33
39
  - name: Test with pytest
34
40
  run: uv run pytest
@@ -1,4 +1,6 @@
1
1
  # -*- mode: gitignore; -*-
2
+ # https://github.com/github/gitignore/blob/main/Global/Emacs.gitignore
3
+ # --------------------------------------------------------------------
2
4
  *~
3
5
  \#*\#
4
6
  /.emacs.desktop
@@ -47,6 +49,9 @@ flycheck_*.el
47
49
  # network security
48
50
  /network-security.data
49
51
 
52
+ # https://github.com/github/gitignore/blob/main/Global/Linux.gitignore
53
+ # --------------------------------------------------------------------
54
+
50
55
  *~
51
56
 
52
57
  # temporary files which can be created if a process still has a handle open of a deleted file
@@ -60,6 +65,10 @@ flycheck_*.el
60
65
 
61
66
  # .nfs files are created when an open file is removed but is still being accessed
62
67
  .nfs*
68
+
69
+ # https://github.com/github/gitignore/blob/main/Python.gitignore
70
+ # --------------------------------------------------------------
71
+
63
72
  # Byte-compiled / optimized / DLL files
64
73
  __pycache__/
65
74
  *.py[cod]
@@ -222,6 +231,37 @@ cython_debug/
222
231
  # and can be added to the global gitignore or merged into this file. For a more nuclear
223
232
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
224
233
  #.idea/
234
+
235
+ # Abstra
236
+ # Abstra is an AI-powered process automation framework.
237
+ # Ignore directories containing user credentials, local state, and settings.
238
+ # Learn more at https://abstra.io/docs
239
+ .abstra/
240
+
241
+ # Visual Studio Code
242
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
243
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
244
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
245
+ # you could uncomment the following to ignore the entire vscode folder
246
+ .vscode/
247
+
248
+ # Ruff stuff:
249
+ .ruff_cache/
250
+
251
+ # PyPI configuration file
252
+ .pypirc
253
+
254
+ # Marimo
255
+ marimo/_static/
256
+ marimo/_lsp/
257
+ __marimo__/
258
+
259
+ # Streamlit
260
+ .streamlit/secrets.toml
261
+
262
+ # https://github.com/github/gitignore/blob/main/CMake.gitignore
263
+ # ------------------------------------------------------------
264
+
225
265
  CMakeLists.txt.user
226
266
  CMakeCache.txt
227
267
  CMakeFiles
@@ -233,6 +273,11 @@ install_manifest.txt
233
273
  compile_commands.json
234
274
  CTestTestfile.cmake
235
275
  _deps
276
+ CMakeUserPresets.json
277
+
278
+ # https://github.com/github/gitignore/blob/main/C.gitignore
279
+ # ---------------------------------------------------------
280
+
236
281
  # Prerequisites
237
282
  *.d
238
283
 
@@ -286,6 +331,9 @@ Module.symvers
286
331
  Mkfile.old
287
332
  dkms.conf
288
333
 
334
+ # sdf-xarray specific ignores
335
+ # ---------------------------
336
+
289
337
  # Generated version file
290
338
  src/sdf_xarray/_version.py
291
339
 
@@ -24,5 +24,9 @@ authors:
24
24
  given-names: Liam
25
25
  orcid: 'https://orcid.org/0000-0001-8604-6904'
26
26
  affiliation: University of York
27
+ - family-names: Shekhanov
28
+ given-names: Sviatoslav
29
+ orcid: 'https://orcid.org/0000-0002-2125-8962'
30
+ affiliation: University of York
27
31
  doi: 10.5281/zenodo.15351323
28
32
  date-released: '2024-07-25'
@@ -28,14 +28,8 @@ pip install .
28
28
 
29
29
  ### Style
30
30
 
31
- We follow [PEP 8](https://peps.python.org/pep-0008/) and use the
32
- following tools:
33
-
34
- - [ruff](https://github.com/astral-sh/ruff) for linting
35
- - [black](https://black.readthedocs.io/en/stable/) for formatting
36
- - [isort](https://pycqa.github.io/isort/) for sorting imports
37
-
38
- To run these tools locally, install the `lint` dependency group:
31
+ We use [Ruff](https://docs.astral.sh/ruff/) to maintain code quality and
32
+ formatting. This can be installed locally via the `lint` dependency group:
39
33
 
40
34
  ```bash
41
35
  pip install --group lint
@@ -53,6 +47,20 @@ Alternatively, `uv` users can do this in one step with `uv run`:
53
47
  uv run ruff check src tests
54
48
  ```
55
49
 
50
+ Many of the issues raised by Ruff can be fixed automatically:
51
+
52
+ ```bash
53
+ ruff check --fix src tests
54
+ ```
55
+
56
+ Ruff may also be used to format the code to a style similar to that enforced by
57
+ [Black](https://black.readthedocs.io/en/stable/), which (almost) matches the
58
+ [PEP-8 standard](https://peps.python.org/pep-0008/):
59
+
60
+ ```bash
61
+ ruff format src tests
62
+ ```
63
+
56
64
  ### Running and adding tests
57
65
 
58
66
  We use [pytest](https://docs.pytest.org/en/stable/) to run tests.
@@ -130,8 +138,8 @@ Then open http://localhost:8000 in your browser to view the documentation.
130
138
 
131
139
  All pull requests are automatically checked using GitHub Actions for:
132
140
 
133
- - Linting (`ruff`)
134
- - Formatting (`black` and `isort`)
141
+ - Linting and formatting (`ruff`)
135
142
  - Testing (`pytest`)
143
+ - Cross-platform building (`cibuildwheel`)
136
144
 
137
145
  These checks must pass before a pull request can be merged.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdf-xarray
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: Provides a backend for xarray to read SDF files as created by the EPOCH plasma PIC code.
5
- Author-Email: Peter Hill <peter.hill@york.ac.uk>, Joel Adams <joel.adams@york.ac.uk>, Shaun Doherty <shaun.doherty@york.ac.uk>, Chris Herdman <chris.herdman@york.ac.uk>, Liam Pattinson <liam.pattinson@york.ac.uk>
5
+ Author-Email: Peter Hill <peter.hill@york.ac.uk>, Joel Adams <joel.adams@york.ac.uk>, Shaun Doherty <shaun.doherty@york.ac.uk>, Chris Herdman <chris.herdman@york.ac.uk>, Liam Pattinson <liam.pattinson@york.ac.uk>, Sviatoslav Shekhanov <sviatoslav.shekhanov@york.ac.uk>
6
6
  License-Expression: BSD-3-Clause
7
7
  Classifier: Development Status :: 5 - Production/Stable
8
8
  Classifier: Intended Audience :: Science/Research
@@ -10,15 +10,15 @@ Classifier: Topic :: Scientific/Engineering
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
16
  Classifier: Programming Language :: Python :: 3.14
18
- Requires-Python: <3.15,>=3.10
17
+ Requires-Python: <3.15,>=3.11
19
18
  Requires-Dist: numpy>=2.0.0
20
19
  Requires-Dist: xarray>=2024.1.0
21
20
  Requires-Dist: dask>=2024.7.1
21
+ Requires-Dist: epydeck~=1.0
22
22
  Provides-Extra: jupyter
23
23
  Requires-Dist: dask[diagnostics]; extra == "jupyter"
24
24
  Requires-Dist: ipykernel>=6.29.5; extra == "jupyter"
@@ -35,7 +35,7 @@ Description-Content-Type: text/markdown
35
35
  ![Build/Publish](https://github.com/epochpic/sdf-xarray/actions/workflows/build_publish.yml/badge.svg)
36
36
  ![Tests](https://github.com/epochpic/sdf-xarray/actions/workflows/tests.yml/badge.svg)
37
37
  [![Read the Docs](https://img.shields.io/readthedocs/sdf-xarray?logo=readthedocs&link=https%3A%2F%2Fsdf-xarray.readthedocs.io%2F)](https://sdf-xarray.readthedocs.io)
38
- [![Formatted with black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
38
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
39
39
 
40
40
 
41
41
  sdf-xarray provides a backend for [xarray](https://xarray.dev) to read SDF files as created by
@@ -148,4 +148,4 @@ To run checks locally before opening a pull request, see [CONTRIBUTING.md](CONTR
148
148
 
149
149
  ![PlasmaFAIR logo](PlasmaFAIR.svg)
150
150
 
151
- Originally developed by [PlasmaFAIR](https://plasmafair.github.io), EPSRC Grant EP/V051822/1
151
+ Originally developed by [PlasmaFAIR](https://plasmafair.github.io), EPSRC Grant EP/V051822/1
@@ -6,7 +6,7 @@
6
6
  ![Build/Publish](https://github.com/epochpic/sdf-xarray/actions/workflows/build_publish.yml/badge.svg)
7
7
  ![Tests](https://github.com/epochpic/sdf-xarray/actions/workflows/tests.yml/badge.svg)
8
8
  [![Read the Docs](https://img.shields.io/readthedocs/sdf-xarray?logo=readthedocs&link=https%3A%2F%2Fsdf-xarray.readthedocs.io%2F)](https://sdf-xarray.readthedocs.io)
9
- [![Formatted with black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
9
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
10
10
 
11
11
 
12
12
  sdf-xarray provides a backend for [xarray](https://xarray.dev) to read SDF files as created by
@@ -119,4 +119,4 @@ To run checks locally before opening a pull request, see [CONTRIBUTING.md](CONTR
119
119
 
120
120
  ![PlasmaFAIR logo](PlasmaFAIR.svg)
121
121
 
122
- Originally developed by [PlasmaFAIR](https://plasmafair.github.io), EPSRC Grant EP/V051822/1
122
+ Originally developed by [PlasmaFAIR](https://plasmafair.github.io), EPSRC Grant EP/V051822/1
@@ -0,0 +1,3 @@
1
+ .cell_output {
2
+ margin-bottom: 0.5em;
3
+ }
@@ -3,6 +3,9 @@
3
3
  .. |animate_accessor| replace:: `xarray.DataArray.epoch.animate
4
4
  <sdf_xarray.plotting.animate>`
5
5
 
6
+ .. |animate_multiple_accessor| replace:: `xarray.Dataset.epoch.animate_multiple
7
+ <sdf_xarray.plotting.animate_multiple>`
8
+
6
9
  ==========
7
10
  Animations
8
11
  ==========
@@ -122,7 +125,7 @@ the animation.
122
125
 
123
126
  .. jupyter-execute::
124
127
 
125
- ds = xr.open_dataset("tutorial_dataset_3d/0005.sdf")
128
+ ds = sdfxr.open_dataset("tutorial_dataset_3d/0005.sdf")
126
129
  da = ds["Derived_Number_Density"]
127
130
  anim = da.epoch.animate(t = "X_Grid_mid")
128
131
  anim.show()
@@ -131,10 +134,8 @@ Moving window
131
134
  -------------
132
135
 
133
136
  EPOCH allows for simulations that have a moving simulation window
134
- (changing x-axis over time). |animate_accessor| will
135
- automatically detect when a simulation has a moving window by searching
136
- for NaNs in the `xarray.DataArray` and change the x-axis limits
137
- accordingly.
137
+ (changing x-axis over time). |animate_accessor| can accept the boolean parameter
138
+ ``move_window`` and change the x-axis limits accordingly.
138
139
 
139
140
  .. warning::
140
141
  `sdf_xarray.open_mfdataset` does not currently function with moving window data.
@@ -152,7 +153,7 @@ accordingly.
152
153
  )
153
154
 
154
155
  da = ds["Derived_Number_Density_Beam_Electrons"]
155
- anim = da.epoch.animate(fps = 5)
156
+ anim = da.epoch.animate(move_window=True, fps = 5)
156
157
  anim.show()
157
158
 
158
159
  .. warning::
@@ -191,73 +192,70 @@ before plotting as in :ref:`sec-unit-conversion`. Some functionality such as
191
192
  )
192
193
  anim.show()
193
194
 
194
- Advanced usage
195
- --------------
195
+ Combining multiple animations
196
+ -----------------------------
196
197
 
197
- Multiple plots on the same axes
198
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198
+ |animate_multiple_accessor| creates a `matplotlib.animation.FuncAnimation`
199
+ that contains multiple plots layered on top of each other.
200
+
201
+ 1D simulation
202
+ ~~~~~~~~~~~~~
199
203
 
200
204
  What follows is an example of how to combine multiple animations on the
201
- same axis. This may be implemented in a more user-friendly function in
202
- a future update.
205
+ same axis.
203
206
 
204
207
  .. jupyter-execute::
205
208
 
206
- # Open the SDF files
207
209
  ds = sdfxr.open_mfdataset("tutorial_dataset_1d/*.sdf")
208
210
 
209
- # Create figure and axes
210
- fig, ax = plt.subplots()
211
- plt.close(fig)
212
-
213
- # Generate the animations independently
214
- anim_1 = ds["Derived_Number_Density_Electron"].epoch.animate()
215
- anim_2 = ds["Derived_Number_Density_Ion"].epoch.animate()
216
-
217
- # Extract the update functions from the animations
218
- update_1 = anim_1._func
219
- update_2 = anim_2._func
220
-
221
- # Create axes details for new animation
222
- x_min, x_max = update_1(0)[0].axes.get_xlim()
223
- y_min_1, y_max_1 = update_1(0)[0].axes.get_ylim()
224
- y_min_2, y_max_2 = update_2(0)[0].axes.get_ylim()
225
- y_min = min(y_min_1, y_min_2)
226
- y_max = max(y_max_1, y_max_2)
227
- x_label = update_1(0)[0].axes.get_xlabel()
228
- y_label = "Number Density [m$^{-3}$]"
229
- label_1 = "Electron"
230
- label_2 = "Ion"
231
-
232
- # Create new update function
233
- def update_combined(frame):
234
- anim_1_fig = update_1(frame)[0]
235
- anim_2_fig = update_2(frame)[0]
236
-
237
- title = anim_1_fig.axes.title._text
238
-
239
- ax.clear()
240
- plot = ax.plot(anim_1_fig._x, anim_1_fig._y, label = label_1)
241
- ax.plot(anim_2_fig._x, anim_2_fig._y, label = label_2)
242
- ax.set_title(title)
243
- ax.set_xlim(x_min, x_max)
244
- ax.set_ylim(y_min, y_max)
245
- ax.set_xlabel(x_label)
246
- ax.set_ylabel(y_label)
247
- ax.legend(loc = "upper left")
248
- return plot
249
-
250
- N_frames = anim_1._save_count
251
- interval = anim_1._interval
252
-
253
- # Create combined animation
254
- anim_combined = FuncAnimation(
255
- fig,
256
- update_combined,
257
- frames=range(N_frames),
258
- interval = interval,
259
- repeat=True,
260
- )
211
+ anim = ds.epoch.animate_multiple(
212
+ ds["Derived_Number_Density_Electron"],
213
+ ds["Derived_Number_Density_Ion"],
214
+ datasets_kwargs=[{"label": "Electron"}, {"label": "Ion"}],
215
+ ylim=(0e27,4e27),
216
+ ylabel="Derived Number Density [1/m$^3$]"
217
+ )
261
218
 
262
- # Display animation as jshtml
263
- HTML(anim_combined.to_jshtml())
219
+ anim.show()
220
+
221
+ 2D simulation
222
+ ~~~~~~~~~~~~~
223
+
224
+ .. tip::
225
+ To correctly display 2D data on top of one another you need to specify
226
+ the ``alpha`` value which sets the opacity of the plot.
227
+
228
+ This also works with 2 dimensional data.
229
+
230
+ .. jupyter-execute::
231
+
232
+ import numpy as np
233
+ from matplotlib.colors import LogNorm
234
+
235
+ ds = sdfxr.open_mfdataset("tutorial_dataset_2d/*.sdf")
236
+
237
+ flux_magnitude = np.sqrt(
238
+ ds["Derived_Poynting_Flux_x"]**2 +
239
+ ds["Derived_Poynting_Flux_y"]**2 +
240
+ ds["Derived_Poynting_Flux_z"]**2
241
+ )
242
+ flux_magnitude.attrs["long_name"] = "Poynting Flux Magnitude"
243
+ flux_magnitude.attrs["units"] = "W/m$^2$"
244
+
245
+ # Cut-off low energy values so that they will be rendered as transparent
246
+ # in the plot as they've been set to NaN
247
+ flux_masked = flux_magnitude.where(flux_magnitude > 0.2e23)
248
+ flux_norm = LogNorm(
249
+ vmin=float(flux_masked.min()),
250
+ vmax=float(flux_masked.max())
251
+ )
252
+
253
+ anim = ds.epoch.animate_multiple(
254
+ ds["Derived_Number_Density_Electron"],
255
+ flux_masked,
256
+ datasets_kwargs=[
257
+ {"alpha": 1.0},
258
+ {"cmap": "hot", "norm": flux_norm, "alpha": 0.9},
259
+ ],
260
+ )
261
+ anim.show()
@@ -50,6 +50,7 @@ extensions = [
50
50
  "myst_parser",
51
51
  "jupyter_sphinx",
52
52
  "sphinx_copybutton",
53
+ "sphinx_togglebutton",
53
54
  ]
54
55
 
55
56
  autosummary_generate = True
@@ -102,9 +103,7 @@ html_theme = "sphinx_book_theme"
102
103
  # relative to this directory. They are copied after the builtin static files,
103
104
  # so a file named "default.css" will overwrite the builtin "default.css".
104
105
  html_static_path = ["_static"]
105
- html_css_files = [
106
- "force_render_dark_xarray_objects.css",
107
- ]
106
+ html_css_files = ["force_render_dark_xarray_objects.css", "jupyter_padding.css"]
108
107
 
109
108
  html_theme_options = {
110
109
  "repository_url": "https://github.com/epochpic/sdf-xarray",
@@ -0,0 +1,75 @@
1
+ .. _sec-getting-started:
2
+
3
+ =================
4
+ Getting Started
5
+ =================
6
+
7
+ Installation
8
+ ------------
9
+
10
+ .. |python_versions_pypi| image:: https://img.shields.io/pypi/pyversions/sdf-xarray.svg
11
+ :alt: Supported Python versions
12
+ :target: https://pypi.org/project/sdf-xarray/
13
+
14
+ .. important::
15
+
16
+ To install this package, ensure that you are using one of the supported Python
17
+ versions |python_versions_pypi|
18
+
19
+ Install sdf-xarray from PyPI with:
20
+
21
+ .. code-block:: bash
22
+
23
+ pip install sdf-xarray
24
+
25
+ or download this code locally:
26
+
27
+ .. code-block:: bash
28
+
29
+ git clone --recursive https://github.com/epochpic/sdf-xarray.git
30
+ cd sdf-xarray
31
+ pip install .
32
+
33
+
34
+ Interaction
35
+ -----------
36
+
37
+ There are two main ways to load EPOCH SDF files into xarray objects: using the dedicated
38
+ `sdf_xarray` functions or using the standard `xarray` interface with our custom engine.
39
+ For examples of how to use these functions see :ref:`loading-sdf-files`.
40
+
41
+ All code examples throughout this documentation are visualised using Jupyter notebooks
42
+ so that you can interactively explore the datasets. To do this on your machine make
43
+ sure that you have the necessary dependencies installed:
44
+
45
+ .. code-block:: bash
46
+
47
+ pip install "sdf-xarray[jupyter]"
48
+
49
+ .. important::
50
+
51
+ When loading SDF files, variables related to ``boundaries``, ``cpu`` and ``output file``
52
+ are excluded as they are problematic. If you wish to load these variables in see
53
+ :ref:`loading-raw-files`.
54
+
55
+
56
+ Using sdf_xarray (Recommended)
57
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58
+
59
+ These functions are wrappers designed specifically for SDF data, providing the most
60
+ straightforward experience:
61
+
62
+ - **Single files**: Use `sdf_xarray.open_dataset` or `sdf_xarray.open_datatree`
63
+ - **Multiple files**: Use `sdf_xarray.open_mfdataset` or `sdf_xarray.open_mfdatatree`
64
+ - **Raw files**: use `sdf_xarray.sdf_interface.SDFFile`
65
+
66
+ Using xarray
67
+ ~~~~~~~~~~~~
68
+
69
+ If you prefer using the native `xarray` functions, you can use the `xarray.open_dataset`,
70
+ `xarray.open_datatree` and `xarray.open_mfdataset`. Strangely there is no function in
71
+ `xarray` for ``xarray.open_mfdatatree``.
72
+
73
+ These functions should all work out of the box as long as `sdf_xarray` is installed on your
74
+ system, if you are having issues with it reading files, you might need to pass the parameter
75
+ ``engine=sdf_engine`` when calling any of the above xarray functions.