Inversion Routines

These routines are used for size distribution inversion.

Index

    Functions

    setupRegularization

    DifferentialMobilityAnalyzers.setupRegularizationFunction
    setupRegularization(𝐀, 𝐈, 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
    source

    Ninv

    DifferentialMobilityAnalyzers.NinvFunction
    Ninv(λ)

    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))                           
    source

    rinv

    DifferentialMobilityAnalyzers.rinvFunction
    rinv(R::AbstractVector, δ::DifferentialMobilityAnalyzer; λ₁ = 1e-2, λ₂ = 1e1, n = 1)
    Warning

    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)
    source

    rinv2

    DifferentialMobilityAnalyzers.rinv2Function
    rinv2(
        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)
    source

    L1

    DifferentialMobilityAnalyzers.L1Function
    L1(λ::AbstractFloat)

    Returns the L1 norm for regularization parameter λ

    Example Usage

    # R is the response vector
    setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)  
    L1 = L1(0.5)
    source

    L2

    DifferentialMobilityAnalyzers.L2Function
    L2(λ::Float64)

    Returns the L2 norm for regularization parameter λ

    Example Usage

    # R is the response vector
    setupRegularization(δ.𝐀, δ.𝐈, R, inv(δ.𝐒) * R, n)  
    L2 = L2(0.5)
    source

    L1L2

    DifferentialMobilityAnalyzers.L1L2Function
    L1L2(λ::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)
    source