-
Notifications
You must be signed in to change notification settings - Fork 25
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_map normalizes vmin and vmax instead of recalculating them from normalized zdata #64
_shade_map normalizes vmin and vmax instead of recalculating them from normalized zdata #64
Conversation
Hey, @maxhollmann, thanks, nice to hear! I had a quick look but I could not reproduce the behaviour you're describing... Here's my quick test that does exactly what I would expect it to do: code to reproducefrom eomaps import MapsGrid
import numpy as np
lon, lat = np.meshgrid(np.linspace(-89, 89, 500), np.linspace(-89, 89, 500))
mg = MapsGrid(1, 2, figsize=(10, 5), wspace=0, left=0.02)
mg.add_feature.preset.coastline()
mg.set_data(np.sqrt(lon**2 + lat**2), lon, lat)
mg.set_shape.shade_raster()
mg.set_plot_specs(vmin=25, vmax=100)
mg[0,0].set_classify_specs("EqualInterval", k=10)
mg.plot_map()
mg.add_colorbar(histbins=50)
for m in mg:
m.cb.pick.attach.annotate() |
Here's an example that reproduces what I described: from eomaps import Maps
import numpy as np
lon, lat = np.meshgrid(np.linspace(-89, 89, 500), np.linspace(-89, 89, 500))
data = np.stack([
np.sqrt(lon**2 + lat**2) + i * 20
for i in range(4)
])
vmin, vmax = np.min(data), np.max(data)
def prepare_layer(l, i):
l.add_feature.preset.ocean()
l.add_feature.preset.coastline()
l.set_plot_specs(vmin=vmin, vmax=vmax)
l.set_data(data[i, :, :], lon, lat)
l.set_shape.shade_raster()
l.plot_map()
l.add_colorbar()
m = Maps(crs=4326)
prepare_layer(m, 0)
for i in range(1, data.shape[0]):
layer = m.new_layer(layer=str(i))
prepare_layer(layer, i)
m.util.layer_slider() Not sure what makes the difference, I can look into it later today. |
ooh, i see 😅 yep you are totally right! Thanks for bringing this up! |
❗ Can you please rebase the branch to derive from the "dev" branch?
|
…m normalized zdata
cb35baf
to
323e303
Compare
Done! |
wow that was fast! thanks! |
OK no need to do another rebase... a hotfix in the master-branch (and re-opening the pull-request) did the job equally well! |
Codecov Report
@@ Coverage Diff @@
## dev #64 +/- ##
=======================================
Coverage 73.22% 73.22%
=======================================
Files 12 12
Lines 5323 5323
=======================================
Hits 3898 3898
Misses 1425 1425
Continue to review full report at Codecov.
|
OK, all checks out fine. Thanks for your contribution!! It'll be in v3.4 (to be released today or tomorrow) |
Awesome, thanks :) |
Hey Raphael, thanks for this library, it's been very useful to me!
I noticed that the vmin & vmax values weren't respected when using shaders. The colorbar used the range set by
set_plot_specs
, but the colors drawn on the map itself were using the min/max of the normalized values. This fixes it by normalizing the existing vmin/vmax instead of recalculating them after normalization.