gelsa.sgs.poly#

Functions

fast_cheb_coeffs_kernel(x_norm, y_norm, ...)

x_norm: (N,) normalized x-coordinates y_norm: (N,) normalized y-coordinates

fast_cheb_eval(norm, coeffs)

norm: (N,) normalized wavelength/position values coeffs: (Deg, N) coefficients for EACH point

fast_polyval2d(x, y, m)

Vectorized 2D power series evaluation: sum(m[i,j] * x^i * y^j)

gelsa.sgs.poly.fast_cheb_eval(norm, coeffs)[source]#

norm: (N,) normalized wavelength/position values coeffs: (Deg, N) coefficients for EACH point

cheb on point x_norm[i] = coeffs[0,i]*T0(x_norm[i]) + coeffs[1,i]*T1(x_norm[i]) + …

T0(x) = 1 T1(x) = x Tn(x) = 2*x*T_{n-1}(x) - T_{n-2}(x)

https://en.wikipedia.org/wiki/Chebyshev_polynomials

We use https://en.wikipedia.org/wiki/Clenshaw_algorithm for evaluation (see numpy)

gelsa.sgs.poly.fast_cheb_coeffs_kernel(x_norm, y_norm, model_matrices)[source]#

x_norm: (N,) normalized x-coordinates y_norm: (N,) normalized y-coordinates

model_matrices: (M, DegX, DegY) model matrices. DegX and DegY are usually 3 or 5 and they are equal. model_metrices contains M matrices of coeefficients.

The output is (M, N) where each row corresponds to the evaluated coefficients for each model at the given x and y.

The algorithm is a two-step Clenshaw evaluation (see fast_cheb_eval above):

gelsa.sgs.poly.fast_polyval2d(x, y, m)[source]#

Vectorized 2D power series evaluation: sum(m[i,j] * x^i * y^j)

The algorithm (Horner) is taken from the numpy implementation, that is - instead of increasing the power of the x and y. I start from the highest degree and loop backwards. e.g. Ay^2+By+C, is calculated as ((A⋅y)+B)⋅y+C.

See numpy/numpy