New error in uvfits writer with astropy 8.0.3
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
Research direction
The traceback points to src/pyuvdata/uvdata/uvfits.py:1200, where fits.GroupData is built; start there and trace the column names with trailing spaces to their definitions. Compare them with the numpy recarray names after astropy strips whitespace (failing key 'UU '). Read write_uvfits and run the uvfits write/round-trip tests under astropy 8.0.3. Done means the KeyError is gone, tests pass, and you note whether to strip whitespace locally or report upstream.
Written by the indexing model from the issue text.
Description
A change in astropy 8.0.3 (related PR: https://github.com/astropy/astropy/pull/20514) is causing a new error in our uvfits reader.
I am not sure if this is more a case of exposing an issue we had vs their change being a bug. The error is triggered because we have been carrying the field names with extra white space to match what is actually written in a uvfits file. Internally, astropy converts to a numpy rec array which strips the white space. But the new code that was introduced in the PR noted above breaks because the numpy rec array field names do not match the parameter names passed to the group constructor.
I can confirm that removing the whitespace in our code prevents the error, not sure if I should report this to astropy or not -- kind of depends if we think this is an error on our side vs theirs.
src/pyuvdata/uvdata/uvdata.py:11318: in write_uvfits
uvfits_obj.write_uvfits(filename, **kwargs)
src/pyuvdata/uvdata/uvfits.py:1200: in write_uvfits
hdu = fits.GroupData(
../../../miniforge3/envs/rasg/lib/python3.14/site-packages/astropy/io/fits/hdu/groups.py:219: in __new__
coldefs._arrays[idx] = self.field(idx)
^^^^^^^^^^^^^^^
../../../miniforge3/envs/rasg/lib/python3.14/site-packages/astropy/io/fits/fitsrec.py:769: in field
field = _get_recarray_field(base, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../miniforge3/envs/rasg/lib/python3.14/site-packages/astropy/io/fits/fitsrec.py:1519: in _get_recarray_field
field = np.recarray.field(array, key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = rec.array([( 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.75333333, 257., 1., 1., 1., 1., 2.00071335, 0.065323...8'), ('ANTENNA2', '<f8'), ('SUBARRAY', '<f8'), ('INTTIM', '<f8'), ('LST', '<f8'), ('DATA', '<f8', (1, 1, 1, 3, 2, 3))])
attr = 'UU ', val = None
def field(self, attr, val=None):
if isinstance(attr, int):
names = ndarray.__getattribute__(self, 'dtype').names
attr = names[attr]
fielddict = ndarray.__getattribute__(self, 'dtype').fields
> res = fielddict[attr][:2]
^^^^^^^^^^^^^^^
E KeyError: 'UU '
../../../miniforge3/envs/rasg/lib/python3.14/site-packages/numpy/_core/records.py:545: KeyError
- Dominant language
- Python
- Stars
- 103
- Forks
- 40
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RadioAstronomySoftwareGroup/pyuvdata
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
RadioAstronomySoftwareGroup/pyuvdata#1750 ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 Half a day Newbie friendliness 48/100
RadioAstronomySoftwareGroup/pyuvdata#1749 ·
Maintainers usually reply within 3 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
RadioAstronomySoftwareGroup/pyuvdata#1748 ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
RadioAstronomySoftwareGroup/pyuvdata#1743 ·
Maintainers usually reply within 3 days
-
Unpin Python 3.15Opencontinuous_integration technical debt
Difficulty 2/5 Under an hour Newbie friendliness 18/100
RadioAstronomySoftwareGroup/pyuvdata#1742 ·
Maintainers usually reply within 3 days
All issues in RadioAstronomySoftwareGroup/pyuvdata
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GoogleCloudPlatform/professional-services-data-validator#1899 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day