credit.pol_lapdiff_filt#
Attributes#
Classes#
A class designed to encapsulate operations related to diffusion and pole filtering |
Functions#
|
|
|
Creates an array of specified length with a sigmoid ramp up and down. |
|
find nearest index in array |
Module Contents#
- credit.pol_lapdiff_filt.polfiltT(D, inddo)#
- credit.pol_lapdiff_filt.create_sigmoid_ramp_function(array_length, ramp_length)#
Creates an array of specified length with a sigmoid ramp up and down.
- Parameters:
array_length – The length of the output array.
ramp_length – The length of the ramp up and down.
- Returns:
An array of the specified length with the described ramp up and down using a sigmoid function.
- credit.pol_lapdiff_filt.find_nearest(array, value)#
find nearest index in array
- class credit.pol_lapdiff_filt.Diffusion_and_Pole_Filter(nlat, nlon, device='cpu', lmax=None, mmax=None, grid='legendre-gauss', radius=6371220.0, omega=7.292e-05, gravity=9.80616, havg=10000.0, hamp=120.0)#
A class designed to encapsulate operations related to diffusion and pole filtering with spherical harmonics transformations
- nlat#
- nlon#
- device = 'cpu'#
- lmax = None#
- mmax = None#
- grid = 'legendre-gauss'#
- radius = 6371220.0#
- omega = 7.292e-05#
- gravity = 9.80616#
- havg = 10000.0#
- hamp = 120.0#
- indpol = 10#
- sigmoid#
- load_data(filename)#
- initialize_sht()#
Initialize spherical harmonics and inverse spherical harmonics transformations for both scalar and vector fields.
- initialize_other_properties()#
Initialize additional properties required for diffusion and pole filtering, including latitude and longitude arrays, Laplacian operators, and Coriolis effect.
- grid2spec(ugrid)#
spectral coefficients from spatial data
- spec2grid(uspec)#
spatial data from spectral coefficients
- vrtdivspec(ugrid)#
spatial data from spectral coefficients
- getuv(vrtdivspec)#
compute wind vector from spectral coeffs of vorticity and divergence
- getgrad(chispec)#
compute vector gradient on grid given complex spectral coefficients.
- Parameters:
chispec – rank 1 or 2 or 3 tensor complex array with shape
(ntrunc+1)*(ntrunc+2)/2 or ((ntrunc+1)*(ntrunc+2)/2,nt) containing complex spherical harmonic coefficients (where ntrunc is the triangular truncation limit and nt is the number of spectral arrays to be transformed). If chispec is rank 1, nt is assumed to be 1.
- Returns:
C{B{uchi, vchi}} - rank 2 or 3 numpy float32 arrays containing
gridded zonal and meridional components of the vector gradient. Shapes are either (nlat,nlon) or (nlat,nlon,nt).
- polefilt_lap2d_V2(U, V, substeps)#
Enhances the characteristics of a two-dimensional (2D) vector field by applying a combination of pole filtering and Laplacian-based correction. This function is designed to refine the input vector field by selectively suppressing the influence of specific poles and adjusting the field to better reflect physical constraints and properties. It achieves this through a sequence of operations in the spectral domain, focusing on the field’s divergence, vorticity, and Laplacian characteristics.
The process involves initial pole filtering to mitigate the effects of unwanted features followed by a detailed correction phase that leverages the field’s Laplacian to enforce smoothness and continuity. The correction phase is further enhanced by considering the field’s divergence and vorticity, ensuring that the final vector field adheres more closely to the expected physical behavior.
- Parameters:
U (Tensor) – The x-component of the velocity or vector field. This tensor should
field (represent one of the two dimensions of the)
that (with spatial dimensions)
component. (match those of the V)
V (Tensor) – The y-component of the velocity or vector field. This tensor complements the U component
field. (pronounced adjustment of the vector)
substeps (int) – The number of iterations for the correction process. This parameter
process (controls the depth of the refinement)
more (with more substeps leading to a)
field.
- Returns:
A tuple containing the modified x and y components (U, V) of the vector field after the pole filtering and Laplacian-based correction have been applied. These components will have undergone adjustments to suppress specified poles and to refine their characteristics based on divergence, vorticity, and Laplacian considerations.
- Return type:
Tuple[Tensor, Tensor]
- polefilt_lap2d_V1(T, substeps)#
Applies a pole filtering transformation followed by a Laplacian-based correction to a scalar in 2D space.
The function aims to modify the scalar field to suppress features associated with specified poles, and to adjust the field based on its divergence, vorticity, and Laplacian properties through a series of spectral domain operations.
- Parameters:
T (Tensor) – scalar-component of the velocity or vector field.
substeps – number of substeps
- Returns:
The modified T components of the scalar field.
- Return type:
Tuple of Tensors
- polefilt_lap2d_QV1(T, substeps)#
Applies a pole filtering transformation followed by a Laplacian-based correction to a scalar in 2D space.
The function aims to modify the scalar field to suppress features associated with specified poles, and to adjust the field based on its divergence, vorticity, and Laplacian properties through a series of spectral domain operations.
- Parameters:
T (Tensor) – scalar-component of the velocity or vector field.
ind_pol (list/int) – Index/indices specifying poles for the filtering process.
- Returns:
The modified T components of the scalar field.
- Return type:
Tuple of Tensors
- diff_lap2d_filt(BB2_tensor)#
- credit.pol_lapdiff_filt.device#