Multichannel time series
Time series data for several channels on one grid, and an ordered list of such series.
MultichannelTimeSeries
¶
Time series data for several channels on one sample grid.
Each channel is a :class:gwmock_data.TimeSeries, the series the gwmock packages share; indexing
returns one. The channel names used when the data is written ("H1:STRAIN" and the like) are
kept here, in :attr:channels, since the shared series has a name and a unit but no channel.
Timing is reported as astropy quantities (seconds, hertz), as before.
Source code in src/gwmock_data/multichannel_series.py
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 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 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 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 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 | |
duration
property
¶
Get the duration of the time series.
Returns:
| Type | Description |
|---|---|
Quantity
|
Duration of the time series, in seconds: the number of samples times the sample spacing. |
end_time
property
¶
Get the end time of the time series.
Returns:
| Type | Description |
|---|---|
Quantity
|
End time of the time series. |
sampling_frequency
property
¶
Get the sampling frequency of the time series.
Returns:
| Type | Description |
|---|---|
Quantity
|
Sampling frequency of the time series, in hertz. |
shape
property
¶
start_time
property
¶
Get the start time of the time series.
Returns:
| Type | Description |
|---|---|
Quantity
|
Start time of the time series, in seconds. |
time_array
property
¶
Get the time array of the time series.
Returns:
| Type | Description |
|---|---|
Quantity
|
GPS time of every sample, in seconds. |
__eq__(other)
¶
Check equality with another MultichannelTimeSeries object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
object
|
Another MultichannelTimeSeries object to compare with. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the two MultichannelTimeSeries objects are equal, False otherwise. |
Source code in src/gwmock_data/multichannel_series.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__getitem__(index)
¶
Get one channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the channel to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
TimeSeries
|
The channel's series. |
Source code in src/gwmock_data/multichannel_series.py
85 86 87 88 89 90 91 92 93 94 | |
__init__(data, start_time, sampling_frequency)
¶
Initialize the MultichannelTimeSeries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
2D numpy array of shape (num_of_channels, num_samples) containing the time series data. |
required |
start_time
|
float | Quantity
|
Start time of the time series in GPS seconds. |
required |
sampling_frequency
|
float | Quantity
|
Sampling frequency of the time series in Hz. |
required |
Source code in src/gwmock_data/multichannel_series.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
__iter__()
¶
Iterate over the channels in the time series.
Returns:
| Type | Description |
|---|---|
Iterator[TimeSeries]
|
Iterator over the channels' series. |
Source code in src/gwmock_data/multichannel_series.py
131 132 133 134 135 136 137 | |
__len__()
¶
Get the number of channels in the time series.
Returns:
| Type | Description |
|---|---|
int
|
Number of channels in the time series. |
Source code in src/gwmock_data/multichannel_series.py
77 78 79 80 81 82 83 | |
__setitem__(index, value)
¶
Replace one channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the channel to set. |
required |
value
|
TimeSeries
|
The new series for the channel: a :class: |
required |
Source code in src/gwmock_data/multichannel_series.py
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 | |
contributes_samples(other)
¶
Whether injecting other into this segment would place at least one sample.
Provenance needs this, and it cannot be recovered after the fact: injection sums chunks into shared channels, so once a segment is built there is no way to ask which signal put samples where. It has to be asked before.
Deliberately a time predicate rather than a look at the data. A chunk of genuine zeros -- a signal whose amplitude is below the sample quantum, or a segment covering only its tapered edge -- still means the signal is present in that frame, which is what a provenance record is claiming. Reading the samples would call that absent.
Answered on the sample grid, with the same computation :meth:inject places by: a chunk
contributes when some grid point of this segment lies within its sample span. A chunk ending
exactly at self.start_time therefore does not -- its last sample is one interval before
the segment's first -- and neither does an off-grid chunk overlapping an edge by less than
a sample, which places nothing here because no grid point of this segment falls inside it.
This is tested across the boundary rather than argued, in
test_provenance_across_segments.py, because an off-by-one here silently over- or
under-reports one frame per signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
MultichannelTimeSeries
|
The chunk that would be injected. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/gwmock_data/multichannel_series.py
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 | |
crop(start_time=None, end_time=None)
¶
Crop the time series, in place, to the samples at GPS times in [start_time, end_time).
A bound that falls on a sample, to within float64 resolution at the GPS epoch, counts as on
it, so cropping at a sample's own time keeps that sample (see gwmock_data.TimeSeries.crop).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
Quantity | float | None
|
Start time of the cropped segment in GPS seconds. If None, use the original start time. |
None
|
end_time
|
Quantity | float | None
|
End time of the cropped segment in GPS seconds. If None, use the original end time. |
None
|
A crop that removes samples leaves a piece cut from the series, so it also removes the
:data:TAPERED_METADATA_KEY mark: the piece no longer falls smoothly to zero at its ends.
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeries
|
This MultichannelTimeSeries, cropped. |
Source code in src/gwmock_data/multichannel_series.py
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 | |
from_json_dict(json_dict)
classmethod
¶
Create a MultichannelTimeSeries object from a JSON-serializable dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_dict
|
dict
|
JSON-serializable dictionary representation of the MultichannelTimeSeries. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MultichannelTimeSeries |
MultichannelTimeSeries
|
An instance of the MultichannelTimeSeries class created from the dictionary. |
Source code in src/gwmock_data/multichannel_series.py
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 | |
inject(other, preceding_gap=None)
¶
Inject another MultichannelTimeSeries into the current MultichannelTimeSeries.
A chunk whose samples fall on this segment's grid is added sample for sample. A chunk that
sits a fraction of a sample off the grid is first resampled, as a whole, onto this segment's
grid -- extended past either end of the segment -- with the band-limited windowed-sinc kernel
gwmock_signal.projection.resampling.resample_uniform_sinc, and a warning is logged. Only
grid points within the chunk's own sample span are produced; nothing is extrapolated beyond
its first or last sample.
Resampling the whole chunk rather than the part inside this segment is what keeps a signal continuous across segment boundaries: the kernel needs about half its taps of context on either side, which a per-segment resample would cut at every boundary. It also means the returned remainder of an off-grid chunk is the resampled series, already on this segment's grid, so a contiguous next segment adds it without resampling it a second time.
This replaces linear interpolation, which at 0.8 x Nyquist was off by ~0.63 of the signal's peak; the sinc kernel's error there is ~1e-12. Off-grid injections therefore produce different samples from earlier releases, most visibly at high frequency.
The kernel is :func:gwmock_data.resampling.resample_uniform_sinc, the one the gwmock packages share,
so an off-grid chunk is resampled here exactly as gwmock-signal resamples when it projects. It is
accurate to 0.8 x Nyquist; a chunk whose metadata marks it tapered (:data:TAPERED_METADATA_KEY) is
first oversampled exactly (:func:gwmock_data.resampling.oversample_fourier) and is accurate up to
its Nyquist frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
MultichannelTimeSeries
|
MultichannelTimeSeries instance to inject. |
required |
preceding_gap
|
tuple[float, float] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeries | None
|
What this segment could not place, for the next segment. other itself, unchanged, if |
MultichannelTimeSeries | None
|
it ends before this segment starts or starts after it ends, in which case nothing is |
MultichannelTimeSeries | None
|
injected. Otherwise the part of the chunk past this segment's end, if it extends beyond |
MultichannelTimeSeries | None
|
it; for an off-grid chunk that is the resampled series, on this segment's grid, carrying |
MultichannelTimeSeries | None
|
other's metadata, channel names and units. |
MultichannelTimeSeries | None
|
segment, or if it is an off-grid chunk whose sample span contains no grid point at all |
MultichannelTimeSeries | None
|
(a single sample between two grid points), in which case nothing is injected and a |
MultichannelTimeSeries | None
|
warning is logged. |
Source code in src/gwmock_data/multichannel_series.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 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 | |
inject_from_list(ts_iterable, preceding_gap=None)
¶
Inject multiple MultichannelTimeSeries from an iterable into the current MultichannelTimeSeries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts_iterable
|
Iterable[MultichannelTimeSeries]
|
Iterable of MultichannelTimeSeries instances to inject. |
required |
preceding_gap
|
tuple[float, float] | None
|
A configured segment gap immediately before this segment; see
:meth: |
None
|
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeriesList
|
MultichannelTimeSeriesList of remaining MultichannelTimeSeries instances that extend beyond the current MultichannelTimeSeries end time. |
Source code in src/gwmock_data/multichannel_series.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
to_json_dict()
¶
Convert the MultichannelTimeSeries to a JSON-serializable dictionary.
Assume the unit
Returns:
| Type | Description |
|---|---|
dict
|
JSON-serializable dictionary representation of the MultichannelTimeSeries. |
Source code in src/gwmock_data/multichannel_series.py
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 | |
MultichannelTimeSeriesList
¶
Bases: Iterable[MultichannelTimeSeries]
List of MultichannelTimeSeries objects with validation.
Source code in src/gwmock_data/multichannel_series.py
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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 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 786 787 788 789 790 791 | |
__getitem__(index)
¶
__getitem__(index: int) -> MultichannelTimeSeries
__getitem__(index: slice) -> list[MultichannelTimeSeries]
Get item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int | slice
|
Index or slice to get. |
required |
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeries | list[MultichannelTimeSeries]
|
MultichannelTimeSeries object or list of MultichannelTimeSeries objects. |
Source code in src/gwmock_data/multichannel_series.py
677 678 679 680 681 682 683 684 685 686 | |
__init__(iterable=None)
¶
List of MultichannelTimeSeries objects with validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
list[MultichannelTimeSeries] | None
|
Optional list of MultichannelTimeSeries objects to initialize the list. |
None
|
Source code in src/gwmock_data/multichannel_series.py
616 617 618 619 620 621 622 623 624 625 626 | |
__iter__()
¶
Iterate over the MultichannelTimeSeries objects in the list.
Returns:
| Type | Description |
|---|---|
Iterator[MultichannelTimeSeries]
|
Iterator over the MultichannelTimeSeries objects in the list. |
Source code in src/gwmock_data/multichannel_series.py
696 697 698 699 700 701 702 | |
__len__()
¶
Get the number of MultichannelTimeSeries objects in the list.
Returns:
| Type | Description |
|---|---|
int
|
Number of MultichannelTimeSeries objects in the list. |
Source code in src/gwmock_data/multichannel_series.py
688 689 690 691 692 693 694 | |
__repr__()
¶
Get the string representation of the MultichannelTimeSeriesList.
Returns:
| Type | Description |
|---|---|
str
|
String representation of the MultichannelTimeSeriesList. |
Source code in src/gwmock_data/multichannel_series.py
785 786 787 788 789 790 791 | |
__setitem__(index, value)
¶
__setitem__(
index: int, value: MultichannelTimeSeries
) -> None
__setitem__(
index: slice, value: Iterable[MultichannelTimeSeries]
) -> None
Set item with validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int | slice
|
Index or slice to set. |
required |
value
|
MultichannelTimeSeries | Iterable[MultichannelTimeSeries]
|
MultichannelTimeSeries object or list of MultichannelTimeSeries objects to set. |
required |
Source code in src/gwmock_data/multichannel_series.py
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | |
append(value)
¶
Append a MultichannelTimeSeries object to the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
MultichannelTimeSeries
|
MultichannelTimeSeries object to append. |
required |
Source code in src/gwmock_data/multichannel_series.py
704 705 706 707 708 709 710 711 712 | |
extend(iterable)
¶
Extend the list with MultichannelTimeSeries objects from an iterable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[MultichannelTimeSeries]
|
Iterable of MultichannelTimeSeries objects to extend the list. |
required |
Source code in src/gwmock_data/multichannel_series.py
714 715 716 717 718 719 720 721 722 | |
from_json_dict(data)
classmethod
¶
Reconstruct a MultichannelTimeSeriesList instance from a JSON dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary with keys: 'data' containing list of MultichannelTimeSeries dicts. |
required |
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeriesList
|
Reconstructed MultichannelTimeSeriesList instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required keys are missing or data format is invalid. |
Source code in src/gwmock_data/multichannel_series.py
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 | |
insert(index, value)
¶
Insert a MultichannelTimeSeries object at a specific index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index to insert at. |
required |
value
|
MultichannelTimeSeries
|
MultichannelTimeSeries object to insert. |
required |
Source code in src/gwmock_data/multichannel_series.py
724 725 726 727 728 729 730 731 732 733 | |
pop(index=-1)
¶
Pop item at index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index to pop. Defaults to -1 (last item). |
-1
|
Returns:
| Type | Description |
|---|---|
MultichannelTimeSeries
|
MultichannelTimeSeries object that was popped. |
Source code in src/gwmock_data/multichannel_series.py
735 736 737 738 739 740 741 742 743 744 | |
to_json_dict()
¶
Convert the MultichannelTimeSeriesList to a JSON-serializable dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON-serializable dictionary representation of the MultichannelTimeSeriesList. |
Source code in src/gwmock_data/multichannel_series.py
746 747 748 749 750 751 752 753 754 755 756 | |