Skip to content

Update uvh5.py, pyuvdata throws error when converting to MS in prev. version#6

Open
joesbright wants to merge 1 commit into
MydonSolutions:masterfrom
joesbright:master
Open

Update uvh5.py, pyuvdata throws error when converting to MS in prev. version#6
joesbright wants to merge 1 commit into
MydonSolutions:masterfrom
joesbright:master

Conversation

@joesbright

Copy link
Copy Markdown

Error from pyuvdata is:

File "/mnt/buf0/jbright/BLRI_STAMP/uvh52ms.py", line 8, in
uv.read(inp)
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/uvdata/uvdata.py", line 11139, in read
self.read_uvh5(
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/uvdata/uvdata.py", line 9883, in read_uvh5
uvh5_obj.read_uvh5(filename, **kwargs)
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/uvdata/uvh5.py", line 1051, in read_uvh5
self._read_header(
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/uvdata/uvh5.py", line 680, in _read_header
self._read_header_with_fast_meta(filename, **kwargs)
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/uvdata/uvh5.py", line 502, in _read_header_with_fast_meta
self.telescope = Telescope.from_hdf5(
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/telescopes.py", line 863, in from_hdf5
setattr(tel_obj, tel_attr, getattr(meta, attr))
File "/usr/lib/python3.10/functools.py", line 981, in get
val = self.func(instance)
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/pyuvdata/utils/io/hdf5.py", line 677, in antenna_names
return np.char.decode(self.header["antenna_names"][:], encoding="utf8")
File "/mnt/buf0/jbright/BLRI_STAMP/BLRI_STAMP/lib/python3.10/site-packages/numpy/_core/strings.py", line 530, in decode
vec_string(a, np.object, 'decode', _clean_args(encoding, errors)),
TypeError: string operation on non-string array

@radonnachie

radonnachie commented Oct 23, 2024

Copy link
Copy Markdown
Contributor

Shotalot Joe!

I'm hesitant to throw the baby out... need that "S4" string to represent the maximum string length still..
does the following work as well? If so I'd prefer it.

uvh5g_header.create_dataset("antenna_names", data=numpy.array(antenna_names).astype(f"S{max(map(len, antenna_names))}"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants