-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Implement lines using 2D xarray with common x coordinates #1282
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1282 +/- ##
==========================================
- Coverage 85.63% 85.63% -0.01%
==========================================
Files 52 52
Lines 11128 11265 +137
==========================================
+ Hits 9530 9647 +117
- Misses 1598 1618 +20 |
Here is an example using import colorcet as cc
import datashader as ds
import numpy as np
import xarray as xr
nx = 100
x = np.linspace(0.0, 1.0, nx)
nchannel = 26
channel = [chr(i) for i in range(65, 65+nchannel)]
rng = np.random.default_rng(8321)
data = rng.normal(loc=np.arange(nchannel).reshape((-1, 1)), scale=0.5, size=(nchannel, nx))
xr_ds = xr.Dataset(
data_vars=dict(
some_name=(("channel", "x"), data),
value=("channel", np.arange(nchannel))
),
coords=dict(
channel=("channel", channel),
x=("x", x),
),
)
print(xr_ds)
canvas = ds.Canvas(plot_height=600, plot_width=800)
agg = canvas.line(source=xr_ds, x="x", y="some_name", agg=ds.first("value"))
im = ds.transfer_functions.shade(agg, how="linear", cmap=cc.glasbey_cool) which produces
|
144f7dc
to
c6e5fd3
Compare
This now works for xarray DataArrays that are backed by
but not for dask-cupy arrays. |
Also note that the 2D |
This is a work in progress to implement datashading lines from a 2D xarray that has common
x
coordinates, as described in issue #1278.So far it only works for
count
andany
reductions, with and without Dask but only on the CPU not GPU. Further work is underway to support other simple reductions, categorical andwhere
reductions, antialiasing, CUDA, etc.There is a limitation when using dask chunking of the 2D array in the
x
direction in that the line segments between chunks are not rendered. This is the same limitation that occurs in other datashader line glyphs that similarly chunk along arrays, and no attempt will be made to address the limitation in this PR.This work is part of a CZI Round 5 grant.