This notebook verifies math in Appendix A. Perspective effect in Oh & Evans 2020.


```python
from sympy import symbols, simplify, latex
from sympy import cos, sin, Matrix, diff, N
import numpy as np

ra, dec = symbols('alpha, delta')
vra,vdec,vr = symbols(r'v_\alpha, v_\delta, v_r')
vx,vy,vz = symbols('v_x v_y v_z')
delta_ra, delta_dec= symbols(r'\Delta\alpha \Delta\delta')

R = Matrix([
    [-sin(ra), cos(ra), 0.],
    [-sin(dec)*cos(ra), -sin(dec)*sin(ra), cos(dec)],
    [cos(dec)*cos(ra), cos(dec)*sin(ra), sin(dec)]
])
```


```python
R
```




$\displaystyle \left[\begin{matrix}- \sin{\left(\alpha \right)} & \cos{\left(\alpha \right)} & 0.0\\- \sin{\left(\delta \right)} \cos{\left(\alpha \right)} & - \sin{\left(\alpha \right)} \sin{\left(\delta \right)} & \cos{\left(\delta \right)}\\\cos{\left(\alpha \right)} \cos{\left(\delta \right)} & \sin{\left(\alpha \right)} \cos{\left(\delta \right)} & \sin{\left(\delta \right)}\end{matrix}\right]$




```python
simplify(R.inv()) == R.T
```




    True




```python
diff(R, ra)
```




$\displaystyle \left[\begin{matrix}- \cos{\left(\alpha \right)} & - \sin{\left(\alpha \right)} & 0\\\sin{\left(\alpha \right)} \sin{\left(\delta \right)} & - \sin{\left(\delta \right)} \cos{\left(\alpha \right)} & 0\\- \sin{\left(\alpha \right)} \cos{\left(\delta \right)} & \cos{\left(\alpha \right)} \cos{\left(\delta \right)} & 0\end{matrix}\right]$




```python
diff(R, dec)
```




$\displaystyle \left[\begin{matrix}0 & 0 & 0\\- \cos{\left(\alpha \right)} \cos{\left(\delta \right)} & - \sin{\left(\alpha \right)} \cos{\left(\delta \right)} & - \sin{\left(\delta \right)}\\- \sin{\left(\delta \right)} \cos{\left(\alpha \right)} & - \sin{\left(\alpha \right)} \sin{\left(\delta \right)} & \cos{\left(\delta \right)}\end{matrix}\right]$



## Geneneral $\Delta v_\mathrm{sphere}$ to the first order


```python
vvec = Matrix([
    [vx],
    [vy],
    [vz]
])
```


```python
delta_v_sphere = diff(R, ra)*vvec*delta_ra + diff(R, dec)*vvec*delta_dec
delta_v_sphere
```




$\displaystyle \left[\begin{matrix}\Delta\alpha \left(- v_{x} \cos{\left(\alpha \right)} - v_{y} \sin{\left(\alpha \right)}\right)\\\Delta\alpha \left(v_{x} \sin{\left(\alpha \right)} \sin{\left(\delta \right)} - v_{y} \sin{\left(\delta \right)} \cos{\left(\alpha \right)}\right) + \Delta\delta \left(- v_{x} \cos{\left(\alpha \right)} \cos{\left(\delta \right)} - v_{y} \sin{\left(\alpha \right)} \cos{\left(\delta \right)} - v_{z} \sin{\left(\delta \right)}\right)\\\Delta\alpha \left(- v_{x} \sin{\left(\alpha \right)} \cos{\left(\delta \right)} + v_{y} \cos{\left(\alpha \right)} \cos{\left(\delta \right)}\right) + \Delta\delta \left(- v_{x} \sin{\left(\delta \right)} \cos{\left(\alpha \right)} - v_{y} \sin{\left(\alpha \right)} \sin{\left(\delta \right)} + v_{z} \cos{\left(\delta \right)}\right)\end{matrix}\right]$



We can express this with $v_\mathrm{sphere} = [v_\alpha,\,v_\delta,\,v_r]^T$ **at** $(\alpha,\,\delta)$.
Such first-order correction has been applied in e.g., Kuhn et al. 2019.
The limits of this is:
1. the mean velocity is estimaten in the projected space, where the perspective effect is **baked in** already
2. it is correct to only first-order in $\Delta \alpha$ and $\Delta \delta$
3. it assumes an absolute center at $(\alpha,\,\delta)$


```python
vvec = R.T @ Matrix([[vra],[vdec],[vr]])
delta_v_sphere = diff(R, ra)*vvec*delta_ra + diff(R, dec)*vvec*delta_dec
```


```python
simplify(delta_v_sphere)
```




$\displaystyle \left[\begin{matrix}\Delta\alpha \left(v_\delta \sin{\left(\delta \right)} - v_{r} \cos{\left(\delta \right)}\right)\\- \Delta\alpha v_\alpha \sin{\left(\delta \right)} - \Delta\delta v_{r}\\\Delta\alpha v_\alpha \cos{\left(\delta \right)} + \Delta\delta v_\delta\end{matrix}\right]$




```python
print(latex(simplify(delta_v_sphere)))
```

    \left[\begin{matrix}\Delta\alpha \left(v_\delta \sin{\left(\delta \right)} - v_{r} \cos{\left(\delta \right)}\right)\\- \Delta\alpha v_\alpha \sin{\left(\delta \right)} - \Delta\delta v_{r}\\\Delta\alpha v_\alpha \cos{\left(\delta \right)} + \Delta\delta v_\delta\end{matrix}\right]


## A special case: $\vec{v}_0$ is radial: perspective expansion/contraction

When $\vec{v}_0$ is exactly radial at $(\alpha,\,\delta)$:


```python
v_radial = Matrix([
    [0],
    [0],
    [vr]
])

v0 = R.T * v_radial
```


```python
dMdrav0 = simplify(diff(R, ra) * v0)
dMddecv0 = simplify(diff(R, dec)*v0)

dMdrav0*delta_ra + dMddecv0*delta_dec
```




$\displaystyle \left[\begin{matrix}- \Delta\alpha v_{r} \cos{\left(\delta \right)}\\- \Delta\delta v_{r}\\0\end{matrix}\right]$



$$ \left[\begin{matrix} \Delta v_\alpha \\ \Delta v_\delta \end{matrix} \right] =
- \left[\begin{matrix} \cos\delta & 0 \\ 0 & 1 \end{matrix}\right] v_r
\left[ \begin{matrix} \Delta \alpha \\ \Delta \delta \end{matrix} \right] $$

Since $\cos\delta>0$ always, and noting that there is not cross-term, this means that the signs of projected velocity gradient $\delta v_\alpha$ and $\delta v_\delta$ depends only on the sign of $v_r$: when $v_r>0$ (receding), the projected velocities decrease outward, i.e., we see an apparent contraction and vice versa.

## Second-order terms

One can expand to second-order as well. There will always be a higher-order correction as $\sin$ and $\cos$ expand forever.
The next order term will dominate the residual pattern.


```python
delta_v_sphere2 = simplify(diff(R, ra, 2) *v0 * delta_ra**2  + diff(R, dec, 2) *v0 * delta_dec**2 + 2*diff(R, ra,dec) * v0 * delta_ra * delta_dec)
```


```python
delta_v_sphere2.subs({ra:np.deg2rad(45), dec:np.deg2rad(45)})
```




$\displaystyle \left[\begin{matrix}0\\0.5 \Delta\alpha^{2} v_{r}\\- v_{r} \left(0.5 \Delta\alpha^{2} + \Delta\delta^{2}\right)\end{matrix}\right]$




```python
delta_v_sphere2.subs({ra:np.deg2rad(135), dec:np.deg2rad(135)})
```




$\displaystyle \left[\begin{matrix}0\\- 0.5 \Delta\alpha^{2} v_{r}\\- v_{r} \left(0.5 \Delta\alpha^{2} + \Delta\delta^{2}\right)\end{matrix}\right]$




```python
N(delta_v_sphere.subs({ra:np.deg2rad(45),dec:np.deg2rad(45), vx:5.0, vy:5.0, vz:7.07106781}), 3)
```




$\displaystyle \left[\begin{matrix}\Delta\alpha \left(0.707 v_\delta - 0.707 v_{r}\right)\\- 0.707 \Delta\alpha v_\alpha - 1.0 \Delta\delta v_{r}\\0.707 \Delta\alpha v_\alpha + 1.0 \Delta\delta v_\delta\end{matrix}\right]$




```python
pos2 = N(delta_v_sphere.subs({ra:np.deg2rad(300),dec:np.deg2rad(45), vx:5.0, vy:5.0, vz:7.07106781}), 3, )
```


```python
N(delta_v_sphere.subs({ra:np.deg2rad(340),dec:np.deg2rad(-65), vx:5.0, vy:5.0, vz:7.07106781}), 3)
```




$\displaystyle \left[\begin{matrix}- 2.99 \Delta\alpha\\5.81 \Delta\alpha + 5.15 \Delta\delta\\2.71 \Delta\alpha + 5.7 \Delta\delta\end{matrix}\right]$



23e82b19b0b837e44cf12a5ed8e6335e32ed9065
ipynb
Jupyter Notebook
notebooks/perspective-effect.ipynb
smoh/kinesis
452940768f1cb7a93f97302867ae4f02d772229a
MIT
2019-06-07T15:03:06.000Z
2020-12-19T21:57:15.000Z
notebooks/perspective-effect.ipynb
smoh/kinesis
452940768f1cb7a93f97302867ae4f02d772229a
MIT
2019-08-08T21:19:58.000Z
2019-09-02T16:28:57.000Z
notebooks/perspective-effect.ipynb
smoh/kinesis
452940768f1cb7a93f97302867ae4f02d772229a
MIT
2019-07-25T20:50:04.000Z
2019-08-08T16:59:05.000Z
Qwen/Qwen-72B
1. YES
2. YES