-
Notifications
You must be signed in to change notification settings - Fork 35
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
Stream thickness #95
Stream thickness #95
Conversation
… functions so that it is possible to scale the thickness of streamlines to reflect the amplitude of the vector field. This functionality was added in a manner similar to the stream_threshold keyword.
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
==========================================
- Coverage 72.99% 72.75% -0.25%
==========================================
Files 20 20
Lines 4503 4518 +15
==========================================
Hits 3287 3287
- Misses 1216 1231 +15
Continue to review full report at Codecov.
|
Thanks @micmitch: do you have a small example you could include in the discretize examples? |
…n vector amplitudes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @micmitch: this looks solid. There are two minor updates I have requested. See what you think and feel free to ping when you are happy with them.
discretize/View.py
Outdated
vecAmp[highInds] = upperBound | ||
|
||
# Normalize amplitudes 0-1 | ||
# norm_thickness = (np.log10(vecAmp) - np.log10(vecAmp.min())) / (np.log10(vecAmp.max()) - np.log10(vecAmp.min())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind cleaning out the commented-out line (523) if it is not needed? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -0,0 +1,83 @@ | |||
""" | |||
Simple example to vary streamline thickness based on the vector amplitudes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this @micmitch! Do you think we can shorten the title? (The whole title is included on the side-bar). What about
Plotting: Streamline thickness
==============================
A simple example to vary streamline thickness based on the vector amplitudes
Author: `@micmitch <https://github.com/micmitch>`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@micmitch: would you mind adding a code snippet showing example usage (and perhaps an image from your new example) to the description of this pull request? I will use your notes as the release notes when the version is bumped (e.g. https://github.com/simpeg/discretize/releases/tag/0.3.5) |
` Plot secondary current densities for a pole transmitter in the ceiling of a tunnel with a conductive block 5 m above.Set source IndexsrcInd = 5 Set colorbar limitsclim = [5e-11, 4.0e-3] Set surrent density plotting parameterslabel = 'Current Density ( Get secondary current density values from fields objectuTotal = fields_total[src,'j'] Set font sizeslabelsize = 30. Setup figurefig = plt.figure() Plot slicedat = mesh.plotSlice(u, ax=ax, normal='X', ind=49, vType='F', view='vec', streamOpts={'color':'w', 'density':2.0}, gridOpts={"color":"k", "alpha":0.1}, grid=True, range_x=[-30, 30], range_y=[-20, 20], clim=[5e-11, 4.0e-3], stream_threshold=1e-8, stream_thickness=3) Plot outline of conductive block above the tunnelgetBlkOutline(sigmaTrue_Block,mesh,sliceInd,normal=sliceNormal, ax=ax, lineWidth=3.0) Plot electrode locationsax.scatter(elecLocs[:,1],elecLocs[:,2], c='w', edgecolors='k', s=150) Label Tx electrodeA = src.loc Add title and set layoutax.set_title("N-S section at "+ "{0:.2f}".format(mesh.vectorCCx[sliceInd])+"m") plt.gca().set_aspect('equal', adjustable='box') Add colorbarif scale == "log": if cb:
|
Is this what you had in mind? |
The image looks great! I didn't mean for you to copy the whole example in, just a minimal part, but I can extract a subset e.g. mesh.plotSlice(
u, ax=ax, normal='X', vType='F', view='vec', stream_threshold=1e-8, stream_thickness=3
) |
Added stream_thickness keyword argument to plotSlice and _plotImage2D functions so that it is possible to scale the thickness of streamlines to reflect the amplitude of the vector field. This functionality was added in a manner similar to the stream_threshold keyword.
stream_thickness keyword currently takes a float which acts as a scaling factor for the streamline thickness. Bounds are hardwired to fix the thickness of the 10% largest and smallest vector amplitudes. Provides good results with the DC current density plots I've made but could probably be generalized in the future for more flexibility.