sal-xarray 0.1.0__tar.gz → 0.2.0__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: sal-xarray
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: SAL backend for xarray
5
5
  Author-email: Samuel Jackson <samuel.jackson@ukaea.uk>
6
6
  Maintainer-email: Samuel Jackson <samuel.jackson@ukaea.uk>
@@ -44,6 +44,14 @@ Or using `uv`:
44
44
  uv pip install sal-xarray
45
45
  ```
46
46
 
47
+ JET data access requires a VPN connection to the JDC. You will also require a config file at `~/.sal/credentials` with the following content:
48
+
49
+ ```toml
50
+ [https://sal.jetdata.eu]
51
+ user=<user-name>
52
+ password=<password>
53
+ ```
54
+
47
55
  ## Usage
48
56
 
49
57
  Open a SAL dataset using xarray:
@@ -24,6 +24,14 @@ Or using `uv`:
24
24
  uv pip install sal-xarray
25
25
  ```
26
26
 
27
+ JET data access requires a VPN connection to the JDC. You will also require a config file at `~/.sal/credentials` with the following content:
28
+
29
+ ```toml
30
+ [https://sal.jetdata.eu]
31
+ user=<user-name>
32
+ password=<password>
33
+ ```
34
+
27
35
  ## Usage
28
36
 
29
37
  Open a SAL dataset using xarray:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sal-xarray"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "SAL backend for xarray"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11, <3.13"
@@ -48,7 +48,7 @@ dev = [
48
48
  sal = "sal_xarray.main:SALBackendEntrypoint"
49
49
 
50
50
  [tool.bumpversion]
51
- current_version = "0.1.0"
51
+ current_version = "0.2.0"
52
52
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
53
53
  serialize = ["{major}.{minor}.{patch}"]
54
54
  search = "{current_version}"
@@ -100,7 +100,8 @@ class SALBackendEntrypoint(BackendEntrypoint):
100
100
  return data
101
101
 
102
102
  def open_datatree(self, filename_or_obj, *, drop_variables=None):
103
- self.open_dataset(filename_or_obj, drop_variables=drop_variables)
103
+ dataset = self.open_dataset(filename_or_obj, drop_variables=drop_variables)
104
+ return xr.DataTree(dataset)
104
105
 
105
106
  def open_groups_as_dict(self, filename_or_obj, **kwargs):
106
107
  """Open groups as a dictionary (not supported for SAL backend)."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sal-xarray
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: SAL backend for xarray
5
5
  Author-email: Samuel Jackson <samuel.jackson@ukaea.uk>
6
6
  Maintainer-email: Samuel Jackson <samuel.jackson@ukaea.uk>
@@ -44,6 +44,14 @@ Or using `uv`:
44
44
  uv pip install sal-xarray
45
45
  ```
46
46
 
47
+ JET data access requires a VPN connection to the JDC. You will also require a config file at `~/.sal/credentials` with the following content:
48
+
49
+ ```toml
50
+ [https://sal.jetdata.eu]
51
+ user=<user-name>
52
+ password=<password>
53
+ ```
54
+
47
55
  ## Usage
48
56
 
49
57
  Open a SAL dataset using xarray:
@@ -181,6 +181,45 @@ class TestSALBackendEntrypoint:
181
181
  ds = backend.open_dataset(f"sal://pulse/{shot_num}/signal_name")
182
182
  assert ds["data"].attrs["shot_id"] == shot_num
183
183
 
184
+ def test_open_datatree(self, mock_sal_client, mock_signal):
185
+ """Test opening a datatree with the SAL backend."""
186
+ backend = SALBackendEntrypoint()
187
+ dt = backend.open_datatree("sal://pulse/12345/signal_name")
188
+
189
+ # Check that a DataTree was created
190
+ assert isinstance(dt, xr.DataTree)
191
+
192
+ # Check that dataset is at root
193
+ assert "/" in dt.groups
194
+ ds = dt["/"].ds
195
+
196
+ # Check dataset contents
197
+ assert isinstance(ds, xr.Dataset)
198
+ assert "data" in ds.data_vars
199
+ assert "status" in ds.data_vars
200
+
201
+ # Check dimensions
202
+ assert "time" in ds.dims
203
+ assert ds.sizes["time"] == 5
204
+
205
+ # Check data values
206
+ np.testing.assert_array_equal(ds["data"].values, mock_signal.data)
207
+
208
+ def test_open_datatree_with_drop_variables(self, mock_sal_client):
209
+ """Test opening a datatree with drop_variables parameter."""
210
+ backend = SALBackendEntrypoint()
211
+ dt = backend.open_datatree(
212
+ "sal://pulse/12345/signal_name", drop_variables="status"
213
+ )
214
+
215
+ # Check that DataTree was created
216
+ assert isinstance(dt, xr.DataTree)
217
+
218
+ # The drop_variables parameter is passed through but not implemented
219
+ # in the current backend, so this just verifies it doesn't error
220
+ ds = dt["/"].ds
221
+ assert isinstance(ds, xr.Dataset)
222
+
184
223
 
185
224
  class TestXarrayIntegration:
186
225
  """Test integration with xarray's open_dataset function."""
@@ -194,3 +233,16 @@ class TestXarrayIntegration:
194
233
  assert isinstance(ds, xr.Dataset)
195
234
  assert "data" in ds.data_vars
196
235
  assert "status" in ds.data_vars
236
+
237
+ def test_xr_open_datatree_with_engine(self, mock_sal_client):
238
+ """Test using xr.open_datatree with engine='sal'."""
239
+ # This test requires the backend to be registered
240
+ # In practice, this happens via entry_points in pyproject.toml
241
+ dt = xr.open_datatree("sal://pulse/12345/signal_name", engine="sal")
242
+
243
+ assert isinstance(dt, xr.DataTree)
244
+ assert "/" in dt.groups
245
+ ds = dt["/"].ds
246
+ assert isinstance(ds, xr.Dataset)
247
+ assert "data" in ds.data_vars
248
+ assert "status" in ds.data_vars
File without changes
File without changes