uda-xarray 0.2.1__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uda-xarray
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: UDA backend for xarray
5
5
  Author-email: Samuel Jackson <samuel.jackson@ukaea.uk>
6
6
  Maintainer-email: Samuel Jackson <samuel.jackson@ukaea.uk>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "uda-xarray"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "UDA backend for xarray"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9, <3.13"
@@ -47,7 +47,7 @@ dev = [
47
47
  uda = "uda_xarray.main:UDABackendEntrypoint"
48
48
 
49
49
  [tool.bumpversion]
50
- current_version = "0.2.1"
50
+ current_version = "0.2.3"
51
51
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
52
52
  serialize = ["{major}.{minor}.{patch}"]
53
53
  search = "{current_version}"
@@ -1,3 +1,4 @@
1
+ import pytest
1
2
  import xarray as xr
2
3
  import numpy as np
3
4
  import pyuda
@@ -74,7 +75,7 @@ def test_open_uda_dataset_2d(mocker):
74
75
  mock_client.get.assert_called_once_with("AYE_TE", 30421)
75
76
 
76
77
  assert ds["data"].name == "data"
77
- assert ds["data"].dims == ("channel", "time")
78
+ assert ds["data"].dims == ("time", "channel")
78
79
  assert "time" in ds.coords
79
80
  assert "channel" in ds.coords
80
81
 
@@ -229,7 +230,7 @@ def test_open_datatree_2d(mocker):
229
230
  # Access the dataset from the root node
230
231
  ds = dt.to_dataset()
231
232
  assert ds["data"].name == "data"
232
- assert ds["data"].dims == ("channel", "time")
233
+ assert ds["data"].dims == ("time", "channel")
233
234
  assert "time" in ds.coords
234
235
  assert "channel" in ds.coords
235
236
 
@@ -272,3 +273,23 @@ def test_open_datatree_video(mocker):
272
273
  assert ds["data"].dims == ("time", "height", "width")
273
274
  assert "time" in ds.coords
274
275
  assert ds.sizes["time"] == 3
276
+
277
+
278
+ @pytest.mark.skip(reason="Requires access to real UDA server with video data")
279
+ def test_open_uda_dataset_video_frame(mocker):
280
+ ds = xr.open_dataset(
281
+ "uda://rba:30421", engine="uda", drop_variables=None, frame_number=1
282
+ )
283
+ assert ds["data"].name == "data"
284
+ assert ds["data"].dims == ("time", "height", "width")
285
+ assert "time" in ds.coords
286
+ assert ds.sizes["time"] == 1
287
+
288
+
289
+ @pytest.mark.skip(reason="Requires access to real UDA server with video data")
290
+ def test_real_data_2d():
291
+ ds = xr.open_dataset("uda://AYE_TE:30421", engine="uda")
292
+ assert ds["data"].name == "data"
293
+ assert ds["data"].dims == ("time", "radial_index")
294
+ assert "time" in ds.coords
295
+ assert "radial_index" in ds.coords
@@ -3,6 +3,7 @@
3
3
  from enum import Enum
4
4
  from typing import Optional
5
5
 
6
+ import os
6
7
  import numpy as np
7
8
  import pyuda
8
9
  import xarray as xr
@@ -10,6 +11,15 @@ from mast.mast_client import ListType
10
11
  from xarray.backends import BackendEntrypoint
11
12
 
12
13
 
14
+ # Set up UDA environment variables with defaults if not already set. This is required for
15
+ # the pyuda client to work correctly outside of Freia.
16
+ os.environ["UDA_HOST"] = os.environ.get("UDA_HOST", "uda2.mast.l")
17
+ os.environ["UDA_META_PLUGINNAME"] = os.environ.get("UDA_META_PLUGINNAME", "MASTU_DB")
18
+ os.environ["UDA_METANEW_PLUGINNAME"] = os.environ.get(
19
+ "UDA_METANEW_PLUGINNAME", "MAST_DB"
20
+ )
21
+
22
+
13
23
  class SignalType(str, Enum):
14
24
  """Enum for UDA signal types."""
15
25
 
@@ -30,6 +40,7 @@ class UDABackendEntrypoint(BackendEntrypoint):
30
40
  *,
31
41
  drop_variables=None,
32
42
  frame_number: Optional[int] = None, # noqa: F821
43
+ **kwargs,
33
44
  ) -> xr.Dataset:
34
45
  """Open a UDA dataset given a signal name and shot number.
35
46
 
@@ -81,7 +92,7 @@ class UDABackendEntrypoint(BackendEntrypoint):
81
92
 
82
93
  # Rename time dimension to just "time" if we can.
83
94
  if signal.time.label in dim_data:
84
- dim_data["time"] = dim_data.pop(signal.time.label)
95
+ dim_data = {"time": dim_data.pop(signal.time.label), **dim_data}
85
96
 
86
97
  item = xr.DataArray(
87
98
  signal.data,
@@ -151,15 +162,17 @@ class UDABackendEntrypoint(BackendEntrypoint):
151
162
  return SignalType.IMAGE
152
163
  return SignalType.SIGNAL
153
164
 
154
- def open_datatree(self, filename_or_obj, *, drop_variables=None):
155
- dataset = self.open_dataset(filename_or_obj, drop_variables=drop_variables)
165
+ def open_datatree(self, filename_or_obj, *, drop_variables=None, **kwargs):
166
+ dataset = self.open_dataset(
167
+ filename_or_obj, drop_variables=drop_variables, **kwargs
168
+ )
156
169
  return xr.DataTree(dataset)
157
170
 
158
171
  def open_groups_as_dict(self, filename_or_obj, **kwargs):
159
172
  """Open groups as a dictionary (not supported for UDA backend)."""
160
173
  raise NotImplementedError("UDA backend does not support opening groups")
161
174
 
162
- open_dataset_parameters = ["filename_or_obj", "drop_variables"]
175
+ open_dataset_parameters = ["filename_or_obj", "drop_variables", "frame_number"]
163
176
  supports_groups = True
164
177
 
165
178
  def guess_can_open(self, filename_or_obj):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uda-xarray
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: UDA backend for xarray
5
5
  Author-email: Samuel Jackson <samuel.jackson@ukaea.uk>
6
6
  Maintainer-email: Samuel Jackson <samuel.jackson@ukaea.uk>
File without changes
File without changes
File without changes