pc: Point cloud data utilities (CLI)¶
moraine.cli.pc 的命令(源码);同样的函数在 Python 里以 mc.<name>(...) 调用(import moraine.cli as mc)。下面的帮助由 docstring 生成,与 moraine COMMAND --help 相同(docstring 为英文)。
| 命令 | 摘要 |
|---|---|
gix2bool |
Convert pc grid index to bool 2d array |
bool2gix |
Convert bool 2d array to grid index |
ras2pc |
Convert raster data to point cloud data |
pc-concat |
concatenate (and sort) point cloud dataset. |
ras2pc-ras-chunk |
Convert raster data to point cloud data that sorted by ras chunk |
pc2ras |
Convert point cloud data to raster data, filled with nan |
pc-hix |
Compute the hillbert index from grid index for point cloud data. |
pc-gix |
Compute the grid index from hillbert index for point cloud data. |
pc-sort |
Sort point cloud data according to the indices that sort idx_in. |
pc-union |
Get the union of two point cloud datasets |
pc-intersect |
Get the intersection of two point cloud datasets. |
pc-diff |
Get the points of the first point cloud dataset that are not in the second one. |
pc-logic-ras |
generate point cloud index based on logical operation of one raster image. |
pc-logic-pc |
generate point cloud index and data based on logical operation one point cloud data. |
pc-select-data |
generate point cloud data based on its index and one point cloud data |
gix2bool¶
Convert pc grid index to bool 2d array
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--gix |
str | 必需 | input grid index (azimuth, range) of the point cloud, shape (n_points, 2), int |
--is_pc |
str | 必需 | output bool raster, True at the points, shape (nlines, width) |
--shape |
tuple[int, int] | 必需 | raster shape (nlines, width) |
--chunks |
tuple[int, int], 1000) | (1000, 1000) |
output chunk size |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(示例 pipeline 未使用此命令;只列必需参数):
在 Python 中:
bool2gix¶
Convert bool 2d array to grid index
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--is_pc |
str | 必需 | input bool array |
--gix |
str | 必需 | output, point cloud grid index |
--chunks |
int | 100000 |
output point chunk size |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(示例 pipeline 未使用此命令;只列必需参数):
在 Python 中:
ras2pc¶
Convert raster data to point cloud data
moraine ras2pc --idx STR --ras PATH [PATH ...] --pc PATH [PATH ...] [--chunks VALUE] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx |
str | 必需 | input grid index or hillbert index of the point cloud |
--ras |
str | list | 必需 | input path or list of paths of raster data, shape (nlines, width, ...) |
--pc |
str | list | 必需 | output, path (in string) or list of path for point cloud data |
--chunks |
int | None |
point chunk size of the output data, same as idx by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/02_ps.toml,步骤 ps_can_data):
[[step]]
name = "ps_can_data"
run = "ras2pc"
idx = "ps/ps_can_hix.zarr"
ras = ["raw/rslc.zarr", "raw/e.zarr", "raw/n.zarr", "raw/lon.zarr", "raw/lat.zarr", "ps/ras_adi.zarr"]
pc = ["ps/ps_can_rslc.zarr", "ps/ps_can_e.zarr", "ps/ps_can_n.zarr", "ps/ps_can_lon.zarr", "ps/ps_can_lat.zarr", "ps/ps_can_adi.zarr"]
也用于 examples/03_ds.toml(步骤 ds_en), examples/04_refine.toml(步骤 lon_lat), examples/04_refine.toml(步骤 geometry)。
在 Python 中:
import moraine.cli as mc
mc.ras2pc(idx, ras, pc, chunks=None, processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.ras2pc 对内存中的 numpy / cupy 数组做同样的事。
pc-concat¶
concatenate (and sort) point cloud dataset.
moraine pc-concat --pcs PATH [PATH ...] --pc PATH [PATH ...] [--key PATH [PATH ...]] [--chunks VALUE] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--pcs |
list | str | 必需 | list of path to pc or directory that hold one pc, or a list of that |
--pc |
list | str | 必需 | output, path of output or a list of that |
--key |
list | str | None |
input key(s) that sort the concatenated data (e.g. from ras2pc_ras_chunk); no sorting by default |
--chunks |
int | None |
pc chunk size in output data, optional, same as first pc in pcs by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/03_ds.toml,步骤 ds_can_concat):
[[step]]
name = "ds_can_concat" # chunks -> one array each, in hilbert order
run = "pc-concat"
pcs = ["ds/chunks/ds_can_ph", "ds/chunks/ds_can_t_coh", "ds/chunks/ds_can_t_coh_w", "ds/chunks/ds_can_n_components"]
pc = ["ds/ds_can_ph.zarr", "ds/ds_can_t_coh.zarr", "ds/ds_can_t_coh_w.zarr", "ds/ds_can_n_components.zarr"]
key = ["ds/chunks/ds_can_key.zarr", "ds/chunks/gix2hix_key.zarr"]
chunks = 200000
在 Python 中:
import moraine.cli as mc
mc.pc_concat(pcs, pc, key=None, chunks=None, processes=False, n_workers=1, threads_per_worker=4)
ras2pc-ras-chunk¶
Convert raster data to point cloud data that sorted by ras chunk
moraine ras2pc-ras-chunk --gix STR --ras PATH [PATH ...] --pc PATH [PATH ...] --key STR [--chunks INT INT] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--gix |
str | 必需 | input grid index (azimuth, range) of the point cloud, shape (n_points, 2), int |
--ras |
str | list | 必需 | input path or list of paths of raster data, shape (nlines, width, ...) |
--pc |
str | list | 必需 | output, path (directory) or list of path for point cloud data |
--key |
str | 必需 | output, path for the key to sort generated pc in the directory back to gix order |
--chunks |
tuple[int, int] | None |
(azimuth, range) raster chunk size used to split the points, same as the first ras by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/03_ds.toml,步骤 ds_can_is_shp):
[[step]]
name = "ds_can_is_shp" # SHPs of the candidates, one zarr per raster chunk
run = "ras2pc-ras-chunk"
gix = "ds/ds_can_gix_ras_order.zarr"
ras = "ds/ras_is_shp.zarr"
pc = "ds/chunks/ds_can_is_shp"
key = "ds/chunks/ds_can_key.zarr"
chunks = [1000, 1000]
在 Python 中:
import moraine.cli as mc
mc.ras2pc_ras_chunk(gix, ras, pc, key, chunks=None, processes=False, n_workers=1, threads_per_worker=4)
pc2ras¶
Convert point cloud data to raster data, filled with nan
moraine pc2ras --idx STR --pc PATH [PATH ...] --ras PATH [PATH ...] --shape INT INT [--chunks INT INT] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx |
str | 必需 | input grid index or hillbert index of the point cloud |
--pc |
str | list | 必需 | input path or list of paths of point cloud data, shape (n_points, ...) |
--ras |
str | list | 必需 | output, path (in string) or list of path for raster data |
--shape |
tuple[int, int] | 必需 | shape of one image (nlines,width) |
--chunks |
tuple[int, int], 1000) | (1000, 1000) |
output chunk size |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(示例 pipeline 未使用此命令;只列必需参数):
在 Python 中:
import moraine.cli as mc
mc.pc2ras(idx, pc, ras, shape, chunks=(1000, 1000), processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.pc2ras 对内存中的 numpy / cupy 数组做同样的事。
pc-hix¶
Compute the hillbert index from grid index for point cloud data.
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--gix |
str | 必需 | input grid index (azimuth, range) of the point cloud, shape (n_points, 2), int |
--hix |
str | 必需 | output hillbert index of the point cloud, shape (n_points,), int64 |
--shape |
tuple[int, int] | 必需 | raster shape (nlines, width) |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/02_ps.toml,步骤 ps_can_hix):
[[step]]
name = "ps_can_hix"
run = "pc-hix"
gix = "ps/ps_can_gix.zarr"
hix = "ps/ps_can_hix_unsorted.zarr"
shape = "${shape}"
也用于 examples/03_ds.toml(步骤 ds_can_hix)。
在 Python 中:
数组函数 mr.pc_hix 对内存中的 numpy / cupy 数组做同样的事。
pc-gix¶
Compute the grid index from hillbert index for point cloud data.
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--hix |
str | 必需 | input hillbert index of the point cloud, shape (n_points,), int64 |
--gix |
str | 必需 | output grid index (azimuth, range) of the point cloud, shape (n_points, 2), int |
--shape |
tuple[int, int] | 必需 | raster shape (nlines, width) |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/05_unwrap.toml,步骤 gix):
[[step]]
name = "gix" # mcf-pc needs the grid index of the points
run = "pc-gix"
hix = "pc/pc_hix.zarr"
gix = "unw/pc_gix.zarr"
shape = "${shape}"
在 Python 中:
数组函数 mr.pc_gix 对内存中的 numpy / cupy 数组做同样的事。
pc-sort¶
Sort point cloud data according to the indices that sort idx_in.
moraine pc-sort --idx_in STR --idx STR [--pc_in PATH [PATH ...]] [--pc PATH [PATH ...]] [--shape INT INT] [--chunks VALUE] [--key STR] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx_in |
str | 必需 | input unsorted grid index or hillbert index of the input data |
--idx |
str | 必需 | output, the sorted grid index or hillbert index |
--pc_in |
str | list | None |
input path or list of paths of the input point cloud data |
--pc |
str | list | None |
output, path (in string) or list of path for the output point cloud data |
--shape |
tuple[int, int] | None |
(nline, width), faster if provided for grid index input |
--chunks |
int | None |
chunk size in output data, same as idx_in by default |
--key |
str | None |
output, path (in string) for the key of sorting |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/02_ps.toml,步骤 ps_can_sort):
[[step]]
name = "ps_can_sort" # hilbert order
run = "pc-sort"
idx_in = "ps/ps_can_hix_unsorted.zarr"
idx = "ps/ps_can_hix.zarr"
也用于 examples/03_ds.toml(步骤 ds_can_sort)。
在 Python 中:
import moraine.cli as mc
mc.pc_sort(idx_in, idx, pc_in=None, pc=None, shape=None, chunks=None, key=None, processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.pc_sort 对内存中的 numpy / cupy 数组做同样的事。
pc-union¶
Get the union of two point cloud datasets. Points in both keep the data of the first point cloud.
moraine pc-union --idx1 STR --idx2 STR --idx STR [--pc1 PATH [PATH ...]] [--pc2 PATH [PATH ...]] [--pc PATH [PATH ...]] [--shape INT INT] [--chunks VALUE] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx1 |
str | 必需 | input grid index or hillbert index of the first point cloud, sorted |
--idx2 |
str | 必需 | input grid index or hillbert index of the second point cloud, sorted |
--idx |
str | 必需 | output grid index or hillbert index of the union |
--pc1 |
str | list | None |
input path or list of paths of the first point cloud data |
--pc2 |
str | list | None |
input path or list of paths of the second point cloud data |
--pc |
str | list | None |
output path or list of paths of the point cloud data of the union |
--shape |
tuple[int, int] | None |
image shape, faster if provided for grid index input |
--chunks |
int | None |
point chunk size of the output data, same as idx1 by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/02_ps.toml,步骤 ps_can):
[[step]]
name = "ps_can" # union of both candidate sets
run = "pc-union"
idx1 = "ps/ps_can_1_gix.zarr"
idx2 = "ps/ps_can_2_gix.zarr"
idx = "ps/ps_can_gix.zarr"
shape = "${shape}"
也用于 examples/04_refine.toml(步骤 merge)。
在 Python 中:
import moraine.cli as mc
mc.pc_union(idx1, idx2, idx, pc1=None, pc2=None, pc=None, shape=None, chunks=None, processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.pc_union 对内存中的 numpy / cupy 数组做同样的事。
pc-intersect¶
Get the intersection of two point cloud datasets.
moraine pc-intersect --idx1 STR --idx2 STR --idx STR [--pc1 PATH [PATH ...]] [--pc2 PATH [PATH ...]] [--pc PATH [PATH ...]] [--shape INT INT] [--chunks VALUE] [--prefer_1 | --no-prefer_1] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx1 |
str | 必需 | input grid index or hillbert index of the first point cloud, sorted |
--idx2 |
str | 必需 | input grid index or hillbert index of the second point cloud, sorted |
--idx |
str | 必需 | output grid index or hillbert index of the intersection |
--pc1 |
str | list | None |
input path or list of paths of the first point cloud data |
--pc2 |
str | list | None |
input path or list of paths of the second point cloud data |
--pc |
str | list | None |
output path or list of paths of the point cloud data of the intersection, taken from pc1 or pc2 (see prefer_1) |
--shape |
tuple[int, int] | None |
image shape, faster if provided for grid index input |
--chunks |
int | None |
point chunk size of the output data, same as idx1 by default |
--prefer_1 |
bool | True |
take the output data from pc1 (True) or from pc2 (False) |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(示例 pipeline 未使用此命令;只列必需参数):
在 Python 中:
import moraine.cli as mc
mc.pc_intersect(idx1, idx2, idx, pc1=None, pc2=None, pc=None, shape=None, chunks=None, prefer_1=True, processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.pc_intersect 对内存中的 numpy / cupy 数组做同样的事。
pc-diff¶
Get the points of the first point cloud dataset that are not in the second one.
moraine pc-diff --idx1 STR --idx2 STR --idx STR [--pc1 PATH [PATH ...]] [--pc PATH [PATH ...]] [--shape INT INT] [--chunks VALUE] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx1 |
str | 必需 | input grid index or hillbert index of the first point cloud, sorted |
--idx2 |
str | 必需 | input grid index or hillbert index of the second point cloud, sorted |
--idx |
str | 必需 | output grid index or hillbert index of the points in idx1 but not in idx2 |
--pc1 |
str | list | None |
input path or list of paths of the first point cloud data |
--pc |
str | list | None |
output path or list of paths of the point cloud data of these points, taken from pc1 |
--shape |
tuple[int, int] | None |
image shape, faster if provided for grid index input |
--chunks |
int | None |
point chunk size of the output data, same as idx1 by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(示例 pipeline 未使用此命令;只列必需参数):
在 Python 中:
import moraine.cli as mc
mc.pc_diff(idx1, idx2, idx, pc1=None, pc=None, shape=None, chunks=None, processes=False, n_workers=1, threads_per_worker=4)
数组函数 mr.pc_diff 对内存中的 numpy / cupy 数组做同样的事。
pc-logic-ras¶
generate point cloud index based on logical operation of one raster image.
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--ras |
必需 | input raster used in operation, shape (nlines, width) |
|
--gix |
必需 | output grid index (azimuth, range) of the point cloud, shape (n_points, 2), int, of the pixels where operation is True |
|
--operation |
str | 必需 | numexpr expression on the raster, which is named ras, e.g. '(ras>=0)&(ras<=0.3)' |
--chunks |
int | 100000 |
chunk size in output data, optional |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/02_ps.toml,步骤 ps_can_adi):
[[step]]
name = "ps_can_adi" # candidates 1: ADI below 0.4
run = "pc-logic-ras"
ras = "ps/ras_adi.zarr"
gix = "ps/ps_can_1_gix.zarr"
operation = "ras<0.4"
chunks = 200000
也用于 examples/02_ps.toml(步骤 ps_can_n2f), examples/03_ds.toml(步骤 ds_can)。
在 Python 中:
pc-logic-pc¶
generate point cloud index and data based on logical operation one point cloud data.
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx_in |
str | 必需 | input grid index or hillbert index of the input point cloud |
--pc_in |
str | 必需 | input point cloud data used in operation, shape (n_points,) |
--idx |
str | 必需 | output grid index or hillbert index of the points where operation is True |
--operation |
str | 必需 | numexpr expression on the point cloud data, which is named pc_in, e.g. '(pc_in>=0.1)&(pc_in<=0.5)' |
--chunks |
int | None |
point chunk size of the output data, same as idx_in by default |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/03_ds.toml,步骤 ds_connected):
[[step]]
name = "ds_connected" # one connected component
run = "pc-logic-pc"
idx_in = "ds/ds_can_hix.zarr"
pc_in = "ds/ds_can_n_components.zarr"
idx = "ds/ds_connected_hix.zarr"
operation = "pc_in==1"
也用于 examples/03_ds.toml(步骤 ds), examples/04_refine.toml(步骤 select)。
在 Python 中:
pc-select-data¶
generate point cloud data based on its index and one point cloud data. The index of generated point cloud data must in the index of the old one.
moraine pc-select-data --idx_in STR --idx STR --pc_in PATH [PATH ...] --pc PATH [PATH ...] [--shape INT INT] [--chunks VALUE] [--processes | --no-processes] [--n_workers VALUE] [--threads_per_worker VALUE]
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--idx_in |
str | 必需 | input grid index or hillbert index of the input point cloud, sorted |
--idx |
str | 必需 | input grid index or hillbert index of the points to select, a subset of idx_in, sorted |
--pc_in |
str | list | 必需 | input path or list of paths of the input point cloud data |
--pc |
str | list | 必需 | output, path (in string) or list of path for the output point cloud data |
--shape |
tuple[int, int] | None |
shape of the raster data the point cloud from, must be provided if idx is hix |
--chunks |
int | None |
point chunk size of the output data, same as idx by default |
--processes |
False |
use processes for the workers instead of threads | |
--n_workers |
1 |
number of workers | |
--threads_per_worker |
4 |
tasks a worker runs at the same time |
全局选项:--json、--traceback、--log FILE、-q / --quiet(约定)。
在 pipeline 文件中(examples/03_ds.toml,步骤 ds_connected_t_coh_w):
[[step]]
name = "ds_connected_t_coh_w" # the weighted temporal coherence of those points
run = "pc-select-data"
idx_in = "ds/ds_can_hix.zarr"
idx = "ds/ds_connected_hix.zarr"
pc_in = ["ds/ds_can_t_coh_w.zarr"]
pc = ["ds/ds_connected_t_coh_w.zarr"]
也用于 examples/03_ds.toml(步骤 ds_data), examples/04_refine.toml(步骤 select_data)。
在 Python 中: