import moraine.cli as mc
import zarr
import numpy as np
import toml
import holoviews as hv
from bokeh.models import WheelZoomTool
Phase Unwrapping
phase unwrapping
'bokeh')
hv.extension(='bottom') hv.output(widget_location
gamma_mcf_pt
gamma_mcf_pt (pc_x:str, pc_y:str, ph:str, unw_ph:str, image_pairs:numpy.ndarray, ref_point:int=1, out_chunks:int=None, n_workers=1, threads_per_worker=2, **dask_cluster_arg)
A wrapper for mcf_pt in GAMMA software.
Type | Default | Details | |
---|---|---|---|
pc_x | str | x coordinate, shape of (N,) | |
pc_y | str | y coordinate, shape of (N,) | |
ph | str | stack of wrapped phase, shape of (N,M) | |
unw_ph | str | output, unwrapped phase, shape of (N,L) | |
image_pairs | ndarray | image pairs to construct interferograms for unwrapping | |
ref_point | int | 1 | reference point, the first point by default |
out_chunks | int | None | unw_ph point cloud chunk size, same as ph by default |
n_workers | int | 1 | number of dask worker, number of interferograms to be unwrapped in the same time |
threads_per_worker | int | 2 | number of threads per dask worker |
dask_cluster_arg | VAR_KEYWORD |
Usage:
= mc.get_logger() logger
# load phase-linked wrapped phase
= './pu/ds_ph.zarr/'
ds_ph = './pu/ds_e.zarr/'
ds_e = './pu/ds_n.zarr/'
ds_n = './pu/ds_unw.zarr/'
ds_unw = zarr.open(ds_ph,'r')
ds_ph_zarr = mr.TempNet.from_bandwidth(ds_ph_zarr.shape[1],bandwidth=1) tnet
gamma_mcf_pt(ds_e, ds_n, ds_ph, ds_unw, tnet.image_pairs)
2025-06-24 22:01:17 - log_args - INFO - running function: gamma_mcf_pt
2025-06-24 22:01:17 - log_args - INFO - fetching args:
2025-06-24 22:01:17 - log_args - INFO - pc_x = './pu/ds_e.zarr/'
2025-06-24 22:01:17 - log_args - INFO - pc_y = './pu/ds_n.zarr/'
2025-06-24 22:01:17 - log_args - INFO - ph = './pu/ds_ph.zarr/'
2025-06-24 22:01:17 - log_args - INFO - unw_ph = './pu/ds_unw.zarr/'
2025-06-24 22:01:17 - log_args - INFO - image_pairs = array([[ 0, 1],
[ 1, 2],
[ 2, 3],
[ 3, 4],
[ 4, 5],
[ 5, 6],
[ 6, 7],
[ 7, 8],
[ 8, 9],
[ 9, 10],
[10, 11],
[11, 12],
[12, 13],
[13, 14],
[14, 15],
[15, 16]], dtype=int32)
2025-06-24 22:01:17 - log_args - INFO - ref_point = 1
2025-06-24 22:01:17 - log_args - INFO - out_chunks = None
2025-06-24 22:01:17 - log_args - INFO - n_workers = 1
2025-06-24 22:01:17 - log_args - INFO - threads_per_worker = 2
2025-06-24 22:01:17 - log_args - INFO - dask_cluster_arg = {}
2025-06-24 22:01:17 - log_args - INFO - fetching args done.
2025-06-24 22:01:17 - gamma_mcf_pt - INFO - load coordinates
2025-06-24 22:01:17 - gamma_mcf_pt - INFO - Done
2025-06-24 22:01:17 - zarr_info - INFO - ./pu/ds_ph.zarr/ zarray shape, chunks, dtype: (293814, 17), (200000, 1), complex64
2025-06-24 22:01:17 - gamma_mcf_pt - INFO - starting dask local cluster.
2025-06-24 22:01:19 - gamma_mcf_pt - INFO - dask local cluster started.
2025-06-24 22:01:19 - dask_cluster_info - INFO - dask cluster: LocalCluster(dashboard_link='http://127.0.0.1:8787/status', workers=1, threads=2, memory=1.46 TiB)
2025-06-24 22:01:19 - darr_info - INFO - ph dask array shape, chunksize, dtype: (293814, 17), (293814, 1), complex64
2025-06-24 22:01:19 - gamma_mcf_pt - INFO - phase wrapping with mcf.
2025-06-24 22:01:19 - gamma_mcf_pt - INFO - got unwrapped phase.
2025-06-24 22:01:19 - darr_info - INFO - unw_ph dask array shape, chunksize, dtype: (293814, 16), (293814, 1), float32
2025-06-24 22:01:19 - gamma_mcf_pt - INFO - save unw_ph
2025-06-24 22:01:19 - zarr_info - INFO - ./pu/ds_unw.zarr/ zarray shape, chunks, dtype: (293814, 16), (200000, 1), float32
2025-06-24 22:01:19 - gamma_mcf_pt - INFO - computing graph setted. doing all the computing.
2025-06-24 22:01:28 - gamma_mcf_pt - INFO - computing finished.9.7s
2025-06-24 22:01:29 - gamma_mcf_pt - INFO - dask cluster closed.
# note that the data is already in hilbert order
mc.pc_pyramid('./pu/ds_ph.zarr',
'./pu/ds_ph_geo_pyramid',
= './pu/ds_e.zarr/',
x = './pu/ds_n.zarr/',
y =20,
ras_resolution
)
mc.pc_pyramid('./pu/ds_unw.zarr',
'./pu/ds_unw_geo_pyramid',
= './pu/ds_e.zarr/',
x = './pu/ds_n.zarr/',
y =20,
ras_resolution )
2025-06-24 22:01:29 - log_args - INFO - running function: pc_pyramid
2025-06-24 22:01:29 - log_args - INFO - fetching args:
2025-06-24 22:01:29 - log_args - INFO - pc = './pu/ds_ph.zarr'
2025-06-24 22:01:29 - log_args - INFO - out_dir = './pu/ds_ph_geo_pyramid'
2025-06-24 22:01:29 - log_args - INFO - x = './pu/ds_e.zarr/'
2025-06-24 22:01:29 - log_args - INFO - y = './pu/ds_n.zarr/'
2025-06-24 22:01:29 - log_args - INFO - yx = None
2025-06-24 22:01:29 - log_args - INFO - ras_resolution = 20
2025-06-24 22:01:29 - log_args - INFO - ras_chunks = (256, 256)
2025-06-24 22:01:29 - log_args - INFO - pc_chunks = 65536
2025-06-24 22:01:29 - log_args - INFO - processes = False
2025-06-24 22:01:29 - log_args - INFO - n_workers = 1
2025-06-24 22:01:29 - log_args - INFO - threads_per_worker = 2
2025-06-24 22:01:29 - log_args - INFO - dask_cluster_arg = {}
2025-06-24 22:01:29 - log_args - INFO - fetching args done.
2025-06-24 22:01:29 - pc_pyramid - INFO - clean out dir
2025-06-24 22:01:30 - zarr_info - INFO - ./pu/ds_ph.zarr zarray shape, chunks, dtype: (293814, 17), (200000, 1), complex64
2025-06-24 22:01:30 - pc_pyramid - INFO - rendering point cloud data coordinates:
2025-06-24 22:01:30 - pc_pyramid - INFO - rasterizing point cloud data to grid with bounds: [-16498471.798140068, 8649651.33657227, -16470131.798140068, 8674811.33657227].
2025-06-24 22:01:30 - zarr_info - INFO - pu/ds_ph_geo_pyramid/x.zarr zarray shape, chunks, dtype: (293814,), (65536,), float64
2025-06-24 22:01:30 - zarr_info - INFO - pu/ds_ph_geo_pyramid/y.zarr zarray shape, chunks, dtype: (293814,), (65536,), float64
2025-06-24 22:01:30 - pc_pyramid - INFO - pc data coordinates rendering ends.
2025-06-24 22:01:30 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_0.zarr zarray shape, chunks, dtype: (1259, 1418), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_1.zarr zarray shape, chunks, dtype: (630, 709), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_2.zarr zarray shape, chunks, dtype: (315, 355), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_3.zarr zarray shape, chunks, dtype: (158, 178), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_4.zarr zarray shape, chunks, dtype: (79, 89), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_5.zarr zarray shape, chunks, dtype: (40, 45), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_6.zarr zarray shape, chunks, dtype: (20, 23), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_7.zarr zarray shape, chunks, dtype: (10, 12), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_8.zarr zarray shape, chunks, dtype: (5, 6), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_9.zarr zarray shape, chunks, dtype: (3, 3), (256, 256), int64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/idx_10.zarr zarray shape, chunks, dtype: (2, 2), (256, 256), int64
2025-06-24 22:01:32 - pc_pyramid - INFO - rasterized idx rendering ends
2025-06-24 22:01:32 - pc_pyramid - INFO - dask local cluster started to render pc data.
2025-06-24 22:01:32 - dask_cluster_info - INFO - dask cluster: LocalCluster(dashboard_link='http://10.211.48.18:8787/status', workers=1, threads=2, memory=1.46 TiB)
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/pc.zarr zarray shape, chunks, dtype: (293814, 17), (65536, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/0.zarr zarray shape, chunks, dtype: (1259, 1418, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/1.zarr zarray shape, chunks, dtype: (630, 709, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/2.zarr zarray shape, chunks, dtype: (315, 355, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/3.zarr zarray shape, chunks, dtype: (158, 178, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/4.zarr zarray shape, chunks, dtype: (79, 89, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/5.zarr zarray shape, chunks, dtype: (40, 45, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/6.zarr zarray shape, chunks, dtype: (20, 23, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/7.zarr zarray shape, chunks, dtype: (10, 12, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/8.zarr zarray shape, chunks, dtype: (5, 6, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/9.zarr zarray shape, chunks, dtype: (3, 3, 17), (256, 256, 1), complex64
2025-06-24 22:01:32 - zarr_info - INFO - pu/ds_ph_geo_pyramid/10.zarr zarray shape, chunks, dtype: (2, 2, 17), (256, 256, 1), complex64
2025-06-24 22:01:33 - pc_pyramid - INFO - computing graph setted. doing all the computing.
2025-06-24 22:01:34 - pc_pyramid - INFO - computing finished. 1.7s
2025-06-24 22:01:34 - pc_pyramid - INFO - dask cluster closed.
2025-06-24 22:01:34 - log_args - INFO - running function: pc_pyramid
2025-06-24 22:01:34 - log_args - INFO - fetching args:
2025-06-24 22:01:34 - log_args - INFO - pc = './pu/ds_unw.zarr'
2025-06-24 22:01:34 - log_args - INFO - out_dir = './pu/ds_unw_geo_pyramid'
2025-06-24 22:01:34 - log_args - INFO - x = './pu/ds_e.zarr/'
2025-06-24 22:01:34 - log_args - INFO - y = './pu/ds_n.zarr/'
2025-06-24 22:01:34 - log_args - INFO - yx = None
2025-06-24 22:01:34 - log_args - INFO - ras_resolution = 20
2025-06-24 22:01:34 - log_args - INFO - ras_chunks = (256, 256)
2025-06-24 22:01:34 - log_args - INFO - pc_chunks = 65536
2025-06-24 22:01:34 - log_args - INFO - processes = False
2025-06-24 22:01:34 - log_args - INFO - n_workers = 1
2025-06-24 22:01:34 - log_args - INFO - threads_per_worker = 2
2025-06-24 22:01:34 - log_args - INFO - dask_cluster_arg = {}
2025-06-24 22:01:34 - log_args - INFO - fetching args done.
2025-06-24 22:01:34 - pc_pyramid - INFO - clean out dir
2025-06-24 22:01:35 - zarr_info - INFO - ./pu/ds_unw.zarr zarray shape, chunks, dtype: (293814, 16), (200000, 1), float32
2025-06-24 22:01:35 - pc_pyramid - INFO - rendering point cloud data coordinates:
2025-06-24 22:01:35 - pc_pyramid - INFO - rasterizing point cloud data to grid with bounds: [-16498471.798140068, 8649651.33657227, -16470131.798140068, 8674811.33657227].
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/x.zarr zarray shape, chunks, dtype: (293814,), (65536,), float64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/y.zarr zarray shape, chunks, dtype: (293814,), (65536,), float64
2025-06-24 22:01:35 - pc_pyramid - INFO - pc data coordinates rendering ends.
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_0.zarr zarray shape, chunks, dtype: (1259, 1418), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_1.zarr zarray shape, chunks, dtype: (630, 709), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_2.zarr zarray shape, chunks, dtype: (315, 355), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_3.zarr zarray shape, chunks, dtype: (158, 178), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_4.zarr zarray shape, chunks, dtype: (79, 89), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_5.zarr zarray shape, chunks, dtype: (40, 45), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_6.zarr zarray shape, chunks, dtype: (20, 23), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_7.zarr zarray shape, chunks, dtype: (10, 12), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_8.zarr zarray shape, chunks, dtype: (5, 6), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_9.zarr zarray shape, chunks, dtype: (3, 3), (256, 256), int64
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/idx_10.zarr zarray shape, chunks, dtype: (2, 2), (256, 256), int64
2025-06-24 22:01:35 - pc_pyramid - INFO - rasterized idx rendering ends
2025-06-24 22:01:35 - pc_pyramid - INFO - dask local cluster started to render pc data.
2025-06-24 22:01:35 - dask_cluster_info - INFO - dask cluster: LocalCluster(dashboard_link='http://10.211.48.18:8787/status', workers=1, threads=2, memory=1.46 TiB)
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/pc.zarr zarray shape, chunks, dtype: (293814, 16), (65536, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/0.zarr zarray shape, chunks, dtype: (1259, 1418, 16), (256, 256, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/1.zarr zarray shape, chunks, dtype: (630, 709, 16), (256, 256, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/2.zarr zarray shape, chunks, dtype: (315, 355, 16), (256, 256, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/3.zarr zarray shape, chunks, dtype: (158, 178, 16), (256, 256, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/4.zarr zarray shape, chunks, dtype: (79, 89, 16), (256, 256, 1), float32
2025-06-24 22:01:35 - zarr_info - INFO - pu/ds_unw_geo_pyramid/5.zarr zarray shape, chunks, dtype: (40, 45, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - zarr_info - INFO - pu/ds_unw_geo_pyramid/6.zarr zarray shape, chunks, dtype: (20, 23, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - zarr_info - INFO - pu/ds_unw_geo_pyramid/7.zarr zarray shape, chunks, dtype: (10, 12, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - zarr_info - INFO - pu/ds_unw_geo_pyramid/8.zarr zarray shape, chunks, dtype: (5, 6, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - zarr_info - INFO - pu/ds_unw_geo_pyramid/9.zarr zarray shape, chunks, dtype: (3, 3, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - zarr_info - INFO - pu/ds_unw_geo_pyramid/10.zarr zarray shape, chunks, dtype: (2, 2, 16), (256, 256, 1), float32
2025-06-24 22:01:36 - pc_pyramid - INFO - computing graph setted. doing all the computing.
2025-06-24 22:01:37 - pc_pyramid - INFO - computing finished. 1.5s
2025-06-24 22:01:37 - pc_pyramid - INFO - dask cluster closed.
with open('./raw/meta.toml','r') as f:
= toml.load(f)['dates']
dates = mc.pc_plot('./pu/ds_ph_geo_pyramid',post_proc_ras='intf_seq', post_proc_pc='intf_seq',level_increase=0)
ds_geo_intf_plot = ds_geo_intf_plot.redim(
ds_geo_intf_plot =hv.Dimension('i', label='Intf index', range=(0,len(dates)-2), value_format=(lambda i: dates[i]+'_'+dates[i+1])),
i=hv.Dimension('lon', label='Longitude'),
x=hv.Dimension('lat',label='Latitude'),
y=hv.Dimension('Wrapped Phase',range=(-np.pi,np.pi))
z
)= ds_geo_intf_plot.opts(
ds_geo_intf_plot
hv.opts.Image(='colorwheel',frame_width=500, frame_height=400, colorbar=True,
cmap=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
default_tools=['wheel_zoom'],
active_tools="Wrapped Phase",
title
),
hv.opts.Points(='Wrapped Phase', cmap='colorwheel',frame_width=500, frame_height=400, colorbar=True,
color=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
default_tools=['wheel_zoom'],
active_tools="Wrapped Phase",
title
),
)
= mc.pc_plot('./pu/ds_unw_geo_pyramid',level_increase=0)
ds_geo_unw_plot = ds_geo_unw_plot.redim(
ds_geo_unw_plot =hv.Dimension('i', label='Intf index', range=(0,len(dates)-2), value_format=(lambda i: dates[i]+'_'+dates[i+1])),
i=hv.Dimension('lon', label='Longitude'),
x=hv.Dimension('lat',label='Latitude'),
y=hv.Dimension('Unwrapped Phase',range=(-10,10))
z
)= ds_geo_unw_plot.opts(
ds_geo_unw_plot
hv.opts.Image(='colorwheel',frame_width=500, frame_height=400, colorbar=True,
cmap=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
default_tools=['wheel_zoom'],
active_tools="Unwrapped Phase",
title
),
hv.opts.Points(='Unwrapped Phase', cmap='colorwheel',frame_width=500, frame_height=400, colorbar=True,
color=['pan',WheelZoomTool(zoom_on_axis=False),'save','reset','hover'],
default_tools=['wheel_zoom'],
active_tools="Unwrapped Phase",
title
), )
*(ds_geo_intf_plot+ds_geo_unw_plot) hv.element.tiles.EsriImagery()