|
|
|
@ -9,8 +9,8 @@ from math import pi as PI
|
|
|
|
|
import logging
|
|
|
|
|
import numpy as num
|
|
|
|
|
|
|
|
|
|
from matplotlib.collections import PathCollection
|
|
|
|
|
from matplotlib.path import Path
|
|
|
|
|
from matplotlib.collections import PatchCollection
|
|
|
|
|
from matplotlib.patches import Polygon
|
|
|
|
|
from matplotlib.transforms import Transform
|
|
|
|
|
from matplotlib.colors import LinearSegmentedColormap
|
|
|
|
|
|
|
|
|
@ -45,7 +45,7 @@ class FixedPointOffsetTransform(Transform):
|
|
|
|
|
self.has_inverse = False
|
|
|
|
|
self.trans = trans
|
|
|
|
|
self.dpi_scale_trans = dpi_scale_trans
|
|
|
|
|
self.fixed_point = num.asarray(fixed_point, dtype=num.float)
|
|
|
|
|
self.fixed_point = num.asarray(fixed_point, dtype=num.float64)
|
|
|
|
|
|
|
|
|
|
def transform_non_affine(self, values):
|
|
|
|
|
fp = self.trans.transform(self.fixed_point)
|
|
|
|
@ -251,7 +251,7 @@ def numpy_rtp2xyz(rtp):
|
|
|
|
|
r = rtp[:, 0]
|
|
|
|
|
theta = rtp[:, 1]
|
|
|
|
|
phi = rtp[:, 2]
|
|
|
|
|
vecs = num.empty(rtp.shape, dtype=num.float)
|
|
|
|
|
vecs = num.empty(rtp.shape, dtype=num.float64)
|
|
|
|
|
vecs[:, 0] = r*num.sin(theta)*num.cos(phi)
|
|
|
|
|
vecs[:, 1] = r*num.sin(theta)*num.sin(phi)
|
|
|
|
|
vecs[:, 2] = r*num.cos(theta)
|
|
|
|
@ -260,7 +260,7 @@ def numpy_rtp2xyz(rtp):
|
|
|
|
|
|
|
|
|
|
def numpy_xyz2rtp(xyz):
|
|
|
|
|
x, y, z = xyz[:, 0], xyz[:, 1], xyz[:, 2]
|
|
|
|
|
vecs = num.empty(xyz.shape, dtype=num.float)
|
|
|
|
|
vecs = num.empty(xyz.shape, dtype=num.float64)
|
|
|
|
|
vecs[:, 0] = num.sqrt(x**2+y**2+z**2)
|
|
|
|
|
vecs[:, 1] = num.arctan2(num.sqrt(x**2+y**2), z)
|
|
|
|
|
vecs[:, 2] = num.arctan2(y, x)
|
|
|
|
@ -268,7 +268,7 @@ def numpy_xyz2rtp(xyz):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def circle_points(aphi, sign=1.0):
|
|
|
|
|
vecs = num.empty((aphi.size, 3), dtype=num.float)
|
|
|
|
|
vecs = num.empty((aphi.size, 3), dtype=num.float64)
|
|
|
|
|
vecs[:, 0] = num.cos(sign*aphi)
|
|
|
|
|
vecs[:, 1] = num.sin(sign*aphi)
|
|
|
|
|
vecs[:, 2] = 0.0
|
|
|
|
@ -310,7 +310,7 @@ def eig2gx(eig, arcres=181):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
xtheta = num.arctan(num.sqrt(Y))
|
|
|
|
|
rtp = num.empty(xphi.shape+(3,), dtype=num.float)
|
|
|
|
|
rtp = num.empty(xphi.shape+(3,), dtype=num.float64)
|
|
|
|
|
rtp[:, 0] = 1.
|
|
|
|
|
if sign > 0:
|
|
|
|
|
rtp[:, 1] = xtheta
|
|
|
|
@ -474,7 +474,7 @@ def choose_transform(axes, size_units, position, size):
|
|
|
|
|
raise BeachballError(
|
|
|
|
|
'invalid argument for size_units: %s' % size_units)
|
|
|
|
|
|
|
|
|
|
position = num.asarray(position, dtype=num.float)
|
|
|
|
|
position = num.asarray(position, dtype=num.float64)
|
|
|
|
|
|
|
|
|
|
return transform, position, size
|
|
|
|
|
|
|
|
|
@ -491,7 +491,7 @@ def mt2beachball(
|
|
|
|
|
projection='lambert',
|
|
|
|
|
view='top'):
|
|
|
|
|
|
|
|
|
|
position = num.asarray(position, dtype=num.float)
|
|
|
|
|
position = num.asarray(position, dtype=num.float64)
|
|
|
|
|
size = size or 1
|
|
|
|
|
mt = deco_part(mt, beachball_type, view)
|
|
|
|
|
|
|
|
|
@ -588,28 +588,29 @@ def plot_beachball_mpl(
|
|
|
|
|
verts = project(poly, projection)[:, ::-1] * size + position[NA, :]
|
|
|
|
|
if alpha == 1.0:
|
|
|
|
|
data.append(
|
|
|
|
|
(Path(verts[::decimation]), color, color, linewidth))
|
|
|
|
|
(verts[::decimation], color, color, linewidth))
|
|
|
|
|
else:
|
|
|
|
|
data.append(
|
|
|
|
|
(Path(verts[::decimation]), color, 'none', 0.0))
|
|
|
|
|
(verts[::decimation], color, 'none', 0.0))
|
|
|
|
|
|
|
|
|
|
for poly in lines_upper:
|
|
|
|
|
verts = project(poly, projection)[:, ::-1] * size + position[NA, :]
|
|
|
|
|
data.append(
|
|
|
|
|
(Path(verts[::decimation]), 'none', edgecolor, linewidth))
|
|
|
|
|
|
|
|
|
|
paths, facecolors, edgecolors, linewidths = zip(*data)
|
|
|
|
|
path_collection = PathCollection(
|
|
|
|
|
paths,
|
|
|
|
|
facecolors=facecolors,
|
|
|
|
|
edgecolors=edgecolors,
|
|
|
|
|
linewidths=linewidths,
|
|
|
|
|
alpha=alpha,
|
|
|
|
|
zorder=zorder,
|
|
|
|
|
transform=transform)
|
|
|
|
|
(verts[::decimation], 'none', edgecolor, linewidth))
|
|
|
|
|
|
|
|
|
|
patches = []
|
|
|
|
|
for (path, facecolor, edgecolor, linewidth) in data:
|
|
|
|
|
patches.append(Polygon(
|
|
|
|
|
xy=path, facecolor=facecolor,
|
|
|
|
|
edgecolor=edgecolor,
|
|
|
|
|
linewidth=linewidth,
|
|
|
|
|
alpha=alpha))
|
|
|
|
|
|
|
|
|
|
collection = PatchCollection(
|
|
|
|
|
patches, zorder=zorder, transform=transform, match_original=True)
|
|
|
|
|
|
|
|
|
|
axes.add_artist(path_collection)
|
|
|
|
|
return path_collection
|
|
|
|
|
axes.add_artist(collection)
|
|
|
|
|
return collection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mts2amps(mts, projection, beachball_type, grid_resolution=200, mask=True,
|
|
|
|
@ -622,12 +623,12 @@ def mts2amps(mts, projection, beachball_type, grid_resolution=200, mask=True,
|
|
|
|
|
x = num.linspace(-1., 1., nx)
|
|
|
|
|
y = num.linspace(-1., 1., ny)
|
|
|
|
|
|
|
|
|
|
vecs2 = num.zeros((nx * ny, 2), dtype=num.float)
|
|
|
|
|
vecs2 = num.zeros((nx * ny, 2), dtype=num.float64)
|
|
|
|
|
vecs2[:, 0] = num.tile(x, ny)
|
|
|
|
|
vecs2[:, 1] = num.repeat(y, nx)
|
|
|
|
|
|
|
|
|
|
ii_ok = vecs2[:, 0]**2 + vecs2[:, 1]**2 <= 1.0
|
|
|
|
|
amps = num_full(nx * ny, num.nan, dtype=num.float)
|
|
|
|
|
amps = num_full(nx * ny, num.nan, dtype=num.float64)
|
|
|
|
|
|
|
|
|
|
amps[ii_ok] = 0.
|
|
|
|
|
for mt in mts:
|
|
|
|
|