-
Notifications
You must be signed in to change notification settings - Fork 67
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
pcolormesh not working #21
Comments
I haven't had a chance to dig in yet, but I'll hazard a quick guess: This may because you're working in strike/dip space, while the plot expects native stereographic coordinates (e.g. https://github.com/joferkington/mplstereonet/blob/master/mplstereonet/stereonet_math.py#L5 (though the units are radians instead of degrees, contrary to the diagram)). I'll try to get an example together shortly. Regardless, if that is the case, it would still be good to have a convenience function for plotting a mesh in plunge/bearing space. Thanks for raising the issue, either way! |
Just to confirm -- the issue is with your 0-360 and 0-90 ranges. If you were to plot the same thing in the coordinate system that all of the plotting functions expect, you'd get:
Because there are multiple ways to represent orientation data (e.g. plunge/bearing vs strike/dip or rake vs plunge/bearing, etc) To convert a pole to plane of a strike/dip to a point you can plot, you'd use Similarly, to reproduce your specific example with strikes ranging from 0-360 and dips ranging from 0-90, you'd do:
|
I'm not sure a convenience function makes a ton of sense, now that I think more about it (i'm on the fence, though). However, I should definitely add another example, at the very least. |
Thanks a lot for the quick feedback on this issue @joferkington. With your "fix" I'm getting a 90° offset problem somehow though (it didn't show in the previous example due to the symmetry). Easy to work around it but maybe something needs more tweaking in the internals or I'm still missing something vital.. (sorry about the longish example..) import numpy as np
import matplotlib.pyplot as plt
import mplstereonet
strikes = np.linspace(0, 360, 131, endpoint=True)
dips = np.linspace(0, 90, 101, endpoint=True)
mesh_strikes, mesh_dips = np.meshgrid(strikes, dips)
data = (np.sin(np.radians(strikes * 2.5 + 22)) *
np.sin(np.radians(strikes * 1.3)) ** 2)[:, np.newaxis] * dips
# Key function you were missing...
lon, lat = mplstereonet.pole(mesh_strikes, mesh_dips)
fig = plt.figure(figsize=(14, 4))
ax_cart = fig.add_subplot(141)
ax_cart.set_title('carthesian')
ax_cart.pcolormesh(mesh_strikes, mesh_dips, data.T)
ax_cart.set_xlabel('strike')
ax_cart.set_ylabel('dip')
ax_polar = fig.add_subplot(142, projection='polar')
ax_polar.set_title('polar\n')
ax_polar.set_theta_direction(-1)
ax_polar.set_theta_offset(np.pi / 2.0)
ax_polar.pcolormesh(np.radians(mesh_strikes), mesh_dips, data.T)
ax_stereo1 = fig.add_subplot(143, projection='stereonet')
ax_stereo1.set_title('stereo\n')
ax_stereo1.pcolormesh(lon, lat, data.T)
ax_stereo2 = fig.add_subplot(144, projection='stereonet')
ax_stereo2.set_title('stereo (tweaked)\n')
# tweak by np.rolling the data array
ax_stereo2.pcolormesh(lon, lat,
np.roll(data.T, (data.shape[0] // 4) + 1))
plt.show() |
@megies - I think the rotation you're seeing may be because you're data isn't actually strikes and dips -- instead, it's plunges and bearings. The plot is exactly what would be expected if your data is actually strike/dips of planes and you're working with the poles to those planes (Can't plot a strike/dip directly as a point, as it's a line. Only the pole to the strike/dip is a point). Using For example, let's say we have a strike/dip of
Alternatively, you might have dip/dip-direction convention planar data, in which case you'd need to subtract 90 degrees from the azimuth to get strike/dips that you can plot poles to. At any rate, depending on what your data actually represent (poles to strike/dip, plunges/bearings, or poles to dip/dip-direction), the plot will be different. To build on your example:
|
Would be nice if one could do a pcolormesh on the ’’stereonet" Axes, right now array data doesn't seem to get projected correctly.
The text was updated successfully, but these errors were encountered: