Inversion Routines
These routines are used for size distribution inversion.
Index
Functions
setupRegularization
DifferentialMobilityAnalyzers.setupRegularization
— FunctionsetupRegularization(𝐀, 𝐈, B, X₀, n)
Initialize the Regvars used to compute the Tikhonov regularization. Regvars is a data type that stores the inversion problem setup. It also stores the precomputed A'A matrix for performance optimization
- A is the convolution matrix
- I is the identity matrix
- B is the response vector
- X0 is the initial guess
- n is the number of BLAS threads
Ninv
DifferentialMobilityAnalyzers.Ninv
— FunctionNinv(λ)
This function computes the regularized inverse for a specified regularization parameter λ. This requires that the problem is iniatialized throug setupRegularization. Use the clean function to truncate negative values.
Example Usage
# R is the response vector
setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)
N = clean(Ninv(0.5))
rinv
DifferentialMobilityAnalyzers.rinv
— Functionrinv(R::AbstractVector, δ::DifferentialMobilityAnalyzer; λ₁ = 1e-2, λ₂ = 1e1, n = 1)
This function is included to maintain backward compatibility with older code. Consider switching to rinv2 instead.
The function rinv is a wrapper to perform the Tikhonov inversion.
- R the response vector to be inverted
- δ the DifferentialMobilityAnalyzer from which R was produced
- λ₁ and λ₂ are the bounds of the search for the optical regularization parameter
- n is the number of BLAS threads to use (currently 1 is fastest)
The function returns an inverted size distribution of type SizeDistribution
Example Usage
# Load Data
df = CSV.read("example_data.csv", DataFrame)
# Setup the DMA
t, p, lpm = 293.15, 940e2, 1.666e-5
r₁, r₂, l = 9.37e-3,1.961e-2,0.44369
Λ = DMAconfig(t,p,1lpm,4lpm,r₁,r₂,l,0.0,:+,6,:cylindrical)
δ = setupDMA(Λ, vtoz(Λ,10000), vtoz(Λ,10), 120)
# Interpolate the data onto the DMA grid
𝕣 = (df, :Dp, :Rcn, δ) |> interpolateDataFrameOntoδ
# Compute the inverse.
𝕟ⁱⁿᵛ = rinv(𝕣.N, δ, λ₁ = 0.1, λ₂ = 1.0)
rinv2
DifferentialMobilityAnalyzers.rinv2
— Functionrinv2(
R::AbstractVector,
δ::DifferentialMobilityAnalyzer;
λ₁ = 1e-2,
λ₂ = 1e1,
order = 0,
initial = true,
n = 1,
)
- R the response vector to be inverted
- δ the DifferentialMobilityAnalyzer from which R was produced
- λ₁ and λ₂ are the bounds of the search for the optical regularization parameter
- order is 0, 1, or 2 corresponding to 0th, 1st, and 2nd order Tikhonov
- use a priori estimate from Tadlukdar and Swihart (2003) method: true/false
- n is the number of BLAS threads to use (currently 1 is fastest)
The function rinv2 is a wrapper to perform the Tikhonov inversion using RegularizationTools. The function supersedes rinv. It has more flexibility. For default inputs
𝕟ᵢₙᵥ = rinv(R, δ)
𝕟ᵢₙᵥ = rinv2(R, δ)
the two function should produce nearly identical results. The main difference is that rinv2 used generalized cross validation instead of the L-curve method. The switch improves stability and spreed. The default setting is 0th order + initial guess, which is identical to what is assumed in the rinv1 algorithm. Note that 0th order without initial guess produces poor results.
The function returns an inverted size distribution of type SizeDistribution
Example Usage
# Load Data
df = CSV.read("example_data.csv", DataFrame)
# Setup the DMA
t, p, lpm = 293.15, 940e2, 1.666e-5
r₁, r₂, l = 9.37e-3,1.961e-2,0.44369
Λ = DMAconfig(t,p,1lpm,4lpm,r₁,r₂,l,0.0,:+,6,:cylindrical)
δ = setupDMA(Λ, vtoz(Λ,10000), vtoz(Λ,10), 120)
# Interpolate the data onto the DMA grid
𝕣 = (df, :Dp, :Rcn, δ) |> interpolateDataFrameOntoδ
# Compute the inverse
𝕟ⁱⁿᵛ = rinv2(𝕣.N, δ, λ₁ = 0.1, λ₂ = 1.0)
L1
DifferentialMobilityAnalyzers.L1
— FunctionL1(λ::AbstractFloat)
Returns the L1 norm for regularization parameter λ
Example Usage
# R is the response vector
setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)
L1 = L1(0.5)
L2
DifferentialMobilityAnalyzers.L2
— FunctionL2(λ::Float64)
Returns the L2 norm for regularization parameter λ
Example Usage
# R is the response vector
setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)
L2 = L2(0.5)
L1L2
DifferentialMobilityAnalyzers.L1L2
— FunctionL1L2(λ::AbstractFloat)
Returns the L1 and L2 norm for regularization parameter λ
Example Usage
# R is the response vector
setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)
L1, L2 = L1L2(0.5)