NEDAS.models.qg.python.strat module

Stratification tools: tridiagonal operator, vertical modes, triple interactions.

Translates Fortran strat_tools.f90 and the relevant parts of qg_run_tools.f90.

NEDAS.models.qg.python.strat.strat_params(dz, drho, F, Fe, surface_bc='rigid_lid')[source]

Build tridiagonal coefficients for the stretching operator.

Returns op of shape (nv, 3) where op[:, 0] = sub-diagonal, op[:, 1] = diagonal, op[:, 2] = super-diagonal. For surface_bc=’surf_buoy’, nv = nz+1; otherwise nv = nz.

Translates Fortran strat_params in strat_tools.f90. The Fortran stores op(1:nv, -1:1); we map -1->0, 0->1, 1->2.

NEDAS.models.qg.python.strat.get_layer_depths(dz)[source]

Layer centre depths (negative downward), like Fortran Get_z.

NEDAS.models.qg.python.strat.get_vmodes(dz, drho, F, Fe=0.0, surface_bc='rigid_lid')[source]

Compute vertical modes via eigendecomposition of the stretching operator.

Returns (kz, vmode) where:

kz : (nz,) deformation wavenumbers (ascending) vmode : (nz, nz) orthonormal mode matrix (columns = modes)

Translates Fortran Get_vmodes in strat_tools.f90.

NEDAS.models.qg.python.strat.get_psiq(dz, drho, F, Fe=0.0, surface_bc='rigid_lid')[source]

Return the psiq tridiagonal operator used in Get_pv / Invert_pv.

psiq[z, offset] with offset in {-1, 0, 1} (Fortran convention). We return shape (nv, 3) mapping to offsets [-1, 0, 1].

NEDAS.models.qg.python.strat.get_tripint(dz, rho, surface_bc='rigid_lid', hf=10)[source]

Triple-interaction coefficients for vertical modes.

Returns tripint of shape (nz, nz, nz).

Translates Fortran Get_tripint in strat_tools.f90, using spline interpolation to a higher-resolution grid for de-aliasing.

NEDAS.models.qg.python.strat.layer2mode(f, vmode, dz)[source]

Project layered spectral field onto vertical modes.

f : (…, nz, nky, nkx) layered field (spectral or physical) vmode : (nz, nz) dz : (nz,) Returns (…, nz, nky, nkx)

NEDAS.models.qg.python.strat.mode2layer(fm, vmode)[source]

Project modal field onto layers.

fm : (…, nz, nky, nkx) vmode : (nz, nz) Returns (…, nz, nky, nkx)