sdf-xarray 0.3.0__cp312-cp312-win_amd64.whl → 0.3.1__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 +0 -0
- sdf_xarray/__init__.py +9 -2
- sdf_xarray/_version.py +3 -3
- sdf_xarray/dataset_accessor.py +73 -0
- sdf_xarray/sdf_interface.cp312-win_amd64.pyd +0 -0
- {sdf_xarray-0.3.0.dist-info → sdf_xarray-0.3.1.dist-info}/METADATA +1 -1
- {sdf_xarray-0.3.0.dist-info → sdf_xarray-0.3.1.dist-info}/RECORD +10 -9
- {sdf_xarray-0.3.0.dist-info → sdf_xarray-0.3.1.dist-info}/WHEEL +0 -0
- {sdf_xarray-0.3.0.dist-info → sdf_xarray-0.3.1.dist-info}/entry_points.txt +0 -0
- {sdf_xarray-0.3.0.dist-info → sdf_xarray-0.3.1.dist-info}/licenses/LICENCE +0 -0
lib/SDFC_14.4.7/sdfc.lib
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
|
|
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.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 3,
|
|
31
|
+
__version__ = version = '0.3.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 3, 1)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
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)
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdf-xarray
|
|
3
|
-
Version: 0.3.
|
|
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
|
|
@@ -6,19 +6,20 @@ 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=
|
|
9
|
+
lib/SDFC_14.4.7/sdfc.lib,sha256=uZ_NxOWWW3b8rXGwRRrfwB3xekjNoh9lC2aJcufRRf4,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=
|
|
15
|
-
sdf_xarray/_version.py,sha256=
|
|
14
|
+
sdf_xarray/__init__.py,sha256=eT5Ub0mLwSZkNytmHNmbkVH-jwa8aSWd-M0yum-u2VQ,20811
|
|
15
|
+
sdf_xarray/_version.py,sha256=54WgTglj_0PywooMasYi8FetaJNx9UMTnqWXa0xCi1g,746
|
|
16
16
|
sdf_xarray/csdf.pxd,sha256=ADPjAuHsodAvdOz96Z_XlFF7VL3KmVaXcTifWDP3rK0,4205
|
|
17
|
+
sdf_xarray/dataset_accessor.py,sha256=TvnVMBefnT1d94Bkllhd-__O3ittzpaVjZKfze-3WQ4,2484
|
|
17
18
|
sdf_xarray/plotting.py,sha256=PnbEspR4XkA5SHkpoFKA2G7BYj5J3mVgR1TEeGol6Vw,7041
|
|
18
|
-
sdf_xarray/sdf_interface.cp312-win_amd64.pyd,sha256=
|
|
19
|
+
sdf_xarray/sdf_interface.cp312-win_amd64.pyd,sha256=O9w7_bMHKSsu2ARW7U4dMzT7ByKRDEFT5WFMezB8gt4,360960
|
|
19
20
|
sdf_xarray/sdf_interface.pyx,sha256=PFC6upg14OZBqiGInLgBoxztIIKBk-HOh3WC9Ro4YUw,11975
|
|
20
|
-
sdf_xarray-0.3.
|
|
21
|
-
sdf_xarray-0.3.
|
|
22
|
-
sdf_xarray-0.3.
|
|
23
|
-
sdf_xarray-0.3.
|
|
24
|
-
sdf_xarray-0.3.
|
|
21
|
+
sdf_xarray-0.3.1.dist-info/METADATA,sha256=mrPI14CcIsMK4vux_WZ66CKaLWuuZKkk5nGb-ZBUpi0,7582
|
|
22
|
+
sdf_xarray-0.3.1.dist-info/WHEEL,sha256=chqeLhPBtPdrOoreR34YMcofSk3yWDQhkrsDJ2n48LU,106
|
|
23
|
+
sdf_xarray-0.3.1.dist-info/entry_points.txt,sha256=gP7BIQpXNg6vIf7S7p-Rw_EJZTC1X50BsVTkK7dA7g0,57
|
|
24
|
+
sdf_xarray-0.3.1.dist-info/licenses/LICENCE,sha256=aHWuyELjtzIL1jTXFHTbI3tr9vyVyhnw3I9_QYPdEX8,1515
|
|
25
|
+
sdf_xarray-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|