Skip to content

Commit ea52ae0

Browse files
authored
Merge pull request #47 from mgovorcin/ionosphere
Add ionosphere module and CLI support
2 parents 4c4be79 + 7a3b12f commit ea52ae0

22 files changed

Lines changed: 4037 additions & 552 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ docs/reference
77

88
# Testing data dir
99
# data/
10+
notebooks/
1011

1112
# Byte-compiled / optimized / DLL files
1213
__pycache__/

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ci:
2-
autofix_prs: false
2+
autofix_prs: true
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -34,6 +34,7 @@ repos:
3434
- types-setuptools
3535
- types-requests
3636
- "pydantic>=2.4"
37+
- types-markdown
3738

3839
- repo: https://github.com/psf/black-pre-commit-mirror
3940
rev: "26.5.1"
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
ps_options:
2+
# Amplitude dispersion threshold to consider a pixel a PS.
3+
# Type: number.
4+
amp_dispersion_threshold: 0.2
5+
phase_linking:
6+
# Size of the ministack for sequential estimator.
7+
# Type: integer.
8+
ministack_size: 100
9+
# Maximum number of compressed images to use in sequential estimator. If there are more
10+
# ministacks than this, the earliest CGSLCs will be left out of the later stacks. .
11+
# Type: integer.
12+
max_num_compressed: 100
13+
# Index of input SLC to use for making phase linked interferograms after EVD/EMI.
14+
# Type: integer.
15+
output_reference_idx: 0
16+
half_window:
17+
# Half window size (in pixels) for x direction.
18+
# Type: integer.
19+
x: 15
20+
# Half window size (in pixels) for y direction.
21+
# Type: integer.
22+
y: 15
23+
# Use EVD on the coherence instead of using the EMI algorithm.
24+
# Type: boolean.
25+
use_evd: false
26+
# Beta regularization parameter for correlation matrix inversion. 0 is no regularization.
27+
# Type: number.
28+
beta: 0.0
29+
# Snap correlation values in the coherence matrix below this value to 0.
30+
# Type: number.
31+
zero_correlation_threshold: 0.0
32+
# Method for finding SHPs during phase linking.
33+
# Type: string.
34+
# Options: ['glrt', 'ks', 'rect', 'rect'].
35+
shp_method: glrt
36+
# Significance level (probability of false alarm) for SHP tests. Lower numbers include more
37+
# pixels within the multilook window during covariance estimation.
38+
# Type: number.
39+
shp_alpha: 0.001
40+
# If True, pixels labeled as PS will get set to NaN during phase linking to avoid summing
41+
# their phase. Default of False means that the SHP algorithm will decide if a pixel should
42+
# be included, regardless of its PS label.
43+
# Type: boolean.
44+
mask_input_ps: false
45+
# StBAS parameter to include only nearest-N interferograms forphase linking. A
46+
# `baseline_lag` of `n` will only include the closest`n` interferograms. `baseline_line`
47+
# must be positive.
48+
# Type: integer | null.
49+
baseline_lag:
50+
# Plan for creating Compressed SLCs during phase linking.
51+
# Type: string.
52+
# Options: ['always_first', 'first_per_ministack', 'last_per_ministack'].
53+
compressed_slc_plan: last_per_ministack
54+
interferogram_network:
55+
# For single-reference network: Index of the reference image in the network.
56+
# Type: integer | null.
57+
reference_idx:
58+
# Max `n` to form the nearest-`n` interferograms by index.
59+
# Type: integer | null.
60+
max_bandwidth: 3
61+
# Maximum temporal baseline of interferograms.
62+
# Type: integer | null.
63+
max_temporal_baseline:
64+
# For manual-index network: list of (ref_idx, sec_idx) defining the interferograms to form.
65+
# Type: array | null.
66+
indexes:
67+
unwrap_options:
68+
# Whether to run the unwrapping step after wrapped phase estimation.
69+
# Type: boolean.
70+
run_unwrap: true
71+
# Whether to run Goldstein filtering step on wrapped interferogram.
72+
# Type: boolean.
73+
run_goldstein: false
74+
# Whether to run interpolation step on wrapped interferogram.
75+
# Type: boolean.
76+
run_interpolation: true
77+
# Phase unwrapping method.
78+
# Type: string.
79+
# Options: ['snaphu', 'icu', 'phass', 'spurt', 'whirlwind'].
80+
unwrap_method: snaphu
81+
# Number of interferograms to unwrap in parallel.
82+
# Type: integer.
83+
n_parallel_jobs: 4
84+
# Set wrapped phase/correlation to 0 where mask is 0 before unwrapping. .
85+
# Type: boolean.
86+
zero_where_masked: false
87+
preprocess_options:
88+
# Adaptive phase (Goldstein) filter exponent parameter.
89+
# Type: number.
90+
alpha: 0.5
91+
# (for interpolation) Maximum radius to find scatterers.
92+
# Type: integer.
93+
max_radius: 150
94+
# Threshold on the correlation raster to use for interpolation. Pixels with less than this
95+
# value are replaced by a weighted combination of neighboring pixels.
96+
# Type: number.
97+
interpolation_cor_threshold: 0.001
98+
# Threshold on the correlation raster to use for interpolation. Pixels with less than this
99+
# value are replaced by a weighted combination of neighboring pixels.
100+
# Type: number.
101+
interpolation_similarity_threshold: 0.4
102+
snaphu_options:
103+
# Number of tiles to split the inputs into using SNAPHU's internal tiling.
104+
# Type: array.
105+
ntiles:
106+
- 5
107+
- 5
108+
# Amount of tile overlap (in pixels) along the (row, col) directions.
109+
# Type: array.
110+
tile_overlap:
111+
- 400
112+
- 400
113+
# Number of tiles to unwrap in parallel for each interferogram.
114+
# Type: integer.
115+
n_parallel_tiles: 7
116+
# Initialization method for SNAPHU.
117+
# Type: string.
118+
# Options: ['mcf', 'mst'].
119+
init_method: mcf
120+
# Statistical cost mode method for SNAPHU.
121+
# Type: string.
122+
# Options: ['defo', 'smooth'].
123+
cost: smooth
124+
# If True, after unwrapping with multiple tiles, an additional post-processing unwrapping
125+
# step is performed to re-optimize the unwrapped phase using a single tile.
126+
# Type: boolean.
127+
single_tile_reoptimize: true
128+
tophu_options:
129+
# Number of tiles to split the inputs into.
130+
# Type: array.
131+
ntiles:
132+
- 1
133+
- 1
134+
# Extra multilook factor to use for the coarse unwrap.
135+
# Type: array.
136+
downsample_factor:
137+
- 1
138+
- 1
139+
# Initialization method for SNAPHU.
140+
# Type: string.
141+
# Options: ['mcf', 'mst'].
142+
init_method: mcf
143+
# Statistical cost mode method for SNAPHU.
144+
# Type: string.
145+
# Options: ['defo', 'smooth'].
146+
cost: smooth
147+
spurt_options:
148+
# Temporal coherence to pick pixels used on an irregular grid.
149+
# Type: number.
150+
temporal_coherence_threshold: 0.7
151+
# Similarity to pick pixels used on an irregular grid. Any pixel with similarity above
152+
# `similarity_threshold` *or* above the temporal coherence threshold is chosen.
153+
# Type: number.
154+
similarity_threshold: 0.5
155+
# After running spurt, interpolate the values that were masked during unwrapping (which are
156+
# otherwise left as nan).
157+
# Type: boolean.
158+
run_ambiguity_interpolation: true
159+
general_settings:
160+
# Tile up data spatially.
161+
# Type: boolean.
162+
use_tiles: true
163+
tiler_settings:
164+
# Maximum number of tiles allowed.
165+
# Type: integer.
166+
max_tiles: 25
167+
# Number of points used for determining tiles based on density.
168+
# Type: integer.
169+
target_points_for_generation: 120000
170+
# Target points per tile when generating tiles.
171+
# Type: integer.
172+
target_points_per_tile: 1400000
173+
# Dilation factor of non-overlapping tiles. 0.05 would lead to 5 percent dilation of the
174+
# tile.
175+
# Type: number.
176+
dilation_factor: 0.04
177+
solver_settings:
178+
# Number of workers for temporal unwrapping in parallel. Set value to <=0 to let workflow
179+
# use default workers (ncpus - 1).
180+
# Type: integer.
181+
t_worker_count: 16
182+
# Number of workers for spatial unwrapping in parallel. Set value to <=0 to let workflow use
183+
# (ncpus - 1).
184+
# Type: integer.
185+
s_worker_count: 3
186+
# Temporal unwrapping operations over spatial links are performed in batches and each batch
187+
# is solved in parallel.
188+
# Type: integer.
189+
links_per_batch: 150000
190+
# Temporal unwrapping costs.
191+
# Type: string.
192+
# Options: ['constant', 'distance', 'centroid'].
193+
t_cost_type: distance
194+
# Scale factor used to compute edge costs for temporal unwrapping.
195+
# Type: number.
196+
t_cost_scale: 100.0
197+
# Spatial unwrapping costs.
198+
# Type: string.
199+
# Options: ['constant', 'distance', 'centroid'].
200+
s_cost_type: constant
201+
# Scale factor used to compute edge costs for spatial unwrapping.
202+
# Type: number.
203+
s_cost_scale: 100.0
204+
# Number of tiles to process in parallel. Set to 0 for all tiles.
205+
# Type: integer.
206+
num_parallel_tiles: 1
207+
merger_settings:
208+
# Minimum number of overlap pixels to be considered valid.
209+
# Type: integer.
210+
min_overlap_points: 25
211+
# Currently, only 'dirichlet' is supported.
212+
# Type: dirichlet.
213+
method: dirichlet
214+
# Method used to estimate bulk offset between tiles.
215+
# Type: string.
216+
# Options: ['integer', 'L2'].
217+
bulk_method: L2
218+
# Number of interferograms to merge in one batch. Use zero to merge all interferograms in a
219+
# single batch.
220+
# Type: integer.
221+
num_parallel_ifgs: 21
222+
timeseries_options:
223+
# Whether to run the inversion step after unwrapping, if more than a single-reference
224+
# network is used.
225+
# Type: boolean.
226+
run_inversion: true
227+
# Norm to use during timeseries inversion.
228+
# Type: string.
229+
# Options: ['L1', 'L2'].
230+
method: L1
231+
# Reference point (row, col) used if performing a time series inversion. If not provided, a
232+
# point will be selected from a consistent connected component with low amplitude
233+
# dispersion.
234+
# Type: array | null.
235+
reference_point:
236+
# Run the velocity estimation from the phase time series.
237+
# Type: boolean.
238+
run_velocity: false
239+
# Pixels with correlation below this value will be masked out.
240+
# Type: number.
241+
correlation_threshold: 0.0
242+
# Size (rows, columns) of blocks of data to load at a time. 3D dimsion is number of
243+
# interferograms (during inversion) and number of SLC dates (during velocity fitting).
244+
# Type: array.
245+
block_shape:
246+
- 256
247+
- 256
248+
# Number of parallel blocks to process at once.
249+
# Type: integer.
250+
num_parallel_blocks: 4
251+
output_options:
252+
# Alternative to specifying output resolution: Specify the (x, y) strides (decimation
253+
# factor) to perform while processing input. For example, strides of [4, 2] would turn an
254+
# input resolution of [5, 10] into an output resolution of [20, 20].
255+
# Type: object.
256+
strides:
257+
x: 6
258+
y: 6
259+
# Area of interest: [left, bottom, right, top] coordinates. e.g.
260+
# `bbox=[-150.2,65.0,-150.1,65.5]`.
261+
# Type: array | null.
262+
bounds:
263+
# Area of interest as a simple Polygon in well-known-text (WKT) format. Can pass a string,
264+
# or a `.wkt` filename containing the Polygon text.
265+
# Type: string | null.
266+
bounds_wkt:
267+
# EPSG code for the `bounds` or `bounds_wkt` coordinates, if specified.
268+
# Type: integer.
269+
bounds_epsg: 4326
270+
# Options for `create_dataset` with h5py.
271+
# Type: object.
272+
hdf5_creation_options:
273+
chunks:
274+
- 128
275+
- 128
276+
compression: gzip
277+
compression_opts: 4
278+
shuffle: true
279+
# GDAL creation options for GeoTIFF files.
280+
# Type: array.
281+
gtiff_creation_options:
282+
- COMPRESS=lzw
283+
- ZLEVEL=4
284+
- BIGTIFF=yes
285+
- TILED=yes
286+
- INTERLEAVE=band
287+
- BLOCKXSIZE=128
288+
- BLOCKYSIZE=128
289+
# Whether to add overviews to the output GeoTIFF files. This will increase file size, but
290+
# can be useful for visualizing the data with web mapping tools. See
291+
# https://gdal.org/programs/gdaladdo.html for more.
292+
# Type: boolean.
293+
add_overviews: false
294+
# Specify an extra reference datetime in UTC. Adding this lets you to create and unwrap two
295+
# single reference networks; the later resets at the given date (e.g. for a large
296+
# earthquake event). If passing strings, formats accepted are YYYY-MM-
297+
# DD[T]HH:MM[:SS[.ffffff]][Z or [±]HH[:]MM], or YYYY-MM-DD.
298+
# Type: string | null.
299+
extra_reference_date:
300+
# When creating `recommended_mask`, pixels with temporal coherence below this threshold and
301+
# with similarity below `recommended_similarity_threshold` are masked.
302+
# Type: number.
303+
recommended_temporal_coherence_threshold: 0.7
304+
# When creating `recommended_mask`, pixels with similarity below this threshold and with
305+
# temporal coherence below `recommended_temporal_coherence_threshold` are masked.
306+
# Type: number.
307+
recommended_similarity_threshold: 0.6
308+
# When creating `recommended_mask`, use the `connected_component_label`
309+
# layer to hide pixels whose label == 0.
310+
# Type: boolean.
311+
recommended_use_conncomp: false
312+
# Spatial wavelength cutoff (in meters) for the spatial filter. Used to create the short
313+
# wavelength displacement layer.
314+
# Type: number.
315+
spatial_wavelength_cutoff: 30000.0
316+
# `vmin, vmax` matplotlib arguments (in meters) passed to browse image creator.
317+
# Type: array.
318+
browse_image_vmin_vmax:
319+
- -0.05
320+
- 0.05
321+
# When running forward mode, size of the interferogram network to form with the latest
322+
# date. Valid choices are 3 (default) and 4.
323+
# Type: integer.
324+
forward_mode_network_size: 3
325+
# Number of output products to create in parallel.
326+
# Type: integer.
327+
num_parallel_products: 4

configs/runconfig_historical.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ dynamic_ancillary_file_group:
2828
# REQUIRED: Path to file containing SAS algorithm parameters.
2929
# Type: string.
3030
algorithm_parameters_file: algorithm_parameters_historical.yaml
31+
# REQUIRED: Path to file containing SAS algorithm parameters for ionosphere from FreqA/B.
32+
# Type: string.
33+
ionosphere_algorithm_parameters_file: algorithm_iono_parameters_historical.yaml
3134
# Paths to the GSLC static_layer files (1 per burst) with line-of-sight unit vectors. If
3235
# none provided, corrections using GSLC static_layer are skipped.
3336
# Type: array.

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ RUN echo "numpy<2" > /tmp/constraints.txt && \
7373
PIP_CONSTRAINT=/tmp/constraints.txt pip install git+https://github.com/isce-framework/spurt@v0.1.1 && \
7474
rm /tmp/constraints.txt
7575
# --no-deps because they are installed with conda
76-
RUN pip install rich && pip install --no-deps git+https://github.com/opera-adt/opera-utils@v0.25.5
77-
RUN pip install tyro && pip install --no-deps git+https://github.com/isce-framework/dolphin@v0.42.4
76+
RUN pip install rich && pip install --no-deps git+https://github.com/opera-adt/opera-utils@v0.25.7
77+
RUN pip install tyro && pip install --no-deps git+https://github.com/isce-framework/dolphin@v0.42.6
7878

7979
COPY --chown=$MAMBA_USER:$MAMBA_USER . .
8080
RUN python -m pip install --no-deps .

src/disp_nisar/_geometry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
import multiprocessing as mp
77
from pathlib import Path
88

9-
import h5py
109
import numpy as np
1110
import rioxarray as rxr
1211
from dolphin._types import Filename
1312
from pyproj import Transformer
1413
from scipy.interpolate import RegularGridInterpolator
1514
from tqdm import tqdm
1615

16+
from ._streaming import open_h5_file
17+
1718
logger = logging.getLogger(__name__)
1819

1920

@@ -164,7 +165,7 @@ def prepare_geometry_layers(
164165

165166
logger.info(f"Reading radar grid from {gslc_path}")
166167
# Read radar grid data from GSLC
167-
with h5py.File(gslc_path) as f:
168+
with open_h5_file(gslc_path, "r") as f:
168169
rg = f["science/LSAR/GSLC/metadata/radarGrid"]
169170
heights = rg["heightAboveEllipsoid"][:]
170171
x_rg = rg["xCoordinates"][:]

0 commit comments

Comments
 (0)