Skip to content

Commit d4f6b98

Browse files
authored
Test FITS reader on Hubble Space Telescope data (#363)
* add test for FITS reader that checks if it can open Hubble data on AWS correctly * fix minor bug with fits reader arguments having to be specified explicitly * rename network -> requires_network to be more consistent with other test decorators * remove ToDO * release note * re-trigger CI
1 parent 7f1232f commit d4f6b98

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

docs/releases.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Bug fixes
3535

3636
- Fix bug preventing generating references for the root group of a file when a subgroup exists.
3737
(:issue:`336`, :pull:`338`) By `Tom Nicholas <https://github.com/TomNicholas>`_.
38+
- Fix bug passing arguments to FITS reader, and test it on Hubble Space Telescope data.
39+
(:pull:`363`) By `Tom Nicholas <https://github.com/TomNicholas>`_.
3840

3941
Documentation
4042
~~~~~~~~~~~~~

virtualizarr/readers/fits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def open_virtual_dataset(
4242

4343
# TODO This wouldn't work until either you had an xarray backend for FITS installed, or issue #124 is implemented to load data from ManifestArrays directly
4444
# TODO Once we have one of those we can use ``maybe_open_loadable_vars_and_indexes`` here
45-
if loadable_variables != [] or indexes != {} or decode_times:
45+
if loadable_variables or indexes:
4646
raise NotImplementedError(
4747
"Cannot load variables or indexes from FITS files as there is no xarray backend engine for FITS"
4848
)

virtualizarr/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from virtualizarr.manifests.manifest import join
1010
from virtualizarr.zarr import ZArray, ceildiv
1111

12-
network = pytest.mark.network
12+
requires_network = pytest.mark.network
1313

1414

1515
def _importorskip(

virtualizarr/tests/test_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from virtualizarr.readers.hdf import HDFVirtualBackend
1616
from virtualizarr.tests import (
1717
has_astropy,
18-
network,
1918
requires_kerchunk,
19+
requires_network,
2020
requires_s3fs,
2121
requires_scipy,
2222
)
@@ -193,7 +193,7 @@ def test_var_attr_coords(self, netcdf4_file_with_2d_coords):
193193
assert set(vds.coords) == set(expected_coords)
194194

195195

196-
@network
196+
@requires_network
197197
@requires_s3fs
198198
class TestReadFromS3:
199199
@pytest.mark.parametrize(
@@ -216,7 +216,7 @@ def test_anon_read_s3(self, indexes, hdf_backend):
216216
assert isinstance(vds[var].data, ManifestArray), var
217217

218218

219-
@network
219+
@requires_network
220220
@pytest.mark.parametrize("hdf_backend", [HDF5VirtualBackend, HDFVirtualBackend])
221221
class TestReadFromURL:
222222
@pytest.mark.parametrize(

virtualizarr/tests/test_readers/test_dmrpp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from virtualizarr import open_virtual_dataset
1212
from virtualizarr.manifests.manifest import ChunkManifest
1313
from virtualizarr.readers.dmrpp import DMRParser
14-
from virtualizarr.tests import network
14+
from virtualizarr.tests import requires_network
1515

1616
urls = [
1717
(
@@ -177,7 +177,7 @@ def dmrparser(dmrpp_xml_str: str, tmp_path: Path, filename="test.nc") -> DMRPars
177177
)
178178

179179

180-
@network
180+
@requires_network
181181
@pytest.mark.parametrize("data_url, dmrpp_url", urls)
182182
@pytest.mark.skip(reason="Fill_val mismatch")
183183
def test_NASA_dmrpp(data_url, dmrpp_url):
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
from xarray import Dataset
3+
4+
from virtualizarr import open_virtual_dataset
5+
from virtualizarr.tests import requires_kerchunk, requires_network
6+
7+
pytest.importorskip("astropy")
8+
9+
10+
@requires_kerchunk
11+
@requires_network
12+
def test_open_hubble_data():
13+
# data from https://registry.opendata.aws/hst/
14+
vds = open_virtual_dataset(
15+
"s3://stpubdata/hst/public/f05i/f05i0201m/f05i0201m_a1f.fits",
16+
reader_options={"storage_options": {"anon": True}},
17+
)
18+
19+
assert isinstance(vds, Dataset)
20+
assert list(vds.variables) == ["PRIMARY"]
21+
var = vds["PRIMARY"].variable
22+
assert var.sizes == {"y": 17, "x": 589}
23+
assert var.dtype == ">i4"

0 commit comments

Comments
 (0)