titusjan / argos

Argos: a data viewer that can read HDF5, NetCDF4, and other file formats.
GNU General Public License v3.0
176 stars 26 forks source link

TypeError when trying to open image plot #25

Closed mfurseman closed 2 years ago

mfurseman commented 2 years ago

I've got a file which displays under the table view fine, however when opening the image plot I get an error:

2022-07-26 13:56:37.178 :               abstract.py:230  : ERROR   : Error while drawing the inspector: Text reading control character must be a single unicode character or None; but got: ', ' ----
2022-07-26 13:56:37.178 :               abstract.py:231  : ERROR   : Text reading control character must be a single unicode character or None; but got: ', '
Traceback (most recent call last):
  File "/home/foo/.local/lib/python3.9/site-packages/argos/inspector/abstract.py", line 201, in updateContents
    self._drawContents(reason=reason, initiator=initiator)
  File "/home/foo/.local/lib/python3.9/site-packages/argos/inspector/pgplugins/imageplot2d.py", line 557, in _drawContents
    self.config.updateTarget()
  File "/home/foo/.local/lib/python3.9/site-packages/argos/config/abstractcti.py", line 288, in updateTarget
    child.updateTarget(level = level + 1)
  File "/home/foo/.local/lib/python3.9/site-packages/argos/config/abstractcti.py", line 288, in updateTarget
    child.updateTarget(level = level + 1)
  File "/home/foo/.local/lib/python3.9/site-packages/argos/config/abstractcti.py", line 286, in updateTarget
    self._updateTargetFromNode()
  File "/home/foo/.local/lib/python3.9/site-packages/argos/inspector/pgplugins/pgctis.py", line 972, in _updateTargetFromNode
    lut = self.data.rgb_uint8_array
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 346, in rgb_uint8_array
    self.load_rgba_uint8_array()
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 366, in load_rgba_uint8_array
    rgb_ints = self._read_rgb_uint8_file(file_name)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 328, in _read_rgb_uint8_file
    rgb_floats = load_rgb_floats(file_name)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/misc.py", line 87, in load_rgb_floats
    array = np.loadtxt(source_file, delimiter=delimiter, dtype=dtype, **kwargs)
  File "/home/foo/.local/lib/python3.9/site-packages/numpy/lib/npyio.py", line 1308, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "/home/foo/.local/lib/python3.9/site-packages/numpy/lib/npyio.py", line 979, in _read
    arr = _load_from_filelike(
TypeError: Text reading control character must be a single unicode character or None; but got: ', '
2022-07-26 13:56:37.192 :                   misc.py:114  : CRITICAL: Bug: uncaught TypeError
titusjan commented 2 years ago

Which Argos and library versions do you have? Can you please copy/paste the versions from the about box?

Can you somehow give me access to this file?

Looking at the error, it seem to me that this error is related to reading the color maps. What happens if you select a different color map by clicking on the color map selection dialog. See red circle in screen shot.

Screenshot 2022-07-26 at 15 10 41
mfurseman commented 2 years ago

image

I'm unable to choose a different colourmap as the error is fatal (unless I can manually put this in the setting configuration somehow?). cmlib is also yours right!?

mfurseman commented 2 years ago

With QT_API=pyside2 python3.9 -m argos filename.nc I'm able to keep the GUI open, although the Exception trace is still the same on all the color map fields.

titusjan commented 2 years ago

Yes cmlib is also mine.

So does this error occur only for that specific file? Or does it occur with any file?

titusjan commented 2 years ago

What happens if you run the cmlib_demo command? See here

mfurseman commented 2 years ago

I get the same error, so that ties it down to something in cmlib. Are you happy to continue discussing here?

$ ~/.local/bin/cmlib_demo
Traceback (most recent call last):
  File "/home/foo/.local/bin/cmlib_demo", line 8, in <module>
    sys.exit(main())
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/demo.py", line 293, in main
    win = DemoWindow(cmLibModel=cmLibModel)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/demo.py", line 226, in __init__
    self.updateSelectedLabel(self.selectionWidget.getCurrentColorMap())
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/demo.py", line 248, in updateSelectedLabel
    self.updateImageLabel(colorMap)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/demo.py", line 255, in updateImageLabel
    pixMap = colorizeImageArray(self._imageArray, colorMap=colorMap,
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/demo.py", line 134, in colorizeImageArray
    rgba_arr = colorMap.rgba_uint8_array
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 357, in rgba_uint8_array
    self.load_rgba_uint8_array()
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 366, in load_rgba_uint8_array
    rgb_ints = self._read_rgb_uint8_file(file_name)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/cmap.py", line 328, in _read_rgb_uint8_file
    rgb_floats = load_rgb_floats(file_name)
  File "/home/foo/.local/lib/python3.9/site-packages/cmlib/misc.py", line 87, in load_rgb_floats
    array = np.loadtxt(source_file, delimiter=delimiter, dtype=dtype, **kwargs)
  File "/home/foo/.local/lib/python3.9/site-packages/numpy/lib/npyio.py", line 1308, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "/home/foo/.local/lib/python3.9/site-packages/numpy/lib/npyio.py", line 979, in _read
    arr = _load_from_filelike(
TypeError: Text reading control character must be a single unicode character or None; but got: ', '
titusjan commented 2 years ago

Yes we can continue discussing here. I can try to reproduce it later this evening.

Do you use Linux or MacOS?

mfurseman commented 2 years ago

This is Linux under WSL, rendering done by Windows 11 Wayland backend.

uname -a
Linux Desktop 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
titusjan commented 2 years ago

Accidentally pressed the close button a bit too early, but I have fixed the issue. I could reproduce it when I upgraded Numpy to version 1.23.1. It was an easy fix.

I have made a new release of cmlib: version 1.1.3. If you update to that version it should work. Please let me know if it doesn't.

mfurseman commented 2 years ago

Installed cmlib-1.1.3 and we're back in business!

image

Thanks for the prompt assistance. Argos is my favourite NetCDF viewer, everything you need and nothing you don't.