sdf-xarray 0.3.0__cp313-cp313-macosx_11_0_arm64.whl → 0.3.1__cp313-cp313-macosx_11_0_arm64.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/libsdfc.a CHANGED
Binary file
sdf_xarray/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
+ import contextlib
1
2
  import os
2
3
  import re
3
4
  from collections import Counter, defaultdict
@@ -18,10 +19,16 @@ from xarray.core import indexing
18
19
  from xarray.core.utils import close_on_error, try_read_magic_number_from_path
19
20
  from xarray.core.variable import Variable
20
21
 
21
- # NOTE: Do not delete this line, otherwise the "epoch" accessor will not be
22
- # imported when the user imports sdf_xarray
22
+ # NOTE: Do not delete these lines, otherwise the "epoch" dataset and dataarray
23
+ # accessors will not be imported when the user imports sdf_xarray
24
+ import sdf_xarray.dataset_accessor
23
25
  import sdf_xarray.plotting # noqa: F401
24
26
 
27
+ # NOTE: This attempts to initialise with the "pint" accessor if the user
28
+ # has installed the package
29
+ with contextlib.suppress(ImportError):
30
+ import pint_xarray # noqa: F401
31
+
25
32
  from .sdf_interface import Constant, SDFFile # type: ignore # noqa: PGH003
26
33
 
27
34
  # TODO Remove this once the new kwarg options are fully implemented
sdf_xarray/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.3.0'
32
- __version_tuple__ = version_tuple = (0, 3, 0)
31
+ __version__ = version = '0.3.1'
32
+ __version_tuple__ = version_tuple = (0, 3, 1)
33
33
 
34
- __commit_id__ = commit_id = 'gcca942b3f'
34
+ __commit_id__ = commit_id = 'gce5426d4a'
@@ -0,0 +1,73 @@
1
+ from typing import Union
2
+
3
+ import xarray as xr
4
+
5
+
6
+ @xr.register_dataset_accessor("epoch")
7
+ class EpochAccessor:
8
+ def __init__(self, xarray_obj: xr.Dataset):
9
+ # The xarray object is the Dataset, which we store as self._ds
10
+ self._ds = xarray_obj
11
+
12
+ def rescale_coords(
13
+ self,
14
+ multiplier: float,
15
+ unit_label: str,
16
+ coord_names: Union[str, list[str]],
17
+ ) -> xr.Dataset:
18
+ """
19
+ Rescales specified X and Y coordinates in the Dataset by a given multiplier
20
+ and updates the unit label attribute.
21
+
22
+ Parameters
23
+ ----------
24
+ multiplier : float
25
+ The factor by which to multiply the coordinate values (e.g., 1e6 for meters to microns).
26
+ unit_label : str
27
+ The new unit label for the coordinates (e.g., "µm").
28
+ coord_names : str or list of str
29
+ The name(s) of the coordinate variable(s) to rescale.
30
+ If a string, only that coordinate is rescaled.
31
+ If a list, all listed coordinates are rescaled.
32
+
33
+ Returns
34
+ -------
35
+ xr.Dataset
36
+ A new Dataset with the updated and rescaled coordinates.
37
+
38
+ Examples
39
+ --------
40
+ # Convert X, Y, and Z from meters to microns
41
+ >>> ds_in_microns = ds.epoch.rescale_coords(1e6, "µm", coord_names=["X_Grid", "Y_Grid", "Z_Grid"])
42
+
43
+ # Convert only X to millimeters
44
+ >>> ds_in_mm = ds.epoch.rescale_coords(1000, "mm", coord_names="X_Grid")
45
+ """
46
+
47
+ ds = self._ds
48
+ new_coords = {}
49
+
50
+ if isinstance(coord_names, str):
51
+ # Convert single string to a list
52
+ coords_to_process = [coord_names]
53
+ elif isinstance(coord_names, list):
54
+ # Use the provided list
55
+ coords_to_process = coord_names
56
+ else:
57
+ coords_to_process = list(coord_names)
58
+
59
+ for coord_name in coords_to_process:
60
+ if coord_name not in ds.coords:
61
+ raise ValueError(
62
+ f"Coordinate '{coord_name}' not found in the Dataset. Cannot rescale."
63
+ )
64
+
65
+ coord_original = ds[coord_name]
66
+
67
+ coord_rescaled = coord_original * multiplier
68
+ coord_rescaled.attrs = coord_original.attrs.copy()
69
+ coord_rescaled.attrs["units"] = unit_label
70
+
71
+ new_coords[coord_name] = coord_rescaled
72
+
73
+ return ds.assign_coords(new_coords)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sdf-xarray
3
- Version: 0.3.0
3
+ Version: 0.3.1
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-Expression: BSD-3-Clause
@@ -1,8 +1,3 @@
1
- sdf_xarray-0.3.0.dist-info/RECORD,,
2
- sdf_xarray-0.3.0.dist-info/WHEEL,sha256=RKB2kgklE3rgz0xlIuKYm-O5gcSzEoMvCOiEOfbYfDs,141
3
- sdf_xarray-0.3.0.dist-info/entry_points.txt,sha256=gP7BIQpXNg6vIf7S7p-Rw_EJZTC1X50BsVTkK7dA7g0,57
4
- sdf_xarray-0.3.0.dist-info/METADATA,sha256=q9WJBhz2Su52p14Q6b1ZBJRjCeepN7yfao9PdVnVbtU,7582
5
- sdf_xarray-0.3.0.dist-info/licenses/LICENCE,sha256=0FfLVWQRQERtj0vUKjJk7-UrDp-t70Et9izWejGe4Os,1487
6
1
  include/SDFC_14.4.7/sdf_derived.h,sha256=VqRsCmjmSRIOGqZSiPMsvmNaFBoNzXhrlKeyWGYIzm8,636
7
2
  include/SDFC_14.4.7/sdf_helper.h,sha256=UD291Xf8ZUeh34iv-qLN-u8f5vPQz0joTFxIQWUIVYA,1020
8
3
  include/SDFC_14.4.7/sdf_vector_type.h,sha256=5tcQcF7zDm7kTkLCzm12G5Z3ARVXvw7-XpKQ6WWej6U,1527
@@ -11,14 +6,20 @@ include/SDFC_14.4.7/sdf_extension.h,sha256=my_ze10hSGfWEQEaUWh8TxFuVsiAl-g6aDn6q
11
6
  include/SDFC_14.4.7/uthash.h,sha256=BN_4JfPHloW0kI3VRhvCqP8D2VcvD0HpSLgo4MBz6Sk,62067
12
7
  include/SDFC_14.4.7/sdf.h,sha256=8RWP2yH8xn_sCcbqZPT443LBaPy_3SHjOxA6IL4xLzE,24996
13
8
  include/SDFC_14.4.7/sdf_list_type.h,sha256=WEq5Qmtv00-A7lmLadxC7RbFy46yLYRgg0LynCGk4PE,1350
14
- lib/SDFC_14.4.7/libsdfc.a,sha256=fIHG7DX-uLb2B-FycaAN8aI1H5fp_-fqoweEUJlVqMY,601592
9
+ sdf_xarray-0.3.1.dist-info/RECORD,,
10
+ sdf_xarray-0.3.1.dist-info/WHEEL,sha256=RKB2kgklE3rgz0xlIuKYm-O5gcSzEoMvCOiEOfbYfDs,141
11
+ sdf_xarray-0.3.1.dist-info/entry_points.txt,sha256=gP7BIQpXNg6vIf7S7p-Rw_EJZTC1X50BsVTkK7dA7g0,57
12
+ sdf_xarray-0.3.1.dist-info/METADATA,sha256=mrPI14CcIsMK4vux_WZ66CKaLWuuZKkk5nGb-ZBUpi0,7582
13
+ sdf_xarray-0.3.1.dist-info/licenses/LICENCE,sha256=0FfLVWQRQERtj0vUKjJk7-UrDp-t70Et9izWejGe4Os,1487
14
+ lib/SDFC_14.4.7/libsdfc.a,sha256=w0ir47TKx6Aow2oG81FIFJNukdUv0q-PpuciBOpm8mo,601592
15
15
  lib/SDFC_14.4.7/SDFCTargets-release.cmake,sha256=Xq-QJnH563tMRWlM5o2wdMSm9EiSKXru4U4hlR-eXlo,811
16
16
  lib/SDFC_14.4.7/SDFCTargets.cmake,sha256=dCkmSqqjFrXSW2HJxHZ4sDmPQa7uU-mBhhtdfE9SC9w,4047
17
17
  lib/SDFC_14.4.7/SDFCConfig.cmake,sha256=QQOXXHTYSEzXXckN8CCi9vuhMmirf2MrOA8b3tY4m2A,784
18
18
  lib/SDFC_14.4.7/SDFCConfigVersion.cmake,sha256=2dR0eWIHiMKSdOwWBD9kI6EA-1mvVZsn61d50hSazkE,2765
19
- sdf_xarray/_version.py,sha256=tVAyi08Mj_h5a-I-GlfgSkJxb9j3A_JL5E2Nkv6jFMk,712
19
+ sdf_xarray/_version.py,sha256=jl4nbj6ZrLINb7SYW2_PbCiEV62Yzz6EVjeJD_oEnzQ,712
20
20
  sdf_xarray/plotting.py,sha256=FJWmBas1wkwlGeP-nRILIiFPDjBXKGZ4OE4NAauKWMw,6836
21
+ sdf_xarray/dataset_accessor.py,sha256=Ihq0mFTNe_guDrHFlCkt0BhGtyRJQEWChUFGFerTKl0,2411
21
22
  sdf_xarray/sdf_interface.pyx,sha256=tYvVkp7PVrzhF4iFxUvDy4EoTSZzJmXOJ0OM_DDXG98,11635
22
- sdf_xarray/__init__.py,sha256=fSQFs6ygI7xGGkUnezPb3UhGvYn5kFqYB5pzMueEsYY,20002
23
- sdf_xarray/sdf_interface.cpython-313-darwin.so,sha256=w2s-U7wGHX62T6meIvGCylgkIbM9Ue7bcgb5ILvmIOU,401664
23
+ sdf_xarray/__init__.py,sha256=Uy4eAMuVYOKK6fFDnAK2B8u52DFCMWgfD_tvUH5aBJU,20258
24
+ sdf_xarray/sdf_interface.cpython-313-darwin.so,sha256=XKKRpks9fD20zNJ_lxPhIHd8fk3uiMwsvWzIgKqKmC0,401664
24
25
  sdf_xarray/csdf.pxd,sha256=6VCmPTbvKOQt3O-r1R1Gj-GvQJ2pOUeSRnkxgMLBvy0,4078