rupture_id_filter
rupture_id_filter
¶
This module provides a class for filtering solution ruptures.
Classes:
Name | Description |
---|---|
FilterRuptureIds |
a chainable filter for ruptures, returning qualifying rupture ids. |
Examples:
>>> # ruptures within 50km of Hamilton with magnitude between 5.75 and 6.25.
>>> ham50 = solvis.circle_polygon(50000, -37.78, 175.28) # 50km radius around Hamilton
<POLYGON ((175.849 -37.779, 175.847 -37.823, 175.839 -37.866, 175.825 -37.90...>
>>> solution = solvis.InversionSolution.from_archive(filename)
>>> rupture_ids = FilterRuptureIds(solution)\
.for_magnitude(min_mag=5.75, max_mag=6.25)\
.for_polygon(ham50)
>>> # ruptures on any of faults A, B, with magnitude and rupture rate limits
>>> rupture_ids = FilterRuptureIds(solution)\
>>> .for_parent_fault_names(['Alpine: Jacksons to Kaniere', 'Vernon 1' ])\
>>> .for_magnitude(7.0, 8.0)\
>>> .for_rupture_rate(1e-6, 1e-2)
>>> # ruptures on fault A that do not involve fault B:
>>> rupture_ids = FilterRuptureIds(solution)\
>>> .for_parent_fault_names(['Alpine: Jacksons to Kaniere'])\
>>> .for_parent_fault_names(['Vernon 1'], join_prior='difference')
FilterRuptureIds
¶
Bases: ChainableSetBase
A helper class to filter solution ruptures, returning the qualifying rupture_ids.
Source code in solvis/filter/rupture_id_filter.py
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 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 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 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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
__rupture_sections: Optional[pd.DataFrame] = None
instance-attribute
¶
__init__(solution: InversionSolution, drop_zero_rates: bool = True)
¶
Instantiate a new filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution
|
InversionSolution
|
The solution instance to filter on. |
required |
drop_zero_rates
|
bool
|
Exclude ruptures with rupture_rate == 0 (default=True). |
True
|
Source code in solvis/filter/rupture_id_filter.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
all() -> ChainableSetBase
¶
Convenience method returning ids for all solution ruptures.
NB the usual join_prior
argument is not implemented as it doesn't seem useful here.
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of all the rupture_ids. |
Source code in solvis/filter/rupture_id_filter.py
139 140 141 142 143 144 145 146 147 148 |
|
for_magnitude(min_mag: Optional[float] = None, max_mag: Optional[float] = None, join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that occur within given magnitude bounds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_mag
|
Optional[float]
|
The minumum rupture magnitude bound. |
None
|
max_mag
|
Optional[float]
|
The maximum rupture magnitude bound. |
None
|
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter arguments. |
Source code in solvis/filter/rupture_id_filter.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
for_named_fault_names(named_fault_names: Iterable[str], join_type: Union[SetOperationEnum, str] = 'union', join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Filter rupture ids based on named fault names.
This method filters the rupture ids for given named fault names. It supports
both intersection and union operations to combine results from multiple named
faults. The join_type
parameter determines how the sets of rupture ids are
combined, while the join_prior
parameter specifies how these sets are combined
with any existing filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
named_fault_names
|
Iterable[str]
|
A collection of named fault names. |
required |
join_type
|
Union[SetOperationEnum, str]
|
The type of set operation to use for combining results from multiple named faults. It can be either 'union' or 'intersection'. |
'union'
|
join_prior
|
Union[SetOperationEnum, str]
|
The type of set operation to use when combining the filtered rupture ids with any existing filters. It can be either 'intersection' or 'difference'. |
'intersection'
|
Returns:
Name | Type | Description |
---|---|---|
ChainableSetBase |
ChainableSetBase
|
A chainable set containing the filtered rupture ids. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unsupported join_type is provided. |
Source code in solvis/filter/rupture_id_filter.py
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 193 |
|
for_parent_fault_id(parent_fault_id: int, join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that occur on the given parent fault id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_fault_id
|
int
|
The parent fault id to filter by. |
required |
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter. |
Source code in solvis/filter/rupture_id_filter.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
for_parent_fault_ids(parent_fault_ids: Iterable[int], join_type: Union[SetOperationEnum, str] = 'union', join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that occur on the given parent_fault ids.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_fault_ids
|
Iterable[int]
|
A list of one or more |
required |
join_type
|
Union[SetOperationEnum, str]
|
The type of set operation to perform when combining results from multiple parent_fault_ids. Options are 'union' and 'intersection'. |
'union'
|
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter. |
Source code in solvis/filter/rupture_id_filter.py
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 |
|
for_parent_fault_names(parent_fault_names: Iterable[str], join_type: Union[SetOperationEnum, str] = 'union', join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Filter rupture ids based on parent fault names.
This method filters the rupture ids for given parent fault names. It supports
both intersection and union operations to combine results from multiple parent
faults. The join_type
parameter determines how the sets of rupture ids are
combined, while the join_prior
parameter specifies how these sets are combined
with any existing filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_fault_names
|
Iterable[str]
|
A collection of parent fault names. |
required |
join_type
|
Union[SetOperationEnum, str]
|
The type of set operation to use for combining results from multiple parent faults. It can be either 'union' or 'intersection'. |
'union'
|
join_prior
|
Union[SetOperationEnum, str]
|
The type of set operation to use when combining the filtered rupture ids with any existing filters. It can be either 'intersection' or 'difference'. |
'intersection'
|
Returns:
Name | Type | Description |
---|---|---|
ChainableSetBase |
ChainableSetBase
|
A chainable set containing the filtered rupture ids. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unsupported join_type is provided. |
Source code in solvis/filter/rupture_id_filter.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 |
|
for_polygon(polygon: shapely.geometry.Polygon, join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that involve a single polygon area.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon
|
shapely.geometry.Polygon
|
The polygon defining the area of intersection. |
required |
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter arguments. |
Source code in solvis/filter/rupture_id_filter.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
for_polygons(polygons: Iterable[shapely.geometry.Polygon], join_type: Union[SetOperationEnum, str] = SetOperationEnum.UNION, join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures involving several polygon areas.
Each polygon will return a set of matching rupture ids, so the user may choose to override the default set operation (UNION) between these using the `join_type' argument.
This method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygons
|
Iterable[shapely.geometry.Polygon]
|
Polygons defining the areas of interest. |
required |
join_type
|
Union[SetOperationEnum, str]
|
How to join the polygon results (default = 'union'). |
SetOperationEnum.UNION
|
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter arguments. |
Source code in solvis/filter/rupture_id_filter.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
for_rupture_rate(min_rate: Optional[float] = None, max_rate: Optional[float] = None, join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that occur within given rates bounds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_rate
|
Optional[float]
|
The minumum rupture _rate bound. |
None
|
max_rate
|
Optional[float]
|
The maximum rupture _rate bound. |
None
|
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter arguments. |
Source code in solvis/filter/rupture_id_filter.py
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 |
|
for_subsection_ids(fault_section_ids: Iterable[int], join_type: Union[SetOperationEnum, str] = 'union', join_prior: Union[SetOperationEnum, str] = 'intersection') -> ChainableSetBase
¶
Find ruptures that occur on any of the given fault_section_ids.
Return the Union of all rupture ids involvcedin te fault_section_ids
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fault_section_ids
|
Iterable[int]
|
A list of one or more fault_section ids. |
required |
join_type
|
Union[SetOperationEnum, str]
|
The type of set operation to perform when combining results from multiple fault_section_ids. Options are 'union' and 'intersection'. |
'union'
|
join_prior
|
Union[SetOperationEnum, str]
|
How to join this result with the prior chain (if any) (default = 'intersection'). |
'intersection'
|
Returns:
Type | Description |
---|---|
ChainableSetBase
|
A chainable set of rupture_ids matching the filter. |
Source code in solvis/filter/rupture_id_filter.py
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 |
|
tolist() -> List[int]
¶
Returns the filtered rupture ids as a list of integers.
Returns:
Type | Description |
---|---|
List[int]
|
A list of integers representing the filtered rupture ids. |
Source code in solvis/filter/rupture_id_filter.py
130 131 132 133 134 135 136 137 |
|