API Documentation
DataSource
Source code in src/zizou/data.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | |
to_sds(tr)
Save trace to SDS directory.
Source code in src/zizou/data.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
FDSNWaveforms
Bases: WaveformBaseclass
Source code in src/zizou/data.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
__init__(url, debug=False, fill_value=np.nan)
Get seismic waveforms from FDSN web service.
Source code in src/zizou/data.py
445 446 447 448 449 450 | |
MockSDSWaveforms
Bases: WaveformBaseclass
Mock SDSWaveforms class for testing by creating synthetic data for the requested streams.
Source code in src/zizou/data.py
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 441 | |
__init__(sds_dir)
Get seismic waveforms from a local SDS archive.
Source code in src/zizou/data.py
350 351 352 353 354 355 | |
generate_dataset(rootdir, net, site, loc, comp, start, end)
Generate a test dataset for the integration tests.
Parameters
rootdir : str Parent directory for the test dataset. start : str Start time for the test dataset in ISO 8601 format. end : str End time for the test dataset in ISO 8601 format.
Source code in src/zizou/data.py
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 | |
get_waveforms(net, site, loc, comp, startdate, enddate)
Generate synthetic daily files that start at midnight on the startdate and end at midnight on the enddate. The return the requested timespan from these files.
Source code in src/zizou/data.py
429 430 431 432 433 434 435 436 437 438 439 440 441 | |
save2sds(trace, rootdir)
Save a trace to a SDS directory structure.
Parameters
trace : obspy.Trace
Seismic/acoustic trace to be written to disk.
rootdir : str
Root directory for the SDS directory structure.
Source code in src/zizou/data.py
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 | |
PostProcess
Class for checking waveforms and station metadata for valid values, filling waveform data gaps and removing instrument sensitivity
Source code in src/zizou/data.py
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 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 | |
check_case_incomplete_station_metadata()
The case where a a channel period start/stops during the selected time window. Some parts of the trace in the stream might not correspond to a valid period according to station metadata.
Source code in src/zizou/data.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
check_case_multiple_channel_periods()
Checks if there are multiple channel operation periods in a given time period. If so, different response removal is required.
Source code in src/zizou/data.py
118 119 120 121 122 123 124 125 126 127 128 | |
check_case_no_data()
Checks if either no stream, or no station metadata exist.
Source code in src/zizou/data.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
output_case_multiple_channel_periods()
Stitches two response periods together to make a single merged trace.
Source code in src/zizou/data.py
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 | |
S3Waveforms
Bases: WaveformBaseclass
Source code in src/zizou/data.py
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 501 502 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 | |
get_waveforms(net, site, loc, comp, start, end)
Get seismic waveforms from GeoNet's open data archive on AWS S3.
Source code in src/zizou/data.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 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 | |
SDSWaveforms
Bases: WaveformBaseclass
Source code in src/zizou/data.py
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 | |
__init__(sds_dir, fdsn_urls, staxml_dir, fill_value=np.nan)
Get seismic waveforms from a local SDS archive.
Source code in src/zizou/data.py
300 301 302 303 304 305 306 307 | |
get_waveforms(net, site, loc, comp, startdate, enddate)
| Parameters: |
|
|---|
Source code in src/zizou/data.py
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 | |
VolcanoMetadata
Read volcano/station/channel metadata
Source code in src/zizou/data.py
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
get_available_streams(volcano)
Get available sensor streams for a given volcano.
Parameters
volcano : str Volcano name
Returns
list List of streams in the format 'NET.STA.LOC.CHAN'
Source code in src/zizou/data.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | |
get_eruption_dates(volcano)
Get eruption dates for a given volcano.
Parameters
volcano : str Volcano name.
Returns
list List of datetime.date objects representing eruption dates.
Source code in src/zizou/data.py
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
get_site_information(sitename)
Get site information for a given site. Note that if the same site name exists at multiple volcanoes, the first match will be returned.
Parameters
sitename : str Three-letter site code.
Returns
dict Dictionary with site information as follows: {'volcano': str, 'site': str, 'channels': list, 'latitude': float, 'longitude': float, 'starttime': datetime}
Source code in src/zizou/data.py
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | |
get_unrest_periods(volcano)
Get unrest periods for a given volcano.
Parameters
volcano : str Volcano name.
Returns
list List of datetime.date objects representing start and end dates.
Source code in src/zizou/data.py
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
get_instrument_response(net, site, loc, staxml_dir='./instrument_response', fdsn_urls='https://service.geonet.org.nz')
Retrieve instrument response file in STATIONXML format.
Source code in src/zizou/data.py
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 | |
tilde_request(domain, name, station, method, sensor, aspect, startdate, enddate)
Request data from the tilde API (https://tilde.geonet.org.nz/v3/api-docs/). See the tilde discovery tool for more information: https://tilde.geonet.org.nz/ui/data-discovery/
Parameters
domain : str The domain of the data (e.g. 'manualcollect') name : str The name of the data (e.g. 'plume-SO2-gasflux') station : str The station code (e.g. 'WI000') method : str The method of the data (e.g. 'contouring') sensor : str The sensor of the data (e.g. 'MC01') aspect : str The aspect of the data (e.g. 'nil') startdate : date The start date of the data enddate : date The end date of the data
Returns
pd.DataFrame A pandas dataframe with the requested data
Source code in src/zizou/data.py
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 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
Compute the Real-time Seismic-Amplitude Measurement (RSAM).
EnergyExplainedByRSAM
Bases: RSAM
The proportion of signal energy in the RSAM bandwidth, relative to a 0.5-10 Hz bandwidth.
Source code in src/zizou/rsam.py
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 | |
compute(trace)
| Parameters: |
|
|---|
Source code in src/zizou/rsam.py
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 | |
RSAM
Bases: FeatureBaseClass
RSAM is the mean of the absolute value of a signal filtered between 2 and 5 Hz.
| Parameters: |
|
|---|
Source code in src/zizou/rsam.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 | |
compute(trace)
| Parameters: |
|
|---|
Source code in src/zizou/rsam.py
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 | |
SSAM
Bases: FeatureBaseClass
SSAM is basically the same as computing a spectrogram. Data are split into interval length segments and the spectrum of each section is computed. Before computing the spectrum, the mean is removed and a hanning window is applied to each segment. The percentage of overlap of each segment can be specified with per_lap and Welch-type smoothing can be applied.
| Parameters: |
|
|---|
Source code in src/zizou/ssam.py
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 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 | |
compute(trace)
Compute SSAM for the given trace.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/ssam.py
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 | |
filterbank(nfilters, nfft, fs)
staticmethod
Computes the integral in an array of bandpass filters that separates the input signal into multiple components. Each component consists of a single frequency sub-band of the original signal.
| Parameters: |
|
|---|
Source code in src/zizou/ssam.py
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 | |
sonogram(data, fs, fc1, nofb=8)
staticmethod
Computes the sonogram of the given data which can be windowed or not. The sonogram is determined by the power in half octave bands of the given data.
If data are windowed the analytic signal and the envelope of each window is returned.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/ssam.py
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 | |
Compute the displacement seismic amplitude ratio (DSAR).
DSAR
Bases: FeatureBaseClass
DSAR is the ratio of low frequency to high frequency amplitudes, as suggested in: https://doi.org/10.1130/G46107.1
The time-domain displacement signal is bandpass filtered in two frequency bands, 4.5 to 8 Hz and 8 to 16 Hz, and DSAR is defined as the median ratio of the absolute signals. The quantity is interpreted in the publication as a change in seismic attenuation in the vicinity of the seismic station.
Source code in src/zizou/dsar.py
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 | |
compute(trace)
Compute the displacement seismic amplitude ratio (DSAR).
TODO:
Publication is quite vague and doesn't have enough detail to understand the method. Unclear whether median is every 10 minutes or every day. This affects the bootstrap calc- ulation too, but this might not be necessary..
| Parameters: |
|
|---|
Source code in src/zizou/dsar.py
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 | |
SpectralFeatures
Bases: FeatureBaseClass
Source code in src/zizou/spectral_features.py
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 | |
bandwidth(psd, freq)
staticmethod
The Vanmarcke (1970) bandwidth parameter, q where 0 <= q <= 1. Calculated using the spectral moments of the acceleration power spectral density function. 0 is a Dirac delta PSDF (sine wave), 1 is a flat PSDF (white signal).
Source code in src/zizou/spectral_features.py
158 159 160 161 162 163 164 165 166 167 168 169 170 | |
centralFrequency(psd, freq)
staticmethod
The 'central' frequency of the acceleration power spectral density function (Hz). Defined as the square root of the ratio between the second and zero-th spectral moments. The spectral moments are calculated with log-spaced frequencies.
Source code in src/zizou/spectral_features.py
145 146 147 148 149 150 151 152 153 154 155 156 | |
compute(trace)
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/spectral_features.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 | |
predominantFrequency(psd, freq)
staticmethod
The peak frequency of the acceleration power spectral density function, in Hz.
Source code in src/zizou/spectral_features.py
136 137 138 139 140 141 142 143 | |
The main PCA script
PCA
Bases: AnomalyDetectionBaseClass
Source code in src/zizou/pca.py
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 | |
infer(fq, savedir=None, overwrite=False)
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/pca.py
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 | |
Train an autoencoder to reduce dimensionality of input features.
TiedAutoEncoder
Bases: Module
Applies an tied-weight autoencoder to the incoming data. From https://gist.github.com/northanapon/375e17fb395391c144deff20914e51df Parameters
in_features : int size of each input sample. h_features : List[int] a list of size of each layer for the encoder and the reverse for the decoder. activation : function, optional an activation function to apply for each layer (the default is torch.tanh).
Source code in src/zizou/autoencoder.py
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 | |
__init__(in_features, h_features, activation=F.relu)
Create an autoencoder.
Source code in src/zizou/autoencoder.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
decode(o)
Return decoded data.
Source code in src/zizou/autoencoder.py
79 80 81 82 83 84 85 | |
encode(x)
Return encoded data.
Source code in src/zizou/autoencoder.py
71 72 73 74 75 76 77 | |
forward(x)
Return result of encoding and decoding.
Source code in src/zizou/autoencoder.py
66 67 68 69 | |
reset_parameters()
Reset linear module parameters (from nn.Linear).
Source code in src/zizou/autoencoder.py
87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_trace(data, colour, kws_ssam)
Return a plotly graphics object from a feature.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/visualise.py
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 | |
multi_feature_plot(feature1, feature2, equal_yrange=False, rangeslider=False, log=False, kws_ssam=None)
Return a combined time-series plot of two features.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/visualise.py
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 | |
multi_feature_plot_mpl(feature1, feature2, figsize=(12, 5), **kwargs)
Plot two features in one figure. 2D features have to be plotted first.
Parameters
feature1 : xarray.DataArray First feature to plot. Can be 1D or 2D. feature2 : xarray.DataArray Second feature to plot. Has to be 1D. figsize : tuple, optional Figure size, by default (12, 5)
Returns
matplotlib.figure.Figure Figure with two y-axis.
Source code in src/zizou/visualise.py
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 | |
plot_ssam_mpl(xdf, axes=None, cmap=cm.viridis, figsize=(12, 6), **kwargs)
Plot spectrogram data using matplotlib.
| Parameters: |
|
|---|
Source code in src/zizou/visualise.py
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 | |
plot_ssam_plotly(xdf, cmap='Ice_r', new_fig=True, **kwargs)
Plot spectrogram data using matplotlib.
| Parameters: |
|
|---|
Source code in src/zizou/visualise.py
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 | |
AnomalyDetectionBaseClass
Bases: object
Source code in src/zizou/anomaly_base.py
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 | |
compute_anomaly_index()
A scalar value between 0 and 1 indicating the degree of anomaly (1=most anomaluous).
Source code in src/zizou/anomaly_base.py
279 280 281 282 283 284 285 | |
fit(starttime, endtime)
Train the model.
Source code in src/zizou/anomaly_base.py
240 241 242 243 244 245 | |
infer(starttime, endtime)
Use the model to infer.
Source code in src/zizou/anomaly_base.py
247 248 249 250 251 252 | |
read_model_parameters()
Read principal components or model weights from file
Source code in src/zizou/anomaly_base.py
262 263 264 265 266 267 268 | |
write_hyperparameters()
Store things like random seed, learning rate, number of principal components etc.
Source code in src/zizou/anomaly_base.py
270 271 272 273 274 275 276 277 | |
write_model_parameters()
Write principal components or model weights to file
Source code in src/zizou/anomaly_base.py
254 255 256 257 258 259 260 | |
Functionality common to several modules.
apply_freq_filter(data, filtertype, filterfreq, corners=4, zerophase=False, **options)
Apply frequency filter to seismic data.
Filter parameters are taken from instance attributes
filtertype and filterfreq.
| Parameters: |
|
|---|
Source code in src/zizou/util.py
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 | |
apply_hanning(x, return_window=None)
Apply a hanning window to the given 1D or 2D array along the given axis.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
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 | |
demean(x, axis=None)
Return x minus the mean(x).
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
generate_test_data(dim=1, ndays=30, nfreqs=10, tstart=datetime.utcnow(), feature_name=None, freq_name=None)
Generate a 1D or 2D feature for testing.
Source code in src/zizou/util.py
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 | |
round_time(time, interval)
Find closest multiple of interval to time.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
stack_feature(xrdata, stack_length, interval='10min')
Stack features in a dataarray.
Parameters
xrdata : xarray.DataArray The data array to stack. stack_length : str The length of the stack. interval : str, optional The interval between stacks, by default "10min".
Source code in src/zizou/util.py
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 | |
stride_windows(x, n, noverlap)
Get all windows of x with length n as a single array, using strides to avoid data duplication.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
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 | |
test_signal(nsec=3600, sampling_rate=100.0, frequencies=[0.1, 3.0, 10.0], amplitudes=[0.1, 1.0, 0.7], phases=[0.0, np.pi * 0.25, np.pi], offsets=[0.0, 0.0, 0.0], starttime=UTCDateTime(1970, 1, 1), gaps=False, noise=True, noise_std=0.5, sinusoid=True, addchirp=True, network='NZ', station='BLUB', location='', channel='HHZ')
Produce a test signal for which we know where the peaks are in the spectrogram.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
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 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 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 | |
trace_window_data(trace, window_len, min_len=0.8)
Subdivide an obspy.core.trace.Trace into windows of interval
length and iterate over windows.
:yield: A trace data windowNone
| Parameters: |
|
|---|
Source code in src/zizou/util.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
trace_window_times(trace, window_len, min_len=0.8)
Subdivide an obspy.core.trace.Trace into windows of window_len
length and iterate over window start & end times.
:yield: The window start & end times
| Parameters: |
|
|---|
Source code in src/zizou/util.py
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 | |
window_array(x, nwin, noverlap, remove_mean=True, taper=True, padval=0, return_window=True)
Take a 1-D numpy array and devide it into (overlapping) windows.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/zizou/util.py
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 | |