## Plotting the Ekman spiral

### a) The top Ekman spiral

The equations for the Ekman spiral are 

\begin{align}
    u_E (z) & = u_s \cos⁡\left(\frac{𝜋}{4} + \frac{\pi}{D} z\right) e^{\frac{\pi}{D}z} \\
    v_E (z) & = -u_s \sin⁡\left(\frac{𝜋}{4} + \frac{\pi}{D} z\right) e^{\frac{\pi}{D}z}
\end{align}
 

Where $u_s = 1$ m/s is the flow at the surface and $D=\pi\sqrt{2K/f}$ is the Ekman layer thickness.  

Plot these two functions for $f=10^{-4} s^{-1}$, $K=2\times10^{-2} m^2/s$ and `z=np.arange(-100, 0.01, 5)`. 

Make three plots:
1. $u_E$ and $v_E$ as two lines as a function of depth. Put depth on the y-axis
2. A scatter-line-plot of $u_E$ vs. $v_E$, with each point color-coded for depth
3. a 3D quiver plot, you can use the code below to show the vector components $u_E$ and $v_E$

    ```
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D 
    fig = plt.figure(figsize=(7, 5)) 
    ax = fig.gca(projection='3d') 
    zs = np.zeros(len(z)) 
    ax.set_xlim((-.1,.1))
    ax.set_ylim((-.1,.1))
    ax.set_zlim((-100,0))
    ax.quiver(zs, zs, z, uE, vE, zs) 
    ax.set_xlabel('zonal velocity [m/s]') 
    ax.set_ylabel('meridional velocity [m/s]') 
    ax.set_zlabel('Depth [m]') 
    plt.show()
    ```
    
Explain the figures.


```python

```

### b) Bottom Ekman Layer
At the bottom there is also an Ekman layer, but only if the ocean interior geostrophic velocity is non-zero so that a no-slip boundary condition can be satisfied. The Ekman spiral looks like this:


\begin{align}
    u_E (z) & = u_g - e^{z/D} \left[u_g \cos(z/D) + v_g \sin(z/D) \right] \\
    v_E (z) & = v_g + e^{z/D} \left[u_g \sin(z/D) - v_g \cos(z/D) \right]
\end{align}

Here $u_g$ and $v_g$ are the geoestrophic velocities in the ocean's interior.

The derivation is similar to that of the surface Ekman layer and can be found in chapter 5.7.3 of _Atmospheric and Oceanic Fluid Dynamics_ (2nd edition) by Vallis or chapter 5.3.2 of _Dynamical Oceanography_ by Dijkstra.

Plot the same three figures as in (a) for $u_g = 0.1 m/s$, $v_g = 0 m/s$, and assuming the same $D$ and $f$ for the 250 meters above the sea floor (for simplicity, the sea floor can now be set to 0 and $z$ is still pointing up).

Explain the figures.


```python

```

d7a7153e386e8324ae10346e3f334b9845b612c0
ipynb
Jupyter Notebook
Ch03_SurfacedriftGyres_Plastic/Ch03_EkmanSpiral.ipynb
OceanCurrentsBook/Exercises
60a91a794edec53d333fbce8679ff68ac9aa6cf9
CC0-1.0
2020-08-28T21:59:36.000Z
2021-08-19T18:40:54.000Z
Ch03_SurfacedriftGyres_Plastic/Ch03_EkmanSpiral.ipynb
OceanCurrentsBook/Exercises
60a91a794edec53d333fbce8679ff68ac9aa6cf9
CC0-1.0
Ch03_SurfacedriftGyres_Plastic/Ch03_EkmanSpiral.ipynb
OceanCurrentsBook/Exercises
60a91a794edec53d333fbce8679ff68ac9aa6cf9
CC0-1.0
Qwen/Qwen-72B
1. YES
2. YES

