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.blobFunction
blob(N, Nj)

Makes moving picture of a random blob by superposition of random circles

Arguments

  • N number of loops for, and if movie, default = 100
  • Nj smoothness, roughly (?)

Outputs

  • x
  • y
source
Slepians.closedcurve_2dMethod
closedcurve_2d(xs, ys)

Generate a closed curve based on (x, y) points given and Euclidean distance

Arguments

  • xs x coordinates of the points
  • ys y coordinates of the points

Outputs

  • xpath x coordinates of the path
  • ypath y coordinates of the path
source
Slepians.convMethod
conv(x,y)

Convolves two arrays of the same length using FFT algorithm

Arguments

  • x::Array{Number}: first array
  • y::Array{Number}: second array

Outputs

  • Array containing the real part of the convolution of x and y
source
Slepians.degaminiMethod
degamini(v)

Arguments

  • v A vector with repeated entries

Outputs

  • dv The same vector with all the repeat sset to 1
  • foldi A same-dimensional vector with how many repeats there are
  • be 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]

source
Slepians.dpss_eigvalMethod
dpss_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 columns
  • n: Integer length of the data
  • nw: Float time bandwidth product
  • ntapers: Integer number of tapers

Outputs

  • eeigvalss: Vector of lengthh ntapers containing the eigenvalues
source
Slepians.dpss_tapersFunction
dpss_tapers(n,w,k,tap_or_egval)

Simply compute discrete prolate spheroidal sequence tapers, eigenvalues

...

Arguments

  • n::Int64: Length of the taper

  • nw::Float64: Time-bandwidth product

  • k::Int64: Number of tapers

  • tap_or_egval::Symbol = :tap: Either :tap, :egval, or :both

...

...

Outputs

  • vv::Vector{Float64}: The matrix of eigenvalues, if taporegval is set to :tap

  • dpss_eigval: Struct conaining the dpss tapers

...

source
Slepians.findnstMethod
findnst(xs, ys, x0, y0)

Find the nearest 2D point in arrays xs, ys to (x0, y0) Euclidean distance

source
Slepians.gaminiFunction
gamini(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

source
Slepians.get_planMethod
get_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
source
Slepians.getbdypts_2dMethod
getbdypts_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
source
Slepians.gpssMethod
gpss(w, k, t, f; <keyword arguments>)

Generalized prolate spheroidal sequences on an unequal grid

...

Arguments

Positional Arguments

  • w::Float64: the bandwidth

  • k::Int64: number of Slepian tapers, must be <=2bwlength(x)

  • t::Vector{Int64}: vector containing the time indices

  • f::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

  • R the Cholesky factor for the generalized eigenvalue problem

...

See also: gpss_orth

source
Slepians.gpss_orthMethod
gpss_orth(w, k, t, f; <keyword arguments>)

Generalized, orthogonalized prolate spheroidal sequences on an unequal grid

...

Arguments

Positional Arguments

  • w::Float64: the bandwidth

  • k::Int64: number of Slepian tapers, must be <=2bwlength(x)

  • t::Vector{Int64}: vector containing the time indices

  • f::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

source
Slepians.interp1Function
interp1()

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)
source
Slepians.interp2Function
interp2(z, xy, z0)

Arguments

  • z::Vector vector of z's
  • yx::Matrix y, x coordinates at each of the z's
  • z0<:Number level at which to interpolate z0

Outputs

  • zyx coordinates corresponding to level z0
source
Slepians.interpcontourMethod
interpcontour(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 contour
  • thph::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
source
Slepians.matrangesMethod
matranges(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]
source
Slepians.mdslepianMethod
mdslepian(w, k, t)

Generalized prolate spheroidal sequences for the 1D missing data problem

...

Arguments

Positional Arguments

  • w::Float64: the bandwidth

  • k::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

source
Slepians.phicurveMethod
phicurve(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 curve
  • thp Colatitude matrix for hatched plotting, if possible
  • php Longitude matrix for hatched plotting, if possible
  • forreal Indices of the ones that are real (could be at zero)

Depends on: @sub2ind, @interp1, @degamini, @matranges, and possibly @blob (demo2)

source
Slepians.quadptsMethod
quadpts(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 x
  • QY Quadrature points in y
  • w Quadrature weights
  • Nrun Number of horizontal line segments in the domain
source
Slepians.randcircFunction
randcirc(xm, ym, r,dr, N)

Arguments

  • xm horizontal positon of the center
  • ym vertical position of the center
  • r radius
  • dr size of random perturbations around the radius
  • N number of random spike points

Outputs

  • x x-coordinate
  • y y-coordinate

Related

@blob

source
Slepians.sub2indMethod
sub2ind(A, row, col)

Convert to linear indices https://www.mathworks.com/help/matlab/ref/sub2ind.html

source