co: Covariance and coherence matrix estimation¶
moraine.api.co(源码)。每个名字也是 moraine.<name>(import moraine as mr)。
multi_look
¶
multi looked interferogram for raster data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rslc1
|
reference rslc |
required | |
rslc2
|
secondary rslc |
required | |
looks
|
default: (1, 1)
|
range and azimuth looks¶ |
(1, 1)
|
intf
¶
1 by 1 look interferogram for both raster and point cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rslc1
|
reference rslc, arbitrary dims, e.g., 3D(raster stack), 2D(raster or point cloud stack) or 1D(point cloud) |
required | |
rslc2
|
secondary rslc |
required |
emperical_co
¶
Maximum likelihood covariance estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rslc
|
ndarray
|
rslc stack, dtype: |
required |
is_shp
|
ndarray
|
shp bool, dtype: |
required |
block_size
|
int
|
no effect, kept for compatibility |
128
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
the covariance and coherence matrix |
emperical_co_pc
¶
emperical_co_pc(rslc: ndarray, idx: ndarray, pc_is_shp: ndarray, block_size: int = 128, image_pairs: ndarray = None, return_n_looks: bool = False)
Maximum likelihood covariance estimator for point cloud data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rslc
|
ndarray
|
rslc stack, dtype: |
required |
idx
|
ndarray
|
index of point target (azimuth_index, range_index), dtype: |
required |
pc_is_shp
|
ndarray
|
shp bool, dtype: |
required |
block_size
|
int
|
no effect, kept for compatibility |
128
|
image_pairs
|
ndarray
|
only coherence of those image pairs will estimated, dtype: |
None
|
return_n_looks
|
bool
|
also return the effective number of independent looks of the SHP set of each point |
False
|
Returns:
| Type | Description |
|---|---|
ndarray or tuple[ndarray, ndarray]
|
|
uncompress_coh
¶
uncompress coh matrix to a hermitian matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coh
|
ndarray
|
compressed coherence stack, dtype: |
required |
image_pairs
|
ndarray
|
image pairs, dtype: |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
uncompressed, dtype: |
ad_intf_pc
¶
ad_intf_pc(ref_rslc: ndarray, sec_rslc: ndarray, idx: ndarray, pc_is_shp: ndarray, block_size: int = 128) -> ndarray
Adaptive multilooking interferogram generation for point cloud data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_rslc
|
ndarray
|
reference rslc, dtype: |
required |
sec_rslc
|
ndarray
|
secondary rslc, dtype: |
required |
idx
|
ndarray
|
index of point target (azimuth_index, range_index), dtype: |
required |
pc_is_shp
|
ndarray
|
shp bool, dtype: |
required |
block_size
|
int
|
the CUDA block size, it only affects the calculation speed |
128
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
isPD
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
co
|
ndarray
|
absolute value of complex coherence/covariance stack |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
bool array indicating wheather coherence/covariance is positive define |
nearestPD
¶
Find the nearest positive-definite matrix to input matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
co
|
ndarray
|
stack of matrix with shape [...,N,N] |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
nearest positive definite matrix of input, shape [...,N,N] |
regularize_spectral
¶
Spectral regularizer for coherence matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coh
|
ndarray
|
stack of matrix with shape [...,N,N] |
required |
beta
|
Union[float, ndarray]
|
the regularization parameter, a float number or cupy ndarray with shape [...] |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
regularized matrix, shape [...,N,N] |
示例¶
构建本手册时运行;输出紧随每段代码。
import numpy as np
import moraine as mr
rng = np.random.default_rng(0)
nlines, width, nimages = 20, 30, 10
rslc = (rng.standard_normal((nlines, width, nimages)) + 1j * rng.standard_normal((nlines, width, nimages))).astype(np.complex64)
idx = np.array([[5, 5], [10, 15]], dtype=np.int32) # (azimuth, range) of two points
pc_is_shp = np.ones((2, 5, 5), dtype=bool) # their SHPs in a 5 x 5 window (all here)
coh = mr.emperical_co_pc(rslc, idx, pc_is_shp) # compressed coherence, (n_points, n_pairs)
print(coh.shape, coh.dtype)
C = mr.uncompress_coh(coh) # full hermitian matrices, (n_points, nimages, nimages)
print(C.shape, np.allclose(np.diagonal(C, axis1=1, axis2=2).real, 1, atol=1e-5))
print(mr.isPD(np.abs(C))) # is the coherence magnitude matrix positive definite?
bad = np.abs(C[0]).copy()
bad[0, 1] = bad[1, 0] = 1.5 # not a valid coherence matrix any more
print(mr.isPD(bad[None])[0], mr.isPD(mr.nearestPD(bad[None]))[0])
intf = mr.intf(np.ascontiguousarray(rslc[..., 0]), np.ascontiguousarray(rslc[..., 1])) # 1 x 1 look interferogram of two images
print(intf.shape, intf.dtype)
The compressed layout is the upper triangle in the order of numpy.triu_indices(nimages, 1) (data contract);
emperical_co_pc(..., return_n_looks=True) also gives the effective number of independent looks of each SHP set,
the input of the weighted DS temporal coherence.