sdf-xarray 0.2.4__tar.gz → 0.2.5__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 (112) hide show
  1. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/PKG-INFO +1 -1
  2. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/src/sdf_xarray/__init__.py +12 -3
  3. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/src/sdf_xarray/_version.py +2 -2
  4. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/test_basic.py +41 -0
  5. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.github/workflows/black.yml +0 -0
  6. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.github/workflows/build_publish.yml +0 -0
  7. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.github/workflows/lint.yml +0 -0
  8. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.github/workflows/tests.yml +0 -0
  9. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.gitignore +0 -0
  10. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.gitmodules +0 -0
  11. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/.readthedocs.yaml +0 -0
  12. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/BEAM.png +0 -0
  13. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/CITATION.cff +0 -0
  14. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/CMakeLists.txt +0 -0
  15. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/CONTRIBUTING.md +0 -0
  16. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/LICENCE +0 -0
  17. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/PlasmaFAIR.svg +0 -0
  18. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/README.md +0 -0
  19. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/.gitignore +0 -0
  20. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/_templates/custom-class-template.rst +0 -0
  21. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/_templates/custom-module-template.rst +0 -0
  22. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/api.rst +0 -0
  23. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/conf.py +0 -0
  24. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/contributing.rst +0 -0
  25. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/getting_started.rst +0 -0
  26. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/index.rst +0 -0
  27. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/key_functionality.rst +0 -0
  28. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/make.bat +0 -0
  29. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0000.sdf +0 -0
  30. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0001.sdf +0 -0
  31. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0002.sdf +0 -0
  32. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0003.sdf +0 -0
  33. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0004.sdf +0 -0
  34. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0005.sdf +0 -0
  35. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0006.sdf +0 -0
  36. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0007.sdf +0 -0
  37. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0008.sdf +0 -0
  38. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0009.sdf +0 -0
  39. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0010.sdf +0 -0
  40. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0011.sdf +0 -0
  41. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0012.sdf +0 -0
  42. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0013.sdf +0 -0
  43. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0014.sdf +0 -0
  44. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0015.sdf +0 -0
  45. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0016.sdf +0 -0
  46. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0017.sdf +0 -0
  47. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0018.sdf +0 -0
  48. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0019.sdf +0 -0
  49. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0020.sdf +0 -0
  50. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0021.sdf +0 -0
  51. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0022.sdf +0 -0
  52. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0023.sdf +0 -0
  53. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0024.sdf +0 -0
  54. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0025.sdf +0 -0
  55. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0026.sdf +0 -0
  56. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0027.sdf +0 -0
  57. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0028.sdf +0 -0
  58. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0029.sdf +0 -0
  59. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0030.sdf +0 -0
  60. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0031.sdf +0 -0
  61. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0032.sdf +0 -0
  62. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0033.sdf +0 -0
  63. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0034.sdf +0 -0
  64. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0035.sdf +0 -0
  65. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0036.sdf +0 -0
  66. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0037.sdf +0 -0
  67. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0038.sdf +0 -0
  68. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0039.sdf +0 -0
  69. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/0040.sdf +0 -0
  70. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/deck.status +0 -0
  71. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/epoch1d.dat +0 -0
  72. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/input.deck +0 -0
  73. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/normal.visit +0 -0
  74. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/tutorial_dataset_1d/restart.visit +0 -0
  75. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/docs/unit_conversion.rst +0 -0
  76. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/pyproject.toml +0 -0
  77. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/src/sdf_xarray/csdf.pxd +0 -0
  78. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/src/sdf_xarray/plotting.py +0 -0
  79. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/src/sdf_xarray/sdf_interface.pyx +0 -0
  80. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_array_no_grids/0000.sdf +0 -0
  81. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_array_no_grids/0001.sdf +0 -0
  82. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_array_no_grids/README.md +0 -0
  83. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_array_no_grids/input.deck +0 -0
  84. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_dist_fn/0000.sdf +0 -0
  85. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_dist_fn/0001.sdf +0 -0
  86. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_dist_fn/0002.sdf +0 -0
  87. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_dist_fn/input.deck +0 -0
  88. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0000.sdf +0 -0
  89. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0001.sdf +0 -0
  90. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0002.sdf +0 -0
  91. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0003.sdf +0 -0
  92. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0004.sdf +0 -0
  93. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0005.sdf +0 -0
  94. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0006.sdf +0 -0
  95. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0007.sdf +0 -0
  96. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0008.sdf +0 -0
  97. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0009.sdf +0 -0
  98. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/0010.sdf +0 -0
  99. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/README.md +0 -0
  100. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_1D/input.deck +0 -0
  101. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/0000.sdf +0 -0
  102. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/0001.sdf +0 -0
  103. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/0002.sdf +0 -0
  104. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/0003.sdf +0 -0
  105. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/0004.sdf +0 -0
  106. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_files_2D_moving_window/input.deck +0 -0
  107. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_mismatched_files/0000.sdf +0 -0
  108. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_mismatched_files/0001.sdf +0 -0
  109. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/example_mismatched_files/0002.sdf +0 -0
  110. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/test_cython.py +0 -0
  111. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/tests/test_epoch_accessor.py +0 -0
  112. {sdf_xarray-0.2.4 → sdf_xarray-0.2.5}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sdf-xarray
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Provides a backend for xarray to read SDF files as created by the EPOCH plasma PIC code.
5
5
  Author-Email: Peter Hill <peter.hill@york.ac.uk>, Joel Adams <joel.adams@york.ac.uk>, Shaun Doherty <shaun.doherty@york.ac.uk>
6
6
  License: Copyright 2024, Peter Hill, Joel Adams, epochpic team
@@ -253,9 +253,18 @@ class SDFDataStore(AbstractDataStore):
253
253
  def load(self): # noqa: PLR0912, PLR0915
254
254
  # Drop any requested variables
255
255
  if self.drop_variables:
256
+ # Build a mapping from underscored names to real variable names
257
+ name_map = {_rename_with_underscore(var): var for var in self.ds.variables}
258
+
256
259
  for variable in self.drop_variables:
257
- # TODO: nicer error handling
258
- self.ds.variables.pop(variable)
260
+ key = _rename_with_underscore(variable)
261
+ original_name = name_map.get(key)
262
+
263
+ if original_name is None:
264
+ raise KeyError(
265
+ f"Variable '{variable}' not found (interpreted as '{key}')."
266
+ )
267
+ self.ds.variables.pop(original_name)
259
268
 
260
269
  # These two dicts are global metadata about the run or file
261
270
  attrs = {**self.ds.header, **self.ds.run_info}
@@ -434,7 +443,7 @@ class SDFEntrypoint(BackendEntrypoint):
434
443
 
435
444
  description = "Use .sdf files in Xarray"
436
445
 
437
- url = "https://epochpic.github.io/documentation/visualising_output/python.html"
446
+ url = "https://epochpic.github.io/documentation/visualising_output/python_beam.html"
438
447
 
439
448
 
440
449
  class SDFPreprocess:
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.2.4'
21
- __version_tuple__ = version_tuple = (0, 2, 4)
20
+ __version__ = version = '0.2.5'
21
+ __version_tuple__ = version_tuple = (0, 2, 5)
@@ -185,3 +185,44 @@ def test_3d_distribution_function():
185
185
  with xr.open_dataset(EXAMPLE_3D_DIST_FN / "0000.sdf") as df:
186
186
  distribution_function = "dist_fn_x_px_py_Electron"
187
187
  assert df[distribution_function].shape == (16, 20, 20)
188
+
189
+
190
+ def test_drop_variables():
191
+ with xr.open_dataset(
192
+ EXAMPLE_FILES_DIR / "0000.sdf", drop_variables=["Electric_Field_Ex"]
193
+ ) as df:
194
+ assert "Electric_Field_Ex" not in df
195
+
196
+
197
+ def test_drop_variables_multiple():
198
+ with xr.open_dataset(
199
+ EXAMPLE_FILES_DIR / "0000.sdf",
200
+ drop_variables=["Electric_Field_Ex", "Electric_Field_Ey"],
201
+ ) as df:
202
+ assert "Electric_Field_Ex" not in df
203
+ assert "Electric_Field_Ey" not in df
204
+
205
+
206
+ def test_drop_variables_original():
207
+ with xr.open_dataset(
208
+ EXAMPLE_FILES_DIR / "0000.sdf",
209
+ drop_variables=["Electric_Field/Ex", "Electric_Field/Ey"],
210
+ ) as df:
211
+ assert "Electric_Field_Ex" not in df
212
+ assert "Electric_Field_Ey" not in df
213
+
214
+
215
+ def test_drop_variables_mixed():
216
+ with xr.open_dataset(
217
+ EXAMPLE_FILES_DIR / "0000.sdf",
218
+ drop_variables=["Electric_Field/Ex", "Electric_Field_Ey"],
219
+ ) as df:
220
+ assert "Electric_Field_Ex" not in df
221
+ assert "Electric_Field_Ey" not in df
222
+
223
+
224
+ def test_erroring_drop_variables():
225
+ with pytest.raises(KeyError):
226
+ xr.open_dataset(
227
+ EXAMPLE_FILES_DIR / "0000.sdf", drop_variables=["Electric_Field/E"]
228
+ )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes