pyvista / pyvista-xarray

xarray DataArray accessors for PyVista
Apache License 2.0
98 stars 6 forks source link

Allow non-numeric coordinates (e.g. time) as spatial axes #65

Closed annehaley closed 4 months ago

annehaley commented 4 months ago

This PR enables selecting coordinates with non-numeric dtypes for spatial axes. Since the true values of a non-numeric coordinate cannot be used on the mesh, a representative value list is created to use on the mesh. This representative list is similar to an index list, but it is scaled according to the step value used to slice that coordinate.

For example, if a coordinate time is selected for the Z axis and a slicing of [0, 20, 4] is applied to time, then mesh.z will have the following values: [0, 4, 8, 12, 16] .

In order to be compatible with non-numeric coordinates, this PR also reorganizes how slicing is done. Expected values for slice arrays must refer to indexes rather than values in the coordinate array.

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 76.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 43.09%. Comparing base (dceabc7) to head (c1b9ef9).

Files Patch % Lines
pvxarray/accessor.py 62.50% 3 Missing :warning:
pvxarray/rectilinear.py 75.00% 1 Missing :warning:
pvxarray/structured.py 80.00% 1 Missing :warning:
pvxarray/vtk_source.py 87.50% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #65 +/- ## ========================================== + Coverage 40.12% 43.09% +2.97% ========================================== Files 11 11 Lines 481 478 -3 ========================================== + Hits 193 206 +13 + Misses 288 272 -16 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.