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
Plot Event far-field radiation pattern / refactor core/event.py into folder structure #1192
Conversation
Looks nice!
That could be very nice for many people, I think.. |
That's very nice! |
Agree. Things that could/should be improved are then:
|
I agree.
But the place to go is already there: EDIT: There could even be methods attached to |
Hmm...I did not realize that matplotlibs 3D plotting lacks basic features like figuring out what should be drawn in the front if one plots two objects...I don't think its possible to make a good 3D quiver plot with matplotlib. Even the "nicer" version of me is almost impossible to interpret because the orthographic projection messes with the mind and is just very confusing. @MMesch I would be fine to have your original mayavi plots in there as well. Just make sure to import mayavi within the plotting functions so it does not become a hard ObsPy dependency. Other opinions on this? |
Yeah, why not. If it's optional visualizations of more special stuff and done as soft dependency.. 👍 |
OK. If someone finds out how to plot the beachball patch_collection in the 3D plot this would be great. I didn't get very far but it should be possible (see http://stackoverflow.com/questions/18228966/how-can-matplotlib-2d-patches-be-transformed-to-3d-with-arbitrary-normals ) |
@megies Here we have a possible new class of functions for seismic source representation, which seems something different to me. |
I managed to plot the beachball together with the surface plot but matplotlib is just not capable of really doing 3D. It can't tell which patch is above the other for the beachball (therefore facecolor='none') and it cannot say when the beachball is behind the surface. 3D plotting in matplotlib is too limited and I'm giving up on this... |
It doesn't look like any released version of Mayavi2 supports Python 3 😦 . FYI @carltape. |
Cool stuff in this thread! I've got some cool stuff in the link below, but most of it is mathematica (which very few seismologists use). I agree, it would be great to have some open-source alternatives. |
Here's a nice spherical harmonics example with Mayavi, this may be what @QuLogic was referring to |
It's just that we're having a lot of pain currently (and I mean really a lot), cleaning up and sanitizing the module structure (which has exploded over the last years), esp. to clean up the top levels of our submodule hierarchy (see #999, #1039, ...). |
Here are plots with mayavi that I did before. Another alternative would be to just output a vtk file if there is no mayavi/vtk and plot otherwise. http://pythology.blogspot.fr/2015/11/earthquake-moment-tensor-radiation.html |
Looks great! 👍 |
👍 amazing look in 3D vtk (mayavi or paraview, whatever) !! |
@megies @claudiodsf I open an event folder now in obspy.core that combines the event.py file and radpattern.py . Is this what you were thinking? I think the radiation pattern functions should somehow be grouped. I am not sure whether a submodule or a class is best. Any thoughts? |
@MMesch, yes, that's what I think makes most sense, to group these event/origin/source related functions close to where all the event stuff is defined. Since up to now it was a plain py file, making it a folder and having everything in there feels natural to me. What do you think about renaming the old
I think having them grouped in that submodule |
There is direct vtk file output now. Renamed event.py -> base.py . Still need to move the plotting routines, and add a taup plotting routine. Normalization of the vector field needs to be checked as well. |
I'm done for the moment. We could add some kind of map in this plot if latlon keyword is provided. Connecting it to the event object is then very quick and simple. I thought about the maps: it seems that a function to plot 2d greatcircle paths between stations and one or several sources is still missing in obspy. I think we should make it a separate branch/issue to add a function that gives 2d greatcircle paths and 3d paths using taup. Once we have such a function, it is simple to combine it with the event radiation pattern and also plotting routines in 2D and 3D. I therefore suggest to finish/test/include the radiation pattern functions as they are right now and to look after the taup map in the next step. Matthias |
I have pulled the Event and Catalog classes out of base.py and attached a plot function to the Event class. Not sure about the best way to better organize this huge class hierarchy @megies @krischer but base.py is really too big and the class hierarchy too deep to be easily accessible in my opinion. If it has to be as deep as it is now (I guess adapted to quakeml) then all classes that are unlikely to be changed should probably be hidden in one file and the others separate from them in different files. You plot the event data now with:
|
re-add some things for event.py restructuring that got lost in rebase to master
OK, green light by Travis, finally.. Since nobody objected to the core/event/ structure in here I'm gonna merge now. |
Plot Event far-field radiation pattern / refactor core/event.py into folder structure
🎉 |
👍 |
yey! |
@MMesch I think one comment regarding the usage of RTP vs. USE was not addressed; can you please follow up with a correction in another PR? |
to plot rpattern.vtk and beachlines.vtk | ||
|
||
:param coordinate_system: the only implemented option so far is 'RTP'. | ||
Should be extended to support NED, USE, DSE, NED |
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.
I'm re-adding this comment so that @MMesch can address it:
Isn't RTP the same as USE? Why is this name used here, but not anywhere else (e.g., in MoPaD)?
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.
yes good point. Technically they are the same, but I think I added USE for regional models (cartesian definition), just to be complete. If you prefer we can remove it!
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.
It'd be preferable to use consistent naming between this and MoPaD, which doesn't use RTP at all. I'm fine with adding aliases; I can never remember which one is which anyway.
The above statement is incorrect though, since USE is implemented as it's the same as RTP?
How can I open a good pull request for this that includes the stuff that @megies merged? I can go through the doc once more then... |
This branch is already merged to |
OK! |
I just discovered this here which also has some very fancy plots and is based on this very PR: https://github.com/FMassin/SeismicSource/blob/master/README.ipynb Any chance for also getting those into main ObsPy? |
looks great! I think adapting the obspy plot to look similar would be very good. Essentially this means different colors and a smaller surface representation of the radiation pattern? Then all of them should be put into one plot. Also we can benchmark the radiation pattern values with this independent code! |
Also maybe center the colormap around 0? |
This addition to obspy allows to compute and plot P/S-wave farfield radiation patterns for (hopefully) arbitray moment tensors. You can run the test or try:
it is neither well tested nor optimized. Some improvements could be: