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

Use the correct fits image dtype #531

Merged
merged 3 commits into from
Dec 5, 2024
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
4 changes: 2 additions & 2 deletions kerchunk/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
16: ">i2",
32: ">i4",
64: ">i8",
-32: "float32",
-64: "float64",
-32: ">f4",
-64: ">f8",
} # always bigendian


Expand Down
14 changes: 14 additions & 0 deletions tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
var = os.path.join(testdir, "variable_length_table.fits")


def test_image():
# this one directly hits a remote server - should cache?
url = "https://fits.gsfc.nasa.gov/samples/WFPC2ASSNu5780205bx.fits"
out = kerchunk.fits.process_file(url)
m = fsspec.get_mapper("reference://", fo=out, remote_protocol="https")
g = zarr.open(m)
arr = g["PRIMARY"][:]
with fsspec.open(
"https://fits.gsfc.nasa.gov/samples/WFPC2ASSNu5780205bx.fits"
) as f:
hdu = fits.getdata(f)
assert (hdu == arr).all()


def test_ascii_table():
# this one directly hits a remote server - should cache?
url = "https://fits.gsfc.nasa.gov/samples/WFPC2u5780205r_c0fx.fits"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_grib.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def test_parse_grib_idx_invalid_url():


def test_parse_grib_idx_no_file():
with pytest.raises(FileNotFoundError):
with pytest.raises((FileNotFoundError, PermissionError)):
# the url is spelled wrong
parse_grib_idx(
"s3://noaahrrr-bdp-pds/hrrr.20220804/conus/hrrr.t01z.wrfsfcf01.grib2",
Expand Down
Loading