sdf-xarray 0.2.4__cp312-cp312-win_amd64.whl → 0.2.6__cp312-cp312-win_amd64.whl

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.

Potentially problematic release.


This version of sdf-xarray might be problematic. Click here for more details.

lib/SDFC_14.4.7/sdfc.lib CHANGED
Binary file
sdf_xarray/__init__.py CHANGED
@@ -69,6 +69,7 @@ def open_mfdataset(
69
69
  *,
70
70
  separate_times: bool = False,
71
71
  keep_particles: bool = False,
72
+ probe_names: list[str] | None = None,
72
73
  ) -> xr.Dataset:
73
74
  """Open a set of EPOCH SDF files as one `xarray.Dataset`
74
75
 
@@ -98,6 +99,8 @@ def open_mfdataset(
98
99
  different output frequencies
99
100
  keep_particles :
100
101
  If ``True``, also load particle data (this may use a lot of memory!)
102
+ probe_names :
103
+ List of EPOCH probe names
101
104
  """
102
105
 
103
106
  # TODO: This is not very robust, look at how xarray.open_mfdataset does it
@@ -108,10 +111,15 @@ def open_mfdataset(
108
111
  path_glob = sorted(list(path_glob)) # noqa: C414
109
112
 
110
113
  if not separate_times:
111
- return combine_datasets(path_glob, keep_particles=keep_particles)
114
+ return combine_datasets(
115
+ path_glob, keep_particles=keep_particles, probe_names=probe_names
116
+ )
112
117
 
113
118
  time_dims, var_times_map = make_time_dims(path_glob)
114
- all_dfs = [xr.open_dataset(f, keep_particles=keep_particles) for f in path_glob]
119
+ all_dfs = [
120
+ xr.open_dataset(f, keep_particles=keep_particles, probe_names=probe_names)
121
+ for f in path_glob
122
+ ]
115
123
 
116
124
  for df in all_dfs:
117
125
  for da in df:
@@ -211,14 +219,23 @@ class SDFDataStore(AbstractDataStore):
211
219
  "drop_variables",
212
220
  "keep_particles",
213
221
  "lock",
222
+ "probe_names",
214
223
  )
215
224
 
216
- def __init__(self, manager, drop_variables=None, keep_particles=False, lock=None):
225
+ def __init__(
226
+ self,
227
+ manager,
228
+ drop_variables=None,
229
+ keep_particles=False,
230
+ lock=None,
231
+ probe_names=None,
232
+ ):
217
233
  self._manager = manager
218
234
  self._filename = self.ds.filename
219
235
  self.drop_variables = drop_variables
220
236
  self.keep_particles = keep_particles
221
237
  self.lock = ensure_lock(lock)
238
+ self.probe_names = probe_names
222
239
 
223
240
  @classmethod
224
241
  def open(
@@ -227,6 +244,7 @@ class SDFDataStore(AbstractDataStore):
227
244
  lock=None,
228
245
  drop_variables=None,
229
246
  keep_particles=False,
247
+ probe_names=None,
230
248
  ):
231
249
  if isinstance(filename, os.PathLike):
232
250
  filename = os.fspath(filename)
@@ -237,6 +255,7 @@ class SDFDataStore(AbstractDataStore):
237
255
  lock=lock,
238
256
  drop_variables=drop_variables,
239
257
  keep_particles=keep_particles,
258
+ probe_names=probe_names,
240
259
  )
241
260
 
242
261
  def _acquire(self, needs_lock=True):
@@ -253,9 +272,18 @@ class SDFDataStore(AbstractDataStore):
253
272
  def load(self): # noqa: PLR0912, PLR0915
254
273
  # Drop any requested variables
255
274
  if self.drop_variables:
275
+ # Build a mapping from underscored names to real variable names
276
+ name_map = {_rename_with_underscore(var): var for var in self.ds.variables}
277
+
256
278
  for variable in self.drop_variables:
257
- # TODO: nicer error handling
258
- self.ds.variables.pop(variable)
279
+ key = _rename_with_underscore(variable)
280
+ original_name = name_map.get(key)
281
+
282
+ if original_name is None:
283
+ raise KeyError(
284
+ f"Variable '{variable}' not found (interpreted as '{key}')."
285
+ )
286
+ self.ds.variables.pop(original_name)
259
287
 
260
288
  # These two dicts are global metadata about the run or file
261
289
  attrs = {**self.ds.header, **self.ds.run_info}
@@ -338,7 +366,28 @@ class SDFDataStore(AbstractDataStore):
338
366
 
339
367
  if value.is_point_data:
340
368
  # Point (particle) variables are 1D
341
- var_coords = (f"ID_{_process_grid_name(key, _grid_species_name)}",)
369
+
370
+ # Particle data does not maintain a fixed dimension size
371
+ # throughout the simulation. An example of a particle name comes
372
+ # in the form of `Particles/Px/Ion_H` which is then modified
373
+ # using `_process_grid_name()` into `Ion_H`. This is fine as the
374
+ # other components of the momentum (`Py`, `Pz`) will have the same
375
+ # size as they represent the same bunch of particles.
376
+
377
+ # Probes however have names in the form of `Electron_Front_Probe/Px`
378
+ # which are changed to just `Px`; this is fine when there is only one
379
+ # probe in the system but when there are multiple they will have
380
+ # conflicting sizes so we can't keep the names as simply `Px` so we
381
+ # instead set their dimension as the full name `Electron_Front_Probe_Px`.
382
+ is_probe_name_match = self.probe_names is not None and any(
383
+ name in key for name in self.probe_names
384
+ )
385
+ name_processor = (
386
+ _rename_with_underscore
387
+ if is_probe_name_match
388
+ else _grid_species_name
389
+ )
390
+ var_coords = (f"ID_{_process_grid_name(key, name_processor)}",)
342
391
  else:
343
392
  # These are DataArrays
344
393
 
@@ -405,6 +454,7 @@ class SDFEntrypoint(BackendEntrypoint):
405
454
  *,
406
455
  drop_variables=None,
407
456
  keep_particles=False,
457
+ probe_names=None,
408
458
  ):
409
459
  if isinstance(filename_or_obj, Path):
410
460
  # sdf library takes a filename only
@@ -415,6 +465,7 @@ class SDFEntrypoint(BackendEntrypoint):
415
465
  filename_or_obj,
416
466
  drop_variables=drop_variables,
417
467
  keep_particles=keep_particles,
468
+ probe_names=probe_names,
418
469
  )
419
470
  with close_on_error(store):
420
471
  return store.load()
@@ -423,6 +474,7 @@ class SDFEntrypoint(BackendEntrypoint):
423
474
  "filename_or_obj",
424
475
  "drop_variables",
425
476
  "keep_particles",
477
+ "probe_names",
426
478
  ]
427
479
 
428
480
  def guess_can_open(self, filename_or_obj):
@@ -434,7 +486,7 @@ class SDFEntrypoint(BackendEntrypoint):
434
486
 
435
487
  description = "Use .sdf files in Xarray"
436
488
 
437
- url = "https://epochpic.github.io/documentation/visualising_output/python.html"
489
+ url = "https://epochpic.github.io/documentation/visualising_output/python_beam.html"
438
490
 
439
491
 
440
492
  class SDFPreprocess:
sdf_xarray/_version.py CHANGED
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '0.2.4'
21
- __version_tuple__ = version_tuple = (0, 2, 4)
31
+ __version__ = version = '0.2.6'
32
+ __version_tuple__ = version_tuple = (0, 2, 6)
33
+
34
+ __commit_id__ = commit_id = 'g67411803b'
sdf_xarray/plotting.py CHANGED
@@ -114,8 +114,8 @@ def animate(
114
114
  --------
115
115
  >>> dataset["Derived_Number_Density_Electron"].epoch.animate()
116
116
  """
117
- import matplotlib.pyplot as plt
118
- from matplotlib.animation import FuncAnimation
117
+ import matplotlib.pyplot as plt # noqa: PLC0415
118
+ from matplotlib.animation import FuncAnimation # noqa: PLC0415
119
119
 
120
120
  kwargs_original = kwargs.copy()
121
121
 
@@ -1,47 +1,20 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: sdf-xarray
3
- Version: 0.2.4
3
+ Version: 0.2.6
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
- License: Copyright 2024, Peter Hill, Joel Adams, epochpic team
7
-
8
- Redistribution and use in source and binary forms, with or without
9
- modification, are permitted provided that the following conditions are
10
- met:
11
-
12
- 1. Redistributions of source code must retain the above copyright
13
- notice, this list of conditions and the following disclaimer.
14
-
15
- 2. Redistributions in binary form must reproduce the above copyright
16
- notice, this list of conditions and the following disclaimer in the
17
- documentation and/or other materials provided with the distribution.
18
-
19
- 3. Neither the name of the copyright holder nor the names of its
20
- contributors may be used to endorse or promote products derived from
21
- this software without specific prior written permission.
22
-
23
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
- “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
-
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Development Status :: 5 - Production/Stable
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Topic :: Scientific/Engineering
10
+ Classifier: Operating System :: OS Independent
35
11
  Classifier: Programming Language :: Python
36
12
  Classifier: Programming Language :: Python :: 3
37
13
  Classifier: Programming Language :: Python :: 3.10
38
14
  Classifier: Programming Language :: Python :: 3.11
39
15
  Classifier: Programming Language :: Python :: 3.12
40
16
  Classifier: Programming Language :: Python :: 3.13
41
- Classifier: Intended Audience :: Science/Research
42
- Classifier: Topic :: Scientific/Engineering
43
- Classifier: Operating System :: OS Independent
44
- Requires-Python: >=3.10
17
+ Requires-Python: <3.14,>=3.10
45
18
  Requires-Dist: numpy>=2.0.0
46
19
  Requires-Dist: xarray>=2024.1.0
47
20
  Requires-Dist: dask>=2024.7.1
@@ -6,19 +6,19 @@ include/SDFC_14.4.7/sdf_list_type.h,sha256=Quu8v0-SEsQuJpGtEZnm09tAyXqWNitx0sXl5
6
6
  include/SDFC_14.4.7/sdf_vector_type.h,sha256=dbKjhzRRsvhzrnTwVjtVlvnuisEnRMKY-vvdm94ok_Q,1595
7
7
  include/SDFC_14.4.7/stack_allocator.h,sha256=L7U9vmGiVSw3VQLIv9EzTaVq7JbFxs9aNonKStTkUSg,1335
8
8
  include/SDFC_14.4.7/uthash.h,sha256=rIyy_-ylY6S_7WaZCCC3VtvXaC9q37rFyA0f1U9xc4w,63030
9
- lib/SDFC_14.4.7/sdfc.lib,sha256=DhpyA_nvLlofl1uM9klwcs3syjPQzAzBvhGIn7ioeho,350410
9
+ lib/SDFC_14.4.7/sdfc.lib,sha256=vzkgOfIchwob_mJqLi6I-d7j-9MZjq4CyeZVmt5On3k,350158
10
10
  lib/SDFC_14.4.7/SDFCConfig.cmake,sha256=IOA1eusC-KvUK4LNTEiOAmEdaPH1ZvNvbYPgiG1oZio,802
11
11
  lib/SDFC_14.4.7/SDFCConfigVersion.cmake,sha256=pN7Qqyf04s3izw7PYQ0XK6imvmhaVegSdR_nEl3Ok_o,2830
12
12
  lib/SDFC_14.4.7/SDFCTargets-release.cmake,sha256=G4zdx5PyjePigeD_a6rmZAxbk7L8Nf0klUnV78Lm2fI,828
13
13
  lib/SDFC_14.4.7/SDFCTargets.cmake,sha256=OVt1Gm8n7Ew4fiTmA9yHoef3vIIGwsXUZfqeG9p9Bys,4152
14
- sdf_xarray/__init__.py,sha256=bPzOJwcKQAsx-mryOyxOCXHijA4nr5ayZWPRrMNNuMU,17642
15
- sdf_xarray/_version.py,sha256=4HOJxLsEz0nPHMraGaR2KjWuypKklVh7NijIwVz3nSg,532
14
+ sdf_xarray/__init__.py,sha256=-RXoKffu5dD54-t5qmapiAJ9ODN-w0OmXDal88e-KKE,19816
15
+ sdf_xarray/_version.py,sha256=tKK1XlQrBwni5QwVI5KGGYkfGy_9gVAaKgRzYVdjGSI,746
16
16
  sdf_xarray/csdf.pxd,sha256=ADPjAuHsodAvdOz96Z_XlFF7VL3KmVaXcTifWDP3rK0,4205
17
- sdf_xarray/plotting.py,sha256=ze1paC1Uw42WOWspdqkyNsUviDt-Z7AwQlPyO7JB90o,7007
18
- sdf_xarray/sdf_interface.cp312-win_amd64.pyd,sha256=dHhckvhBNazLGLM_R2geBlAoWZFcll1UGrKC5VW8h3Y,359424
17
+ sdf_xarray/plotting.py,sha256=PnbEspR4XkA5SHkpoFKA2G7BYj5J3mVgR1TEeGol6Vw,7041
18
+ sdf_xarray/sdf_interface.cp312-win_amd64.pyd,sha256=hWUXJSmAhYdIlsUh3MjqxFRa-xJS3XRf8wQXeCG3eMY,360960
19
19
  sdf_xarray/sdf_interface.pyx,sha256=PFC6upg14OZBqiGInLgBoxztIIKBk-HOh3WC9Ro4YUw,11975
20
- sdf_xarray-0.2.4.dist-info/METADATA,sha256=l0Gwyl2O5oSNQJ8yLOCcABSSd5VlCz9MAwo4GgHxcuQ,9129
21
- sdf_xarray-0.2.4.dist-info/WHEEL,sha256=k3AOLK754NVb09U5k7PdROOgoHUP1Q4mZk2PKi14SoM,106
22
- sdf_xarray-0.2.4.dist-info/entry_points.txt,sha256=gP7BIQpXNg6vIf7S7p-Rw_EJZTC1X50BsVTkK7dA7g0,57
23
- sdf_xarray-0.2.4.dist-info/licenses/LICENCE,sha256=aHWuyELjtzIL1jTXFHTbI3tr9vyVyhnw3I9_QYPdEX8,1515
24
- sdf_xarray-0.2.4.dist-info/RECORD,,
20
+ sdf_xarray-0.2.6.dist-info/METADATA,sha256=tiVT3h4nUdTgmGJsSKbymdlWjDNbVw8pnr5ccxNy5cQ,7475
21
+ sdf_xarray-0.2.6.dist-info/WHEEL,sha256=TcMXEVBP2SQds4YZwJ6flDTTNRzCE5owNAganfIqM0g,106
22
+ sdf_xarray-0.2.6.dist-info/entry_points.txt,sha256=gP7BIQpXNg6vIf7S7p-Rw_EJZTC1X50BsVTkK7dA7g0,57
23
+ sdf_xarray-0.2.6.dist-info/licenses/LICENCE,sha256=aHWuyELjtzIL1jTXFHTbI3tr9vyVyhnw3I9_QYPdEX8,1515
24
+ sdf_xarray-0.2.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: scikit-build-core 0.11.2
2
+ Generator: scikit-build-core 0.11.5
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5