Open main menu
relax wiki
Search
Changes
← Older edit
Relax disp.spin lock offset+field figure
2,210 bytes added
,
17:35, 6 November 2015
→See also
:
Fix for the category.
{{lowercase title}}
__TOC__
== Reference to original figure ==
Comparing to Figure 1 and 10 the reference:
* {{#lst:Citations|PalmerMassi06}}
[[File:Fig1 Palmer Massi 2006.png|thumb|center|upright=4|Try to reproduce Figure 1.]]
== Script to produce figure ==
{{collapsible script
<source
| type = Python script
| title = Reproduce figure 1 of Palmer and Massi, 2006 using matplotlib.
|
lang
=
"
python
">
| script =
#############
# Made by Troels E. Linnet
label = labels[i]
label.xy = tX[i],tY[i]
label.update_positions(fig.canvas.renderer)
tX_t, tY_t, _ = proj3d.proj_transform(dataX_t, dataY_t, dataZ_t, ax.get_proj())
for i in range(len(dataX_t)):
label = labels_t[i]
label.xy = tX_t[i],tY_t[i]
label.update_positions(fig.canvas.renderer)
fig.canvas.draw()
#########
fig = plt.figure(
figsize=(12, 12)
)
ax=fig.gca(projection='3d')
ax.add_patch(circle)
#art3d.pathpatch_2d_to_3d(circle, z=0, zdir='y')
pathpatch_2d_to_3d(circle, z=0, normal =
(
[
1, 0, 1
]
)
)
#######
#Input 3D Data for Text
#
Sx
Sy Sx Szp Sxp w1 O1 we1 O_av w_e
data
=
np.array([
[1,0,0]
,
Sy =
[0,-1,0]
,
Sz =
[0,0,1]
,
Szp =
[
0
1
.
975
1
,0,1.
17
1
]
,
Sxp =
[0.75,0,-0.75]
,
w1 =
[0.7,0,0]
,
O1 =
[0,0,0.3]
we1 = [w1[0],0
,
O1[2]]
O_av =
[0.
7
0
,0,
Szp[2]/Szp[
0
.3
]
,
*w1
[0
.
]]
we = [w1[
0
]
,0,
Szp[2]/Szp[
0
.84
]
,
*w1
[0
]]
data = np
.
7
array([Sx, Sy, Sz , Szp , Sxp, w1, O1, we1
,
0
O_av
,
0.84]
we
])
textlab = [r"S$_x$", r"S$_y$=S$_y$'", r"S$_z$", r"S$_z$'", r"S$_x$'", r"$\omega_1$", r"$\Omega_1$", r"$\omega_{e1}$", r"$\bar{\Omega}$", r"$\omega_{e}$"]
#Array of labels
labels = []
#Loop through data points to initially annotate scatter plot
#and populate labels array
label = ax.annotate(text,
xycoords='data',
xy = (tX[i], tY[i]), xytext = (
-
+
20,
-
20),
textcoords = 'offset points', ha = 'right', va = 'top', fontsize=12,
bbox = dict(boxstyle = 'round,pad=0.5', fc = 'grey', alpha = 0.8),
arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))
labels.append(label)
#######
#######
#Input 3D Data for Ttheta
t1 = [0.5*we1[0],0,0.5*we1[2]]
t = [0.5*we[0],0,0.5*we[2]]
data_t = np.array([t1, t])
textlab_t = [r"$\theta_1$", r"$\theta$"]
#Separate into X, Y, Z for greater clarity
dataX_t = data_t[:,0]
dataY_t = data_t[:,1]
dataZ_t = data_t[:,2]
#3D scatter plot
ax.scatter(dataX_t, dataY_t, dataZ_t, marker = 'o', c='k', s=1)
#Transform co-ordinates to get initial 2D projection
tX_t, tY_t, _ = proj3d.proj_transform(dataX_t, dataY_t, dataZ_t, ax.get_proj())
#Array of labels
labels_t = []
#Loop through data points to initially annotate scatter plot
#and populate labels array
for i in range(len(dataX_t)):
#text='['+str(int(dataX[i]))+','+str(int(dataY[i]))+','+str(int(dataZ[i]))+']'
text=textlab_t[i]
label = ax.annotate(text,
xycoords='data',
xy = (tX[i], tY[i]), xytext = (-100, 50),
textcoords = 'offset points', ha = 'right', va = 'top', fontsize=12,
bbox = dict(boxstyle = 'round,pad=0.5', fc = 'grey', alpha = 0.8),
arrowprops = dict(arrowstyle = '->', connectionstyle = 'angle3,angleA=0,angleB=90'))
labels_t.append(label)
#######
# Make Sx
i
x, y, z
=
0
Sx
Sx = Arrow3D([-1,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=1, arrowstyle="-
|
{{!}}
>", color="k")
ax.add_artist(Sx)
# Make Sy
i +
x, y, z
=
1
Sy
Sy
fSy
= Arrow3D([0,
dataX[i]
x
],[1,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=1, arrowstyle="-
|
{{!}}
>", color="k")ax.add_artist(
Sy
fSy
)
# Make Sz
i +
x, y, z
=
1
Sz
Sz
fSz
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [-1,
dataZ[i]
z
], mutation_scale=20, lw=1, arrowstyle="-
|
{{!}}
>", color="k")ax.add_artist(
Sz
fSz
)
# Make Szp
i +
x, y, z
=
1
Szp
Szp
fSzp
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=3, arrowstyle="-
|
{{!}}
>", color="k")ax.add_artist(
Szp
fSzp
)
# Make Sxp
i +
x, y, z
=
1
Sxp
Sxp
fSxp
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=3, arrowstyle="-
|
{{!}}
>", color="k")ax.add_artist(
Sxp
fSxp
)
# Make w1
i +
x, y, z
=
1
w1
w1
fw1
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=1, arrowstyle="-", color="k")ax.add_artist(
w1
fw1
)
# Make O1
i +
x, y, z
=
1
O1
O1
fO1
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
y
], mutation_scale=20, lw=1, arrowstyle="-", color="k")ax.add_artist(
O1
fO1
)
# Make we1
i +
x, y, z = we1
fwe1 = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw
= 1
, arrowstyle="-{{!}}>", color="b")
ax.add_artist(fwe1)
# Make O1 ->
we1
fO1_we1
= Arrow3D(
[O1
[0
]
,
dataX
we1
[
i
0
]],[
0
O1[1]
,
dataY
we1
[
i
1
]], [
0
O1[2]
,
dataZ
we1
[
i
2
]], mutation_scale=20, lw=1, arrowstyle="-
|>
", color="b")ax.add_artist(
we1
fO1_we1
)
# Make O_av
i +
x, y, z
=
1
O_av
O_av
fO_av
= Arrow3D([0,
dataX[i]
x
],[0,
dataY[i]
y
], [0,
dataZ[i]
z
], mutation_scale=20, lw=1, arrowstyle="-", color="k")ax.add_artist(
O_av
fO_av
)
# Make we
i +
x, y, z = we
fwe = Arrow3D([0, x],[0, y], [0, z], mutation_scale=20, lw
= 1
, arrowstyle="-{{!}}>", color="r")
ax.add_artist(fwe)
# Make w1 ->
we
fw1_we
= Arrow3D(
[w1[0], we
[0
]],[w1[1], we[1]]
,
dataX
[
i
w1[2
]
, we[2]], mutation_scale=20, lw=1, arrowstyle="-", color="r")
ax.add_artist(fw1_we)
# Make O_ave -> we
fO_av_we = Arrow3D([O_av[0
],
we
[0
]],[O_av[1]
,
dataY
we
[
i
1
]], [
0
O_av[2]
,
dataZ
we
[
i
2
]], mutation_scale=20, lw=1, arrowstyle="-
|>
", color="r")ax.add_artist(
we
fO_av_we
)
fig.canvas.mpl_connect('button_release_event', update_position)
plt.show()
</source>
}}
== See also ==
[[Category:Relaxation dispersion analysis]]
Bugman
Trusted,
Bureaucrats
4,223
edits