Slepians.jl
This repo includes codes to compute discrete prolate spheroidal sequences, generalized prolate spheroidal sequences (unequal sampling), and solves the special case of d-dimensional concentration in the Cartesian plane where the function is restricted to the disc in the spectral domain.
These docs are under construction, but I will include the docstrings for the main functions here.
Index of functions
Slepians.blob
— Functionblob(N, Nj)
Makes moving picture of a random blob by superposition of random circles
Arguments
N
number of loops for, and if movie, default = 100Nj
smoothness, roughly (?)
Outputs
x
y
Slepians.closedcurve_2d
— Methodclosedcurve_2d(xs, ys)
Generate a closed curve based on (x, y) points given and Euclidean distance
Arguments
xs
x coordinates of the pointsys
y coordinates of the points
Outputs
xpath
x coordinates of the pathypath
y coordinates of the path
Slepians.conv
— Methodconv(x,y)
Convolves two arrays of the same length using FFT algorithm
Arguments
x::Array{Number}
: first arrayy::Array{Number}
: second array
Outputs
- Array containing the real part of the convolution of x and y
Slepians.degamini
— Methoddegamini(v)
Arguments
v
A vector with repeated entries
Outputs
dv
The same vector with all the repeat sset to 1foldi
A same-dimensional vector with how many repeats there arebe
A matrix with begin and end indices into the original vector
Example
dv, foldi, be = degamini([1, 2, 2, 3])
answer is dv = [1, 2, 3]; foldi = [1, 2, 1]; be = [1 1; 2 3; 4 4]
Slepians.dpss_eigval
— Methoddpss_eigval(dpVecs, n, nw, ntapers)
Eigenvalues/concentrations for the Slepian sequences, given the vectors (Percival 390)
Arguments
dpVecs
: (n x ntapers) Matrix in which Slepian eigenvectors are the columnsn
: Integer length of the datanw
: Float time bandwidth productntapers
: Integer number of tapers
Outputs
eeigvalss
: Vector of lengthhntapers
containing the eigenvalues
Slepians.dpss_tapers
— Functiondpss_tapers(n,w,k,tap_or_egval)
Simply compute discrete prolate spheroidal sequence tapers, eigenvalues
...
Arguments
n::Int64
: Length of the tapernw::Float64
: Time-bandwidth productk::Int64
: Number of taperstap_or_egval::Symbol = :tap
: Either :tap, :egval, or :both
...
...
Outputs
vv::Vector{Float64}
: The matrix of eigenvalues, if taporegval is set to :tapdpss_eigval
: Struct conaining the dpss tapers
...
Slepians.findnst
— Methodfindnst(xs, ys, x0, y0)
Find the nearest 2D point in arrays xs, ys to (x0, y0) Euclidean distance
Slepians.gamini
— Functiongamini(data, folding)
Arguments
-data
: some data vector -folding
: The replication factor for every element of the data; if a scalar thsi applies to all of the elements (default 3), if zero or negative, no replication occurs
Outputs
-bigger
Example usage
a, b = degamini(gamini([1, 2, 3, 1, 4, 5], [1, 2, 3, 2, 4, 2]))
One gets [1, 2, 2, 3, 3, 3, 1, 1, 4, 4, 4, 4, 5, 5] as the intermediate result.
See also
@degamini, @gamini2
Slepians.get_plan
— Methodget_plan(n)
Obtain an FFT plan
Arguments
n::Int64
: Length of the FFT plan
Outputs
- Tuple containing two ComplexF64 arrays of length
n
and an FFT plan
Slepians.getbdypts_2d
— Methodgetbdypts_2d(mask)
Starting with a matrix of zeros and ones, get the points on the boundary
Arguments
- `mask` a matrix of zeros and ones
Outputs
- `x` x-coordinates of the boundary points
- `y` y-coordinates of the boundary points
Slepians.gpss
— Methodgpss(w, k, t, f; <keyword arguments>)
Generalized prolate spheroidal sequences on an unequal grid
...
Arguments
Positional Arguments
w::Float64
: the bandwidthk::Int64
: number of Slepian tapers, must be <=2bwlength(x)t::Vector{Int64}
: vector containing the time indicesf::Float64
: frequency at which the tapers are to be computed
Keyword Arguments
beta::Float64 = 0.5
: analysis half-bandwidth (similar to Nyquist rate)
...
...
Outputs
lambda::Vector{Float64}
the concentrations of the generalized prolate spheroidal
sequences
u::Matrix{Float64}
the matrix containing the sequences themselvesR
the Cholesky factor for the generalized eigenvalue problem
...
See also: gpss_orth
Slepians.gpss_orth
— Methodgpss_orth(w, k, t, f; <keyword arguments>)
Generalized, orthogonalized prolate spheroidal sequences on an unequal grid
...
Arguments
Positional Arguments
w::Float64
: the bandwidthk::Int64
: number of Slepian tapers, must be <=2bwlength(x)t::Vector{Int64}
: vector containing the time indicesf::Float64
: frequency at which the tapers are to be computed
Keyword Arguments
beta::Float64 = 0.5
: analysis half-bandwidth (similar to Nyquist rate)
...
...
Outputs
lambda::Vector{Float64}
the concentrations of the generalized prolate spheroidal
sequences
u::Matrix{Float64}
the matrix containing the sequences themselves, equivalent to
u*R for the ordinary gpss
routine.
...
See also: gpss
Slepians.interp1
— Functioninterp1()
1D data interpolation, linear https://www.mathworks.com/help/matlab/ref/interp1.html?stid=docta
Arguments
- Vector x contains the sample points, and
- v contains the corresponding values, v(x).
- Vector xq contains the coordinates of the query points.
Outputs
- interpolated values of a 1-D function at specific query points using linear interpolation
Example usage
interp1(LinRange(0, 1, 10), log10.(LinRange(0, 1, 10)), [0.5, 0.9], :linear)
Slepians.interp2
— Functioninterp2(z, xy, z0)
Arguments
z::Vector
vector of z'syx::Matrix
y, x coordinates at each of the z'sz0<:Number
level at which to interpolate z0
Outputs
- zyx coordinates corresponding to level z0
Slepians.interpcontour
— Methodinterpcontour(z, z0, thph, N)
Arguments
z::Vector
the two z-values between which the level z0 falls.z0<:Number
the z-level of the desired contourthph::Matrix
the zyx coordinates (first N are at level z[1] second are at level z[2])N::Int64
number of points for each contour
Slepians.matranges
— Methodmatranges(ranges)
Makes an index vector with monotonically increasing indices between pairs of numbers supplied as input. From slepian_alpha
Arguments
ranges
Outputs
Example
matranges([1, 4, 1, 2, -1, 2])
# answer is [1, 2, 3, 4, 1, 2, -1, 0, 1, 2]
Slepians.mdslepian
— Methodmdslepian(w, k, t)
Generalized prolate spheroidal sequences for the 1D missing data problem
...
Arguments
Positional Arguments
w::Float64
: the bandwidthk::Int64
: number of Slepian tapers, must be <=2bwlength(x)t::Vector{Int64}
: vector containing the time indices
...
...
Outputs
lambda,u::Tuple{Vector{Float64}, Vector{Float64}}
: tuple containing the
concentrations and the tapers
...
See also: mdmultispec
, gpss
Slepians.phicurve
— Methodphicurve(thph, th)
Adapted from slepian_alpha; finds the longitude crossings and thus integration domains of a closed curve parameterized in colatitude/longitude space at certian query points of colatitude.
Arguments
thph::
Colatitude/longitude of the closed curve (degrees)th::
Colatitude at which crossings are required (degrees)
Outputs
phint
A matrix with crossings/intervals and zeros of dimensions MxN where M = length(th) and N can be anything depending on the oscillations of the curvethp
Colatitude matrix for hatched plotting, if possiblephp
Longitude matrix for hatched plotting, if possibleforreal
Indices of the ones that are real (could be at zero)
Depends on: @sub2ind, @interp1, @degamini, @matranges, and possibly @blob (demo2)
Slepians.quadpts
— Methodquadpts(qx, Nqx, qy, forreal, xints, wqx, wqy)
Scale the quaduature points and weights
Arguments
qx
Nqx
qy
forreal
xints
wqx
wqy
Outputs
QX
Quadrature points in xQY
Quadrature points in yw
Quadrature weightsNrun
Number of horizontal line segments in the domain
Slepians.randcirc
— Functionrandcirc(xm, ym, r,dr, N)
Arguments
- xm horizontal positon of the center
- ym vertical position of the center
r
radiusdr
size of random perturbations around the radiusN
number of random spike points
Outputs
x
x-coordinatey
y-coordinate
Related
@blob
Slepians.sub2ind
— Methodsub2ind(A, row, col)
Convert to linear indices https://www.mathworks.com/help/matlab/ref/sub2ind.html