Skip to content

metrics

Module for computing quality metrics of estimated solutions.

estimate_temp_coh(cpx_phase, C_arrays)

Estimate the temporal coherence for a block of solutions.

Parameters:

Name Type Description Default
cpx_phase ArrayLike

Complex valued phase linking results from [dolphin.phase_link.run_cpl][] shape = (nslc, rows, cols). If cpx_phase.shape = (nslc,) (a single pixel), will be reshaped to (nslc, 1, 1)

required
C_arrays ArrayLike, shape = (rows, cols, nslc, nslc)

The sample covariance matrix at each pixel (e.g. from dolphin.phase_link.covariance.estimate_stack_covariance). If one covariance matrix is passed (C_arrays.shape = (nslc, nslc)), will be reshaped to (1, 1, nslc, nslc)

required

Returns:

Type Description
Array

The temporal coherence of the time series compared to cov_matrix. Output shape is (rows, cols)

Source code in src/dolphin/phase_link/metrics.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@jit
def estimate_temp_coh(cpx_phase: ArrayLike, C_arrays: ArrayLike) -> Array:
    """Estimate the temporal coherence for a block of solutions.

    Parameters
    ----------
    cpx_phase : ArrayLike
        Complex valued phase linking results from [dolphin.phase_link.run_cpl][]
        shape = (nslc, rows, cols).
        If cpx_phase.shape = (nslc,) (a single pixel), will be reshaped to (nslc, 1, 1)
    C_arrays : ArrayLike, shape = (rows, cols, nslc, nslc)
        The sample covariance matrix at each pixel
        (e.g. from [dolphin.phase_link.covariance.estimate_stack_covariance][]).
        If one covariance matrix is passed (C_arrays.shape = (nslc, nslc)),
        will be reshaped to (1, 1, nslc, nslc)

    Returns
    -------
    jax.Array
        The temporal coherence of the time series compared to cov_matrix.
        Output shape is (rows, cols)

    """
    if cpx_phase.ndim == 1:
        cpx_phase = cpx_phase.reshape(1, 1, -1)
    if C_arrays.ndim == 2:
        C_arrays = C_arrays.reshape(1, 1, *C_arrays.shape)

    _temp_coh_3d = vmap(estimate_temp_coh_single)
    estimate_temp_coh = vmap(_temp_coh_3d)
    return estimate_temp_coh(cpx_phase, C_arrays)

estimate_temp_coh_single(cpx_phase, C)

Estimate the temporal coherence for one covariance matrix/phase solution.

Parameters:

Name Type Description Default
cpx_phase ArrayLike

1D-Complex valued phase linking results from [dolphin.phase_link.run_cpl][]

required
C ArrayLike, shape = (nslc, nslc)

The sample covariance matrix at one pixel.

required

Returns:

Type Description
Array

The temporal coherence of the time series compared to cov_matrix. Output shape is ()

Source code in src/dolphin/phase_link/metrics.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@jit
def estimate_temp_coh_single(cpx_phase: ArrayLike, C: ArrayLike) -> Array:
    """Estimate the temporal coherence for one covariance matrix/phase solution.

    Parameters
    ----------
    cpx_phase : ArrayLike
        1D-Complex valued phase linking results from [dolphin.phase_link.run_cpl][]
    C : ArrayLike, shape = (nslc, nslc)
        The sample covariance matrix at one pixel.

    Returns
    -------
    jax.Array
        The temporal coherence of the time series compared to cov_matrix.
        Output shape is ()

    """
    # For original Squeesar temp coh, everything is equally weighted
    W = jnp.ones(C.shape, dtype="float32")
    return _general_temp_coh_single(cpx_phase=cpx_phase, C=C, W=W)

estimate_weighted_temp_coh_single(cpx_phase, C)

Estimate the weighted temporal coherence for one pixel.

Source code in src/dolphin/phase_link/metrics.py
66
67
68
69
70
71
@jit
def estimate_weighted_temp_coh_single(cpx_phase: ArrayLike, C: ArrayLike) -> Array:
    """Estimate the weighted temporal coherence for one pixel."""
    # Weight the differences by pass in weights coherence magnitudes
    W = jnp.abs(C)
    return _general_temp_coh_single(cpx_phase=cpx_phase, C=C, W=W)