Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test FITS reader on Hubble Space Telescope data #363

Merged
merged 7 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Bug fixes

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

Documentation
~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion virtualizarr/readers/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def open_virtual_dataset(

# 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
# TODO Once we have one of those we can use ``maybe_open_loadable_vars_and_indexes`` here
if loadable_variables != [] or indexes != {} or decode_times:
if loadable_variables or indexes:
raise NotImplementedError(
"Cannot load variables or indexes from FITS files as there is no xarray backend engine for FITS"
)
Expand Down
2 changes: 1 addition & 1 deletion virtualizarr/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from virtualizarr.manifests.manifest import join
from virtualizarr.zarr import ZArray, ceildiv

network = pytest.mark.network
requires_network = pytest.mark.network


def _importorskip(
Expand Down
6 changes: 3 additions & 3 deletions virtualizarr/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from virtualizarr.readers.hdf import HDFVirtualBackend
from virtualizarr.tests import (
has_astropy,
network,
requires_kerchunk,
requires_network,
requires_s3fs,
requires_scipy,
)
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_var_attr_coords(self, netcdf4_file_with_2d_coords):
assert set(vds.coords) == set(expected_coords)


@network
@requires_network
@requires_s3fs
class TestReadFromS3:
@pytest.mark.parametrize(
Expand All @@ -216,7 +216,7 @@ def test_anon_read_s3(self, indexes, hdf_backend):
assert isinstance(vds[var].data, ManifestArray), var


@network
@requires_network
@pytest.mark.parametrize("hdf_backend", [HDF5VirtualBackend, HDFVirtualBackend])
class TestReadFromURL:
@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions virtualizarr/tests/test_readers/test_dmrpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from virtualizarr import open_virtual_dataset
from virtualizarr.manifests.manifest import ChunkManifest
from virtualizarr.readers.dmrpp import DMRParser
from virtualizarr.tests import network
from virtualizarr.tests import requires_network

urls = [
(
Expand Down Expand Up @@ -177,7 +177,7 @@ def dmrparser(dmrpp_xml_str: str, tmp_path: Path, filename="test.nc") -> DMRPars
)


@network
@requires_network
@pytest.mark.parametrize("data_url, dmrpp_url", urls)
@pytest.mark.skip(reason="Fill_val mismatch")
def test_NASA_dmrpp(data_url, dmrpp_url):
Expand Down
23 changes: 23 additions & 0 deletions virtualizarr/tests/test_readers/test_fits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
from xarray import Dataset

from virtualizarr import open_virtual_dataset
from virtualizarr.tests import requires_kerchunk, requires_network

pytest.importorskip("astropy")


@requires_kerchunk
@requires_network
def test_open_hubble_data():
# data from https://registry.opendata.aws/hst/
vds = open_virtual_dataset(
"s3://stpubdata/hst/public/f05i/f05i0201m/f05i0201m_a1f.fits",
reader_options={"storage_options": {"anon": True}},
)

assert isinstance(vds, Dataset)
assert list(vds.variables) == ["PRIMARY"]
var = vds["PRIMARY"].variable
assert var.sizes == {"y": 17, "x": 589}
assert var.dtype == ">i4"
Loading