ps
Find the persistent scatterers in a stack of SLCS.
calc_ps_block(stack_mag, amp_dispersion_threshold=0.25, min_count=None)
Calculate the amplitude dispersion for a block of data.
The amplitude dispersion is defined as the standard deviation of a pixel's magnitude divided by the mean of the magnitude:
where \(Z \in \mathbb{R}^{N}\) is one pixel's complex data for \(N\) SLCs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack_mag
|
ArrayLike
|
The magnitude of the stack of SLCs. |
required |
amp_dispersion_threshold
|
float
|
The threshold for the amplitude dispersion to label a pixel as a PS: ps = amp_disp < amp_dispersion_threshold Default is 0.25. |
0.25
|
min_count
|
int
|
The minimum number of valid pixels to calculate the mean and standard
deviation. If the number of valid pixels is less than |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
mean |
ndarray
|
The mean amplitude for the block. dtype: float32 |
amp_disp |
ndarray
|
The amplitude dispersion for the block. dtype: float32 |
ps |
ndarray
|
The persistent scatterers for the block. dtype: bool |
Notes
The min_count is used to prevent the mean and standard deviation from being calculated for pixels that are not valid for most of the SLCs. This happens when the burst footprints shift around and pixels near the edge get only one or two acquisitions. Since fewer samples are used to calculate the mean and standard deviation, there is a higher false positive risk for these edge pixels.
Source code in src/dolphin/ps.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
combine_amplitude_dispersions(dispersions, means, N)
Compute the combined amplitude dispersion from multiple groups.
Given several ADs where difference numbers of images, N, went in, the function computes a weighted mean/variance to calculate the combined AD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dispersions
|
ndarray
|
A 3D array of amplitude dispersion values for each group. Shape: (depth, height, width) |
required |
means
|
ndarray
|
A 3D array of mean values for each group. Shape: (depth, height, width) |
required |
N
|
ndarray
|
An array sample sizes for each group. Shape: (depth, ) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The combined amplitude dispersion. Shape: (height, width) |
ndarray
|
The combined amplitude mean. Shape: (height, width) |
Notes
All input arrays are expected to have the same shape.
The operation is performed along axis=0.
Let \(X_i\) be the random variable for group \(i\), with mean \(\mu_i\) and variance \(\sigma_i^2\), and \(N_i\) be the number of samples in group \(i\).
The combined variance \(\sigma^2\) uses the formula
where \(E[X]\) is the combined mean, and \(E[X^2]\) is the expected value of the squared random variable.
The combined mean is calculated as:
For \(E[X^2]\), we use the property \(E[X^2] = \sigma^2 + \mu^2\):
Substituting these into the variance formula gives:
Source code in src/dolphin/ps.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
combine_means(means, N)
Compute the combined mean from multiple mu_i values.
This function calculates the weighted average of amplitudes based on the number of original data points (N) that went into each mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
means
|
ArrayLike
|
A 3D array of mean values. Shape: (n_images, rows, cols) |
required |
N
|
ndarray
|
A list/array of weights indicating the number of original images. Shape: (depth,) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The combined mean. Shape: (height, width) |
Notes
Both input arrays are expected to have the same shape. The operation is performed along axis=0.
The combined mean is calculated as
Source code in src/dolphin/ps.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
create_ps(*, reader, output_file, output_amp_mean_file, output_amp_dispersion_file, like_filename, amp_dispersion_threshold=0.25, existing_amp_mean_file=None, existing_amp_dispersion_file=None, nodata_mask=None, update_existing=False, block_shape=(512, 512), **tqdm_kwargs)
Create the amplitude dispersion, mean, and PS files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
StackReader
|
A dataset reader for the 3D SLC stack. |
required |
output_file
|
Filename
|
The output PS file (dtype: Byte) |
required |
output_amp_dispersion_file
|
Filename
|
The output amplitude dispersion file. |
required |
output_amp_mean_file
|
Filename
|
The output mean amplitude file. |
required |
like_filename
|
Filename
|
The filename to use for the output files' spatial reference. |
required |
amp_dispersion_threshold
|
float
|
The threshold for the amplitude dispersion. Default is 0.25. |
0.25
|
existing_amp_mean_file
|
Optional[Filename]
|
An existing amplitude mean file to use, by default None. |
None
|
existing_amp_dispersion_file
|
Optional[Filename]
|
An existing amplitude dispersion file to use, by default None. |
None
|
nodata_mask
|
Optional[ndarray]
|
If provided, skips computing PS over areas where the mask is False Otherwise, loads input data from everywhere and calculates. |
None
|
update_existing
|
bool
|
If providing existing amp mean/dispersion files, combine them with the data from the current SLC stack. If False, simply uses the existing files to create as PS mask. Default is False. |
False
|
block_shape
|
tuple[int, int]
|
The 2D block size to load all bands at a time. Default is (512, 512) |
(512, 512)
|
**tqdm_kwargs
|
optional
|
Arguments to pass to |
{}
|
Source code in src/dolphin/ps.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
multilook_ps_files(strides, ps_mask_file, amp_dispersion_file, block_shape=(512, 512))
Create a multilooked version of the full-res PS mask/amplitude dispersion.
Processes the rasters in blocks to avoid loading entire files into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strides
|
dict[str, int]
|
Decimation factor for 'x', 'y' |
required |
ps_mask_file
|
Filename
|
Name of input full-res uint8 PS mask file |
required |
amp_dispersion_file
|
Filename
|
Name of input full-res float32 amplitude dispersion file |
required |
block_shape
|
tuple[int, int]
|
The (row, col) block size for chunked processing on the output grid.
Input blocks are |
(512, 512)
|
Returns:
| Name | Type | Description |
|---|---|---|
output_ps_file |
Path
|
Multilooked PS mask file
Will be same as |
output_amp_disp_file |
Path
|
Multilooked amplitude dispersion file
Similar naming scheme to |
Source code in src/dolphin/ps.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |