# Plotting BeachBall arrays

Hi All;

I have an ascii file that looks like this:

strike dip rake depth VR Mag

130 74 74 19 8.437e+01 4.17
129 74 72 20 8.459e+01 4.17
130 75 73 21 8.458e+01 4.19
129 74 72 22 8.490e+01 4.19
129 74 70 23 8.505e+01 4.19

After plot the time series x,y, where x=depth and y =VR, I would like to plot the fault plane solution for each
x,y pair in the same plot, so that, I can see the change in fault geometry as a function of depth.

I was trying something like this:

import numpy as np
import matplotlib.pyplot as plt
from obspy.imaging.beachball import Beach

file = open(‘meca.dat’,‘r’)
file.close()

x1 =[]
x2=[]
x3=[]
x4=[]
x5=[]
x6=[]

strike=np.array(x1)
dip=np.array(x2)
rake=np.array(x3)
dep=np.array(x4)
vrd=np.array(x5)
mag=np.array(x6)

fig, ax = plt.subplots(figsize=(10,6))
plt.scatter(dep, vrd, s=mag*15, c=mag, alpha=0.75)
plt.colorbar()
ax.set_ylabel(‘Variance reduction (%)’)
ax.set_xlabel(‘Depth (km)’)

bball = Beach([strike, dip, rake], xy=([dep,vrd]), width=(0.80,0.45), linewidth=1, alpha=0.85)
bball.set_zorder(1)

plt.show()

But it doesn’t work: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Is there an smart way to do this? Any help will be appreciated.

Cheers;

-Esteban

Hi Esteban,

there are a few things incorrect in your script.

file = open(‘meca.dat’,‘r’)
file.close()

You stored a list of your data in lines, yet you never do anything with it. Try ‘print lines’ at this point to see what I mean.

x1 =[]
x2=[]
x3=[]
x4=[]
x5=[]
x6=[]

strike=np.array(x1)
dip=np.array(x2)
rake=np.array(x3)
dep=np.array(x4)
vrd=np.array(x5)
mag=np.array(x6)

The code x1= [] generates a list, which is then converted in to a numpy array (strike=np.array(x1)).
This list/array is empty and does not have your strike values in it.

You have to extract the values from the list first.
Since your arrays are empty, there is nothing to plot.

Cheers,
Martin