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

shade function of datashader.transfer_functions does not implement 'span' parameter correctly. #664

Closed
xuanvinhilb opened this issue Oct 19, 2018 · 2 comments

Comments

@xuanvinhilb
Copy link

Description

If we do not provide the span parameter, the function works correctly. For example:
img = ds.transfer_functions.shade(agg, cmap=customColorMap, how='linear')
However, the function behaves incorrectly when the span parameter is provided. For example:
img = ds.transfer_functions.shade(agg, cmap=customColorMap, how='linear', span = [valMin ,valMax])
This is because the data has been shifted with the offset = min(agg). However, the span value is not shifted accordingly. One way to fix it is to shift the span value

suggested fix:

In the function _interpolate(), we modify the function as follows:
CHANGE FROM:
if span is None:
span = [np.nanmin(data), np.nanmax(data)]
else:
if how == 'eq_hist':
# For eq_hist to work with span, we'll need to store the histogram
# from the data and then apply it to the span argument.
raise ValueError("span is not (yet) valid to use with eq_hist")
span = interpolater(span,0)

TO:
if span is None:
span = [np.nanmin(data), np.nanmax(data)]
else:
if how == 'eq_hist':
# For eq_hist to work with span, we'll need to store the histogram
# from the data and then apply it to the span argument.
raise ValueError("span is not (yet) valid to use with eq_hist")
if 'offset' in locals():
span = interpolater(span - offset,0)
else:
span = interpolater(span,0)

@jbednar
Copy link
Member

jbednar commented Oct 19, 2018

Duplicate of #368 . Can you try what is suggested there, and if it helps make a PR so that we can review this fix?

@jbednar jbednar closed this as completed Oct 19, 2018
@xuanvinhilb
Copy link
Author

I read the thread 368 already. I did not check whether it fix my problem. However, what I suggested work for me.

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