pyshqg.core.poisson module
Submodule dedicated to the Poisson solver.
- class pyshqg.core.poisson.QGPoissonSolver(backend, spectral_transformations, vertical_parametrisation, orography, orography_scale)
Bases:
objectClass for the Poisson solver.
The goal of this class is to define the transformations $hat{q} mapsto hat{q}^{mathsf{t}} mapsto hat{psi} mapsto zeta$. The (relative) vorticity $hat{q}$ is the control variable of the QG model. The total vorticity $hat{q}^{mathsf{t}}$ is related to $hat{q}$ by… Then, $hat{q}^{mathsf{t}}$ and the stream function $hat{psi}$ are related by the following Poisson-like equation… Finally, the drag $zeta$ is defined as…
- backend
The backend.
- Type:
pyshqg.backend.Backend object
- spectral_transformations
The object encapsulating the spectral transformations.
- spec_qp
The planet vorticity, corrected by the orography, in spectral space $hat{q}^{mathsf{p}}$.
- Type:
backend array, shape (Nlevel, 2, T+1, T+1)
- q_to_psi_coupling
The vertical coupling coefficients for the $hat{q}^{mathsf{t}} mapsto hat{psi}$ transformation.
- Type:
backend array, shape (Nlevel, Nlevel, T+1)
- __init__(backend, spectral_transformations, vertical_parametrisation, orography, orography_scale)
Constructor for the Poisson solver.
First, the planet voticity in spectral space $hat{q}^{mathsf{p}}$ is pre-computed using the precompute_planet_vorticity method, then the vertical coupling coefficients are pre-computed using the precompute_q_to_psi_coupling method.
- Parameters:
backend (pyshqg.backend.Backend object) – The backend.
spectral_transformations (pyshqg.core.spectral_transformations.SpectralTransformations) – The object encapsulating the spectral transformations.
vertical_parametrisation (pyshqg.preprocessing.vertical_parametrisation.VerticalParametrisation) – The object encapsulating the vertical parametrisation.
orography (pyshqg.preprocessing.orography.Orography) – The object encapsulating the orography in the grid.
orography_scale (float) – The vertical length scale for the orography.
- precompute_planet_vorticity(vertical_parametrisation, orography, orography_scale)
Pre-computes the planet vorticity in spectral space $hat{q}^{mathsf{p}}$.
First, the planet voticity is pre-computed in grid space using the spectral_transformations object. Then, the orography correction is added in grid space by the orography object. Finally, the corrected planet vorticity is sent to spectral space using spectral_transformations object.
- Parameters:
vertical_parametrisation (pyshqg.preprocessing.vertical_parametrisation.VerticalParametrisation) – The object encapsulating the vertical parametrisation.
orography (pyshqg.preprocessing.orography.Orography) – The object encapsulating the orography in the grid.
orography_scale (float) – The vertical length scale for the orography.
- Returns:
spec_qp – The corrected planet vorticity in spectral space $hat{q}^{mathsf{p}}$.
- Return type:
backend array, shape (Nlevel, 2, T+1, T+1)
- precompute_q_to_psi_coupling(vertical_parametrisation)
Pre-computes the vertical coupling coefficients.
First, the inverse coupling matrix is computed using the vertical_parametrisation object. Then, the inverse coupling matrix is corrected using Eigen spectrum of the Laplacian operator, defined in the spectral_transformations object, and inversed using numpy.linalg.inv.
Note that this method distinguished the special case l=0 from the general case.
- Parameters:
vertical_parametrisation (pyshqg.preprocessing.vertical_parametrisation.VerticalParametrisation) – The object encapsulating the vertical parametrisation.
- Returns:
q_to_psi_coupling – The vertical coupling coefficients.
- Return type:
backend array, shape (Nlevel, Nlevel, T+1)
- q_to_total_q(spec_q)
Computes the $hat{q} mapsto hat{q}^{mathsf{t}}$ transformation.
To do this, the planet vorticity in spectral space $hat{q}^{mathsf{p}}$ is added to the relative vorticity in spectral space $hat{q}$.
- Parameters:
spec_q (backend array, shape (..., Nlevel, 2, T+1, T+1)) – The relative vorticity in spectral space $hat{q}$.
- Returns:
spec_total_q – The total vorticity in spectral space $hat{q}^{mathsf{t}}$.
- Return type:
backend array, shape (…, Nlevel, 2, T+1, T+1)
- total_q_to_psi(spec_total_q)
Computes the $hat{q}^{mathsf{t}} mapsto hat{psi}$ transformation.
To do this, $hat{q}^{mathsf{t}}$ is multiplied by the vertical coupling coefficients.
- Parameters:
spec_total_q (backend array, shape (..., Nlevel, 2, T+1, T+1)) – The total vorticity in spectral space $hat{q}^{mathsf{t}}$.
- Returns:
spec_psi – The stream function in spectral space $hat{psi}$.
- Return type:
backend array, shape (…, Nlevel, 2, T+1, T+1)
- psi_to_zeta(spec_psi)
Computes the $hat{psi} mapsto zeta$ transformation.
To do this, the lowest level of $hat{psi}$ (indexed by -1) is multiplied by the Eigen values of the Laplacian operator to get $hat{zeta}$. Then, $hat{zeta}$ is sent to grid space to get $zeta$.
- Parameters:
spec_psi (backend array, shape (..., Nlevel, 2, T+1, T+1)) – The stream function in spectral space $hat{psi}$.
- Returns:
zeta – The drag in grid space $zeta$.
- Return type:
backend array, shape (…, Nlat, Nlon)