depsi.classification
depsi.classification.ps_selection(slcs, threshold, method='nad', output_chunks=10000, mem_persist=False, ps_selection_start_date=None, ps_selection_end_date=None)
Select Persistent Scatterers (PS) from an SLC stack, and return a Space-Time Matrix.
The selection method is defined by method and threshold.
The selected pixels will be reshaped to (space, time), where space is the number of selected pixels.
The unselected pixels will be discarded.
The original azimuth and range coordinates will be persisted.
The computed NAD or NMAD will be added to the output dataset as a new variable. It can be persisted in
memory if mem_persist is True.
The original time axis will be preserved in all cases. If ps_selection_start_date and ps_selection_end_date
are provided, the selection will only use the images in the provided time window. However, the full time axis
will be preserved and returned. In this case, the layers time_selection_nmad / time_selection_nad and
full_ts_nmad / full_ts_nad are thus different.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slcs
|
Dataset
|
Input SLC stack. It should have the following dimensions: ("azimuth", "range", "time").
There should be a |
required |
threshold
|
float
|
Threshold value for selection for "nad" / "nmad". |
required |
method
|
Literal['nad', 'nmad']
|
Method of selection, by default "nad". - "nad": Normalized Amplitude Dispersion - "nmad": Normalized median absolute deviation |
'nad'
|
output_chunks
|
int
|
Chunk size in the |
10000
|
mem_persist
|
bool
|
If true persist the NAD or NMAD in memory, by default False. |
False
|
ps_selection_start_date
|
datetime | str | None
|
the start date of the time window to be used for the ps_selection, in one of three formats: - datetime object - str object, formatted as YYYYMMDD - None, no cropping in time requested for the ps_selection (default) |
None
|
ps_selection_end_date
|
datetime | str | int | None
|
the end date of the time window to be used for the ps_selection, in one of four formats: - datetime object - str object, formatted as YYYYMMDD - int object, which is interpreted as the number of images intended in the crop (including the start date). If more images are requested than exist since the start date, all images from start_date until the last image are provided. - None, no cropping in time requested for the ps_selection (default) |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Selected STM, in form of an xarray.Dataset with dimensions: - space ( # PS selected) - time ( # epochs of input dataset) with coordinates: - time: epoch in np.datetime64 format - space: index of the PS - azimuth: azimuth coordinate of the PS - range: range coordinate of the PS with attributes: - ps_selection_start_date: the epoch of the first image used for the PS selection - ps_selection_end_date: the epoch of the last image used for the PS selection with variables: - h2ph (space, time): the height to phase conversion - lat (space): latitude of the PS - lon (space): longitude of the PS - complex (space, time): the complex value of the PS at each epoch - amplitude (space, time): the amplitude of the PS at each epoch - phase (space, time): the phase of the PS at each epoch - time_selection_nad / time_selection_nmad (space): the value used for selection of the PS, dependent on method - full_ts_nad (space): the Normalized Amplitude Dispersion of the PS - full_ts_nmad (space): the Normalized Median Amplitude Dispersion of the PS - pnt_class (space): 1 for all selected PS |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Raised when an unsupported method is provided. |
Source code in depsi/classification.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
depsi.classification.network_stm_selection(stm, min_dist, include_index=None, sortby_var='time_selection_nmad', crs='radar', x_var='azimuth', y_var='range', azimuth_spacing=None, range_spacing=None)
Select a Space-Time Matrix (STM) from a candidate STM for network processing.
The selection is based on two criteria: 1. A minimum distance between selected points. 2. A sorting metric to select better points.
The candidate STM will be sorted by the sorting metric. The selection will be performed iteratively, starting from the best point. In each iteration, the best point will be selected, and points within the minimum distance will be removed. The process will continue until no points are left in the candidate STM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stm
|
Dataset
|
candidate Space-Time Matrix (STM). |
required |
min_dist
|
int | float
|
Minimum distance between selected points. The unit is determined by |
required |
include_index
|
list[int]
|
Index of points in the candidate STM that must be included in the selection, by default None |
None
|
sortby_var
|
str
|
Sorting metric for selecting points, by default "time_selection_nmad" |
'time_selection_nmad'
|
crs
|
int | str
|
EPSG code of Coordinate Reference System of |
'radar'
|
x_var
|
str
|
Data variable name for x coordinate, by default "azimuth" |
'azimuth'
|
y_var
|
str
|
Data variable name for y coordinate, by default "range" |
'range'
|
azimuth_spacing
|
float
|
Azimuth pixel spacing, by default None. Required if crs is "radar". |
None
|
range_spacing
|
float
|
Range pixel spacing, by default None. Required if crs is "radar". |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Selected network Space-Time Matrix (STM). |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when |
NotImplementedError
|
Raised when an unsupported Coordinate Reference System is provided. |
Source code in depsi/classification.py
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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |