source
download_dl_model
download_dl_model (models:str|list=None, path:str=None)
| models |
str | list |
None |
deep learning models to be downloaded, all available models by default |
| path |
str |
None |
directory to save these models, inside installed Moraine package by default |
Deep learning models have to be installed before use, download them by:
Downloading https://raw.githubusercontent.com/kanglcn/n2f/refs/heads/main/n2f.onnx to /work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2f.onnx
File '/work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2f.onnx' downloaded successfully.
Downloading https://raw.githubusercontent.com/kanglcn/n2f/refs/heads/main/n2fs3d.onnx to /work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2fs3d.onnx
File '/work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2fs3d.onnx' downloaded successfully.
Downloading https://raw.githubusercontent.com/kanglcn/n2ft/refs/heads/main/n2ft.onnx to /work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2ft.onnx
File '/work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2ft.onnx' downloaded successfully.
Downloading https://raw.githubusercontent.com/kanglcn/n2ft/refs/heads/main/n2ft.onnx.data to /work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2ft.onnx.data
File '/work/projects/jinwook/radarlab/kangl/moraine/moraine/dl_model/n2ft.onnx.data' downloaded successfully.
source
n2f
n2f (intf:numpy.ndarray, chunks:tuple=None, depths:tuple=(0, 0),
model:str=None)
| intf |
ndarray |
|
interferogram, 2d np.complex64 or cp.complex64 |
| chunks |
tuple |
None |
chunksize, intf.shape by default |
| depths |
tuple |
(0, 0) |
width of the boundary |
| model |
str |
None |
path to the model in onnx format, use the model comes with this package by default |
Usage:
import zarr
import numpy as np
import holoviews as hv
hv.extension('bokeh')
hv.output(widget_location='bottom')
from bokeh.models import WheelZoomTool
from holoviews import opts
ⓘ
rslc_zarr = zarr.open('../CLI/raw/rslc.zarr/',mode='r')
intf = rslc_zarr[:,:,7]*rslc_zarr[:,:,13].conj()
filtered_intf = n2f(intf,depths=(10,10))
CPU times: user 2min 44s, sys: 9.54 s, total: 2min 54s
Wall time: 7.04 s
raw_intf_plot = mr.ras_plot(np.angle(intf))
filtered_intf_plot = mr.ras_plot(np.angle(filtered_intf))
(raw_intf_plot+filtered_intf_plot).opts(
opts.Image(
cmap='colorwheel',width=600, height=600, colorbar=True,invert_yaxis=True,
default_tools=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
active_tools=['wheel_zoom'])
)
source
n2fs3d
n2fs3d (adi:numpy.ndarray, intf:numpy.ndarray, chunks:tuple=None,
depths:tuple=(0, 0), model:str=None)
| adi |
ndarray |
|
amplitude dispersion index, 2d np.float32 or cp.float32 |
| intf |
ndarray |
|
interferogram, 2d np.complex64 or cp.complex64 |
| chunks |
tuple |
None |
chunksize, intf.shape by default |
| depths |
tuple |
(0, 0) |
width of the boundary |
| model |
str |
None |
path to the model in onnx format, use the model comes with this package by default |
Usage:
import zarr
import numpy as np
import holoviews as hv
hv.extension('bokeh')
hv.output(widget_location='bottom')
from bokeh.models import WheelZoomTool
from holoviews import opts
ⓘ
rslc_zarr = zarr.open('../CLI/raw/rslc.zarr/',mode='r')
intf = rslc_zarr[:,:,7]*rslc_zarr[:,:,13].conj()
adi = zarr.open('../CLI/ps/adi.zarr/',mode='r')[:]
filtered_intf = n2fs3d(adi,intf,depths=(200,200))
CPU times: user 2min 36s, sys: 12 s, total: 2min 48s
Wall time: 6.47 s
if is_cuda_available():
intf_cp = cp.asarray(intf)
adi_cp = cp.asarray(adi)
filtered_intf_cp = n2fs3d(adi_cp,intf_cp)
CPU times: user 1 s, sys: 170 ms, total: 1.17 s
Wall time: 998 ms
source
n2ft
n2ft (x:numpy.ndarray, y:numpy.ndarray, intf:numpy.ndarray,
chunks:int=None, k:int=128, model:str=None, cuda:bool=False)
| x |
ndarray |
|
x coordinate, e.g., longitude, shape (n,) np.floating |
| y |
ndarray |
|
y coordinate, e.g., latitude, shape (n,) np.floating |
| intf |
ndarray |
|
interferogram, shape(n,) np.complex64 |
| chunks |
int |
None |
chunksize, intf.shape[0] by default |
| k |
int |
128 |
halo size for chunkwise processing |
| model |
str |
None |
path to the model in onnx format, use the model comes with this package by default |
| cuda |
bool |
False |
use gpu for inference |
Usage:
base = '../Tutorials/CLI/ps_processing/'
ps_can_rslc_zarr = zarr.open(base+'hix/ps_can_rslc.zarr/',mode='r')
ps_can_y = zarr.open(base+'hix/ps_can_n.zarr',mode='r')[:]
ps_can_x = zarr.open(base+'hix/ps_can_e.zarr',mode='r')[:]
ps_can_lon = zarr.open(base+'hix/ps_can_lon.zarr',mode='r')[:]
ps_can_lat = zarr.open(base+'hix/ps_can_lat.zarr',mode='r')[:]
ps_can_intf = ps_can_rslc_zarr[:,10]*ps_can_rslc_zarr[:,13].conj()
out = n2ft(ps_can_lon, ps_can_lat, ps_can_intf,)
CPU times: user 1min 55s, sys: 14.2 s, total: 2min 9s
Wall time: 12.7 s
out = n2ft(ps_can_lon, ps_can_lat, ps_can_intf, chunks=50000, cuda=True)
CPU times: user 7.61 s, sys: 2.03 s, total: 9.64 s
Wall time: 5.15 s
out = n2ft(ps_can_lon, ps_can_lat, ps_can_intf, chunks=20000)
CPU times: user 5min 10s, sys: 6.06 s, total: 5min 16s
Wall time: 19.4 s
import moraine as mr
import holoviews as hv
import numpy as np
import zarr
from holoviews import opts
from bokeh.models import WheelZoomTool
hv.extension('bokeh')
ⓘ
intf_plot = mr.pc_plot(np.angle(ps_can_intf),ps_can_y,ps_can_x)
intf_plot = intf_plot[0]*intf_plot[1]
intf_filt_plot = mr.pc_plot(np.angle(out),ps_can_y,ps_can_x)
intf_filt_plot = intf_filt_plot[0]*intf_filt_plot[1]
intf_plot = intf_plot.redim(
x=hv.Dimension('lon', label='Longitude'), y=hv.Dimension('lat',label='Latitude'),
z=hv.Dimension('intf',label='Phase',range=(-np.pi,np.pi)),
)
intf_filt_plot = intf_filt_plot.redim(
x=hv.Dimension('lon', label='Longitude'), y=hv.Dimension('lat',label='Latitude'),
z=hv.Dimension('intf',label='Phase',range=(-np.pi,np.pi)),
)
(intf_plot+intf_filt_plot).opts(
opts.Image(
cmap='colorwheel',width=600, height=400, colorbar=True,
default_tools=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
active_tools=['wheel_zoom']
),
opts.Points(
color='intf', cmap='colorwheel',width=600, height=400, colorbar=True,
default_tools=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
active_tools=['wheel_zoom']
)
)