pywwt icon indicating copy to clipboard operation
pywwt copied to clipboard

Error plotting table layers with 200,000 rows

Open astrofrog opened this issue 3 years ago • 2 comments

The following example now crashes:

import numpy as np
from astropy.table import Table
from pywwt.qt import WWTQtClient

N = 200_000

table = Table()
table['x'] = np.random.uniform(-10, 10, N)
table['y'] = np.random.uniform(-10, 10, N)
table['z'] = np.random.uniform(-10, 10, N)

wwt = WWTQtClient(block_until_ready=True)
wwt.wait(5)
wwt.set_view('milky way')
wwt.layers.add_table_layer(table=table, frame='Sky',
                           x_att='x', y_att='y', z_att='z', xyz_unit='pc')
wwt.wait()

The error is:

Traceback (most recent call last):
  File "/Users/tom/Downloads/glue_dataverse/data/test.py", line 15, in <module>
    wwt.layers.add_table_layer(table=table, frame='Sky',
  File "/Users/tom/Code/pywwt/pywwt/layers.py", line 241, in add_table_layer
    layer = TableLayer(self._parent, table=table,
  File "/Users/tom/Code/pywwt/pywwt/layers.py", line 424, in __init__
    self._on_trait_change({'name': 'color', 'new': self.color})
  File "/Users/tom/Code/pywwt/pywwt/layers.py", line 847, in _on_trait_change
    self.parent._send_msg(event='table_layer_set',
  File "/Users/tom/Code/pywwt/pywwt/core.py", line 249, in _send_msg
    raise ViewerNotAvailableError()
pywwt.core.ViewerNotAvailableError: cannot complete the operation because the WWT viewer isn't responding

As discussed with @pkgw this is because the table serialization/deserialization takes more than the threshold for testing if the viewer is 'live'. Increasing that threshold does indeed make the error go away.

astrofrog avatar Jul 27 '21 06:07 astrofrog