pl: Phase linking¶
moraine.api.pl (source). Every name is also moraine.<name> (import moraine as mr).
emi
¶
Phase linking with the EMI estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coh
|
ndarray
|
complex coherence of the points (upper triangle of the coherence matrix, all image pairs), dtype complex64, shape (n_points, n_image_pairs), numpy or cupy |
required |
ref
|
int
|
index of the reference image, its phase is set to 0 |
0
|
regularize
|
bool
|
regularize the coherence matrix of the points whose coherence magnitude matrix is not positive definite or numerically singular (e.g. when the number of images approaches the number of independent looks of the SHPs; without it their phase history is not reliable); points with a well conditioned positive definite matrix are not changed |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
phase history |
ds_temp_coh
¶
ds_temp_coh(coh: ndarray, ph: ndarray, image_pairs: ndarray = None, block_size: int = 128, n_looks=None, alpha: float = 0.001)
DS temporal coherence, optionally also weighted by the coherence of the image pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coh
|
ndarray
|
complex coherence of the points as estimated (upper triangle of the coherence matrix), dtype complex64, shape (n_points, n_image_pairs), numpy or cupy |
required |
ph
|
ndarray
|
phase history of the points, dtype complex64, shape (n_points, nimages), unit amplitude; with |
required |
image_pairs
|
ndarray
|
image pairs of |
None
|
block_size
|
int
|
the CUDA block size, a multiple of 32, only applied for cuda |
128
|
n_looks
|
float or ndarray
|
effective number of independent looks of the coherence of each point, float or shape (n_points,),
e.g. from |
None
|
alpha
|
float
|
only with |
1e-3
|
Returns:
| Type | Description |
|---|---|
ndarray or tuple[ndarray, ndarray, ndarray, ndarray]
|
temporal coherence |
emperical_co_emi_temp_coh_pc
¶
emperical_co_emi_temp_coh_pc(rslc: ndarray, idx: ndarray, pc_is_shp: ndarray, batch_size: int = None, regularize: bool = True, weighted: bool = False, alpha: float = 0.001)
Coherence matrix estimation, EMI phase linking and DS temporal coherence of points in one pass, without keeping the coherence matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rslc
|
ndarray
|
rslc stack, dtype complex64, shape (nlines, width, nimages), numpy or cupy |
required |
idx
|
ndarray
|
grid index of the points (azimuth, range) in |
required |
pc_is_shp
|
ndarray
|
SHP masks of the points, dtype bool, shape (n_points, az_win, r_win) |
required |
batch_size
|
int
|
number of points processed at once; the coherence matrices of a batch take 8 bytes per image pair and point, their estimation on the GPU up to 1 GiB more. Default: as many points as 1 GiB of coherence matrices hold |
None
|
regularize
|
bool
|
regularize the coherence matrix in the phase linking as in |
True
|
weighted
|
bool
|
also return the weighted temporal coherence, the effective number of image pairs and the number of
connected components of |
False
|
alpha
|
float
|
|
1e-3
|
Returns:
| Type | Description |
|---|---|
tuple
|
phase history |
Examples¶
Run when this manual is built; the output follows each snippet.
import numpy as np
import moraine as mr
rng = np.random.default_rng(0)
nimages, n_points = 8, 3
phi = rng.uniform(-np.pi, np.pi, (n_points, nimages)) # a true phase history per point
phi[:, 0] = 0
ph_true = np.exp(1j * phi)
lag = np.abs(np.arange(nimages)[:, None] - np.arange(nimages)[None, :])
gamma = 0.7 ** lag # coherence magnitude decaying with the time lag
C = gamma * ph_true[:, :, None] * np.conj(ph_true[:, None, :]) # (n_points, nimages, nimages)
i, j = np.triu_indices(nimages, 1)
coh = C[:, i, j].astype(np.complex64) # compressed, (n_points, n_pairs)
ph = mr.emi(coh) # phase linking, (n_points, nimages), unit amplitude
print(ph.shape, ph.dtype)
print('max phase error [rad]', np.abs(np.angle(ph * np.conj(ph_true))).max().round(4))
t_coh = mr.ds_temp_coh(coh, ph) # how well the linked phases explain the coherence
print('temporal coherence', t_coh.round(3))
Coherence estimated from few looks is often not positive definite; emi regularizes such matrices by default
(regularize=True). With n_looks (from emperical_co_pc) ds_temp_coh also returns the weighted temporal
coherence, the effective number of image pairs and the number of connected components of the coherent pairs,
the quantities the DS selection uses.