From fedae7309ddc60601fb563cd1605b1a4ff53653e Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 18 Mar 2024 13:57:17 +0200 Subject: [PATCH] Fix dimension creation --- tests/test_xarrayfits.py | 1 + xarrayfits/fits.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_xarrayfits.py b/tests/test_xarrayfits.py index 8cfb4e9..644086c 100644 --- a/tests/test_xarrayfits.py +++ b/tests/test_xarrayfits.py @@ -98,6 +98,7 @@ def test_beam_creation(beam_cube): cmp_data = cmp_data.reshape(xds.hdu0.shape) np.testing.assert_array_equal(xds.hdu0.data, cmp_data) assert xds.hdu0.data.shape == (257, 257, 32) + assert xds.hdu0.dims == ("hdu0-0", "hdu0-1", "hdu0-2") assert xds.hdu0.attrs == { "BITPIX": -64, "EQUINOX": 2000.0, diff --git a/xarrayfits/fits.py b/xarrayfits/fits.py index 1a0f7ea..ca91d2c 100644 --- a/xarrayfits/fits.py +++ b/xarrayfits/fits.py @@ -198,7 +198,7 @@ def _xarray_from_fits_hdu( fits_filename, fits_key, fits_graph, hdu_index, shape, dtype, flat_chunks ) - dims = tuple(f"{name_prefix}{hdu_index}-{i}" for i in range(naxis, 0, -1)) + dims = tuple(f"{name_prefix}{hdu_index}-{i}" for i in range(0, naxis)) attrs = {(k, v) for k, v in sorted(hdu.header.items())} return xr.DataArray(array, dims=dims, attrs=attrs)