dl: Deep learning operators: Noise2Fringe (n2f, n2fs3d) and Noise2Fringe Transformer (n2ft) filtering¶
moraine.api.dl (source). Every name is also moraine.<name> (import moraine as mr).
download_dl_model
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
str | list
|
deep learning models to be downloaded, all available models by default |
None
|
path
|
str
|
directory to save these models, inside installed Moraine package by default |
None
|
n2f
¶
Noise2Fringe filtering of an interferogram; on the GPU (cupy input) the network runs in half precision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intf
|
ndarray
|
interferogram, 2d np.complex64 or cp.complex64 |
required |
chunks
|
tuple
|
chunksize, intf.shape by default |
None
|
depths
|
tuple
|
width of the boundary |
(0, 0)
|
model
|
str
|
path to the model weights (.pth), use the model comes with this package by default |
None
|
n2fs3d
¶
n2fs3d(adi: ndarray, intf: ndarray, chunks: tuple = None, depths: tuple = (0, 0), model: str = None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adi
|
ndarray
|
amplitude dispersion index, 2d np.float32 or cp.float32 |
required |
intf
|
ndarray
|
interferogram, 2d np.complex64 or cp.complex64 |
required |
chunks
|
tuple
|
chunksize, intf.shape by default |
None
|
depths
|
tuple
|
width of the boundary |
(0, 0)
|
model
|
str
|
path to the model weights (.pth), use the model comes with this package by default |
None
|
n2ft
¶
n2ft(x: ndarray, y: ndarray, intf: ndarray, chunks: int = None, k: int = 128, model: str = None, cuda: bool = False, compile: bool = None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
x coordinate, e.g., longitude, shape (n,) np.floating |
required |
y
|
ndarray
|
y coordinate, e.g., latitude, shape (n,) np.floating |
required |
intf
|
ndarray
|
interferogram, shape(n,) or shape(n,m) np.complex64 |
required |
chunks
|
int
|
chunksize, intf.shape[0] by default |
None
|
k
|
int
|
number of nearest neighbours of every point of a chunk that are filtered with it (halo) |
128
|
model
|
str
|
path to the model weights (.pth), use the model comes with this package by default |
None
|
cuda
|
bool
|
use gpu for inference |
False
|
compile
|
bool
|
compile the model with torch.compile: the model then runs about 3 times faster on a GPU, but the compilation takes 15-40 s once per process (torch caches its result on disk). Default: when points times interferograms is at least 1e8 |
None
|
Examples¶
Run when this manual is built; the output follows each snippet.
The filters need PyTorch and the trained models (moraine.download_dl_model()), so this example is not run when
the manual is built.
import numpy as np
import moraine as mr
mr.download_dl_model() # once; the .pth files go to moraine/dl_model/
# rasters: Noise2Fringe on an interferogram stack (nlines, width, n_pairs), chunked with halos (depths)
intf_filtered = mr.n2f(intf, chunks=(256, 256), depths=(32, 32))
# with the amplitude dispersion index as a second input
intf_filtered = mr.n2fs3d(adi, intf, chunks=(256, 256), depths=(32, 32))
# point clouds: the Noise2Fringe Transformer on (n_points, n_pairs) with the coordinates of the points
intf_filtered = mr.n2ft(lon, lat, intf, chunks=20000, k=128, cuda=True)
The outputs have unit amplitude; the temporal coherence between the filtered and the raw interferograms
(temp_coh) is the quality of a pixel or point.