Kitware / pan3d

Other
10 stars 2 forks source link

DateTime related errors loading ESGF Example #102

Closed johnkit closed 1 month ago

johnkit commented 1 month ago

1. Pan3D Viewer

Running pan3d-viewer --config_path examples/example_config_esgf.json triggers this error message

    TypeError: SetZCoordinates argument 1: method requires a vtkDataArray, a vtkStringArray was provided.
Full Traceback
Traceback (most recent call last):
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/bin/pan3d-viewer", line 8, in 
    sys.exit(serve())
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/serve_viewer.py", line 27, in serve
    builder.viewer.start(debug=args.debug)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_builder.py", line 66, in viewer
    self._viewer = DatasetViewer(
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/trame/decorators/klass.py", line 44, in decorated_constructor
    instance = klass(*args, **kwargs)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 91, in __init__
    self._mesh_changed()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 727, in _mesh_changed
    self.apply_and_render()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 427, in apply_and_render
    self.run_as_async(self.plot_mesh)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 464, in run_as_async
    function()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 405, in plot_mesh
    mesh = self.builder.mesh
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_builder.py", line 377, in mesh
    return self._algorithm.mesh
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/vtk_source.py", line 211, in mesh
    self._compute_mesh()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/vtk_source.py", line 267, in _compute_mesh
    self._mesh = self.persisted_data.pyvista.mesh(
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/accessor.py", line 83, in mesh
    return meth(self, x=x, y=y, z=z, order=order, component=component)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/rectilinear.py", line 29, in mesh
    self._mesh.z = self._get_array(z)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pyvista/core/grid.py", line 405, in z
    self.SetZCoordinates(convert_array(coords))
TypeError: SetZCoordinates argument 1: method requires a vtkDataArray, a vtkStringArray was provided.

2. JupyterLab (local)

Running the import_config_esgf.ipynb notebook locally triggers this error:

    TypeError: '>=' not supported between instances of 'cftime._cftime.Datetime360Day' and 'int'
Full Traceback

ERROR:root:Exception raised by task =  exception=TypeError("'>=' not supported between instances of 'cftime._cftime.Datetime360Day' and 'int'")>
Traceback (most recent call last):
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/trame_server/core.py", line 700, in on_done
    task.result()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/wslink/backends/aiohttp/__init__.py", line 133, in start
    port_callback(self.get_port())
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/trame_server/protocol.py", line 96, in port_callback
    self.server.controller.on_server_ready(**self.server.state.to_dict())
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/trame_server/state.py", line 151, in to_dict
    self.flush()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/trame_server/state.py", line 246, in flush
    coroutine = callback(**self._pushed_state)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 806, in _on_change_da_coordinates
    self.builder._auto_select_slicing(bounds, steps)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_builder.py", line 468, in _auto_select_slicing
    self.slicing = {
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_builder.py", line 368, in slicing
    self._viewer._mesh_changed()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_viewer.py", line 709, in _mesh_changed
    da = self.builder.data_array
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pan3d/dataset_builder.py", line 187, in data_array
    return self._algorithm.sliced_data_array
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/vtk_source.py", line 199, in sliced_data_array
    self._compute_sliced_data_array()
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/pvxarray/vtk_source.py", line 249, in _compute_sliced_data_array
    sliced_array = np.where(np.logical_and(c >= s[0], c <= s[1]))[0]
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/xarray/core/_typed_ops.py", line 290, in __ge__
    return self._binary_op(other, operator.ge)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/xarray/core/dataarray.py", line 4687, in _binary_op
    f(self.variable, other_variable_or_arraylike)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/xarray/core/_typed_ops.py", line 630, in __ge__
    return self._binary_op(other, operator.ge)
  File "/home/local/KHQ/john.tourtellott/.py3-venv/pan3d/lib/python3.9/site-packages/xarray/core/variable.py", line 2411, in _binary_op
    f(self_data, other_data) if not reflexive else f(other_data, self_data)
TypeError: '>=' not supported between instances of 'cftime._cftime.Datetime360Day' and 'int'

  

3. JupyterHub

Running the import_config_esgf.ipynb notebook on kitware.2i2c.cloud triggers this error.

    TypeError: <class 'cftime._cftime.Datetime360Day'> is not convertible to datetime, at position 0

The cloud version is using release 0.8.8, so we need a new release once this is fixed.

johnkit commented 1 month ago

I think the only bug was my naivete. Once I updated to the current pyvista-xarray, the problems loading this data were resolved. And my guess is that the JupyterHub instance will work once we update its container image.