beachball - spherical or cartesian coords?

Hello,

I have happily been using Beach() from obspy.imaging to plot focal mechanisms for strike, dip, rake. A colleague of mine is now working with a mt inversion program and needs to plot beachballs using the moment tensor components. She actually looked at the documentation before using it (a fatal mistake!), and noticed that it says:

Beach(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k', alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False, zorder=100)
    Return a beach ball as a collection which can be connected to an
    current matplotlib axes instance (ax.add_collection).
    
    S1, D1, and R1, the strike, dip and rake of one of the focal planes, can
    be vectors of multiple focal mechanisms.
    
    :param fm: Focal mechanism that is either number of mechanisms (NM) by 3
        (strike, dip, and rake) or NM x 6 (Mxx, Myy, Mzz, Mxy, Mxz, Myz - the
        six independent components of the moment tensor, where the coordinate
        system is x,y,z = Up,South,East).

Which implies that the Cartesian coordinate moment tensor is expected as input. However, we have noticed that the plot appears to be correct only when the spherical coordinate moment tensor is used. Just to check I plotted several moment tensors from the Global CMT catalog, which are in spherical coordinates, and Beach() produces exactly what I see on the Global CMT web page.

We just want to make sure we're correct that Beach is expecting the spherical coordinate moment tensor (M_rr, M_thetatheta, etc.) and not the Cartesian one as implied in the documentation. Can anyone please let me know whether they have also found this?

Many thanks,

- Phil

Hi Phil,

I agree, that the coordinate system is not intuitive, but the documentation is IMHO correct: it says x,y,z = Up,South,East, which is maybe not necessarily what you imagine x,y,z to be. This is why the beachballs are correct with r, theta, phi as input. This is yet another coordinate frame then Stein/Wysession use in their widespread figure 4.4-6 (which is north, west, up).

You can override this behaviour by setting the paramter

:param mopad_basis: The system which may be chosen as 'NED' (North, East
         Down), 'USE' (Up, South, East), 'NWU' (North, West, Up) or
  'XYZ'. 'USE' mimics the ObsPy Beachball behaviour.

I think this is the behaviour you would expect:

#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from obspy.imaging.mopad_wrapper import Beach

source = [1,0,0,0,0,0]
b = Beach(source, xy=(0.5, 0.5), width=1., mopad_basis='XYZ')
plt.gca().add_collection(b)
plt.show()

Cheers,
Martin

Hi Martin,

Thanks for the explanation. I still think the notation Mxx, Myy etc in the documentation is confusing, but it is true that x,y,z = USE is the same as r,theta,phi. Anyway, I'm happy that I confirmed we're using it correctly. Many thanks!

- Phil