Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traj.animate does not work for Parcels output yet #51

Open
erikvansebille opened this issue Mar 1, 2023 · 4 comments
Open

traj.animate does not work for Parcels output yet #51

erikvansebille opened this issue Mar 1, 2023 · 4 comments

Comments

@erikvansebille
Copy link
Contributor

[Oops, I now see that I've added a message that's more relevant as an Issue when I created PR #50. SO I will rename that PR and add the message here too]

Thanks for implementing a ds.traj.animate() functionality in #46! However, I fear it's not yet working for the Parcels output in your tests/test_data/parcels.zarr file. I've added a breaking example file at #50.

The problem seems to be the default(?) 1-hour interval for the animation? The error I'm getting is

Traceback (most recent call last):
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3803, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 2263, in pandas._libs.hashtable.Int64HashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 2273, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/xarray/core/indexes.py", line 468, in sel
    indexer = self.index.get_loc(label_value)
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    raise KeyError(key) from err
KeyError: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/erik/Codes/trajan/tests/test_parcels.py", line 19, in <module>
    test_parcels_flatmesh(True, True)
  File "/Users/erik/Codes/trajan/tests/test_parcels.py", line 12, in test_parcels_flatmesh
    ds.traj.animate()
  File "/Users/erik/Codes/trajan/trajan/animation/__init__.py", line 27, in __call__
    return self.animate(*args, **kwargs)
  File "/Users/erik/Codes/trajan/trajan/animation/__init__.py", line 34, in animate
    ds = self.ds.traj.gridtime(times='1H')
  File "/Users/erik/Codes/trajan/trajan/traj2d.py", line 66, in gridtime
    da.loc[{'trajectory': t}] = f(times.to_numpy().astype(np.float64))
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/xarray/core/dataarray.py", line 216, in __setitem__
    dim_indexers = map_index_queries(self.data_array, key).dim_indexers
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/xarray/core/indexing.py", line 183, in map_index_queries
    results.append(index.sel(labels, **options))  # type: ignore[call-arg]
  File "/Users/erik/miniconda3/envs/py3_parcels/lib/python3.10/site-packages/xarray/core/indexes.py", line 470, in sel
    raise KeyError(
KeyError: "not all values found in index 'trajectory'. Try setting the `method` keyword argument (example: method='nearest')."
@gauteh
Copy link
Member

gauteh commented Mar 1, 2023

Thanks for the PR, it is great to have this test to work against as well. The animation function is extremely basic as you can see, and we should discuss how we want it to work. I would like to stay as close to xarray and matplotlib as possible, and build things in a way that makes it composable for users - so that we do not need one method with an enormous amount of more or less valid argument combinations (opendrift now). The animate method you are trying out is meant to be similar to plot in that it just gives you a basic animation with sane defaults for exploring the data.

@gauteh
Copy link
Member

gauteh commented Mar 16, 2023

I think our CI failed because of the binutils-linux-64 and gcc.. dependencies. Are these needed by parcels for JIT compiling?

@gauteh
Copy link
Member

gauteh commented Mar 16, 2023

After some more investigation I now think the issue is the use of cache from functools, for some reason this segfaults pytest.

@gauteh
Copy link
Member

gauteh commented May 12, 2023

Ref parcels issue: OceanParcels/Parcels#1319

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

No branches or pull requests

2 participants