block
Series block representation of timeseries data.
Series
dataclass
¶
Series(time_ns, data, channel)
Single-channel timeseries data for a given timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_ns
|
int
|
The timestamp associated with this data, in nanoseconds. |
required |
data
|
ndarray or MaskedArray
|
The timeseries data. |
required |
channel
|
Channel
|
Channel metadata associated with this timeseries. |
required |
SeriesBlock
dataclass
¶
SeriesBlock(time_ns, data, channels=dict())
Series block containing timeseries for channels for a given timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_ns
|
int
|
The timestamp associated with this data, in nanoseconds. |
required |
data
|
dict[str, ndarray]
|
Mapping between channels and timeseries. |
required |
channels
|
dict[str, Channel]
|
Channel metadata associated with this data block. |
dict()
|
create_gaps ¶
create_gaps(channels)
Add channels with all null values (gaps).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channels
|
Iterable[Channel]
|
The channels to create gaps for. Any channels currently present will be ignored. |
required |
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The block with additional gaps present. |
Source code in arrakis/block.py
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 | |
filter ¶
filter(channels=None)
Filter a block based on criteria.
Fixme
more info needed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channels
|
list[str]
|
If specified, keep only these channels. |
None
|
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The filtered series. |
Source code in arrakis/block.py
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 | |
from_column_batch
classmethod
¶
from_column_batch(batch, channels)
Create a series block from a record batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
A record batch, with a 'time' column with the timestamp and channel columns with all channels to publish. |
required |
channels
|
dict[str, Channel]
|
Channel metadata. The metadata for the channels defined in the batch will be extracted from this dictionary, so this dictionary may include metadata for additional channels not included in the batch. |
required |
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The block representation of the record batch. |
Source code in arrakis/block.py
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 | |
from_row_batch
classmethod
¶
from_row_batch(batch, index_to_channel)
Create a series block from a record batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
A record batch, with a 'time' column with the timestamp, a 'channel' column with the channel name, and a 'data' column containing the timeseries. |
required |
index_to_channel
|
dict[int, Channel]
|
Mapping from the id (channel index) to the channel. The channel name is not encoded in the record batch in order to save space. Instead, an index value is sent. This is the reverse mapping, back to the channel. It is specific to the partitioning of the channels. |
required |
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The block representation of the record batch. |
Source code in arrakis/block.py
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 | |
full_gap
classmethod
¶
full_gap(time_ns, duration_ns, channels)
Create a block with all null values (gaps).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_ns
|
int
|
GPS time in nanoseconds of the resulting SeriesBlock. |
required |
duration_ns
|
int
|
Duration of SeriesBlock in nanoseconds. |
required |
channels
|
Iterable[Channel]
|
The channels for the SeriesBlock. |
required |
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The full-gap block. |
Source code in arrakis/block.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 | |
to_column_batch ¶
to_column_batch(schema=None)
Create a row-based record batch from a series block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Schema
|
Pre-defined schema to use for the record batch. If provided, the schema must be compatible with the block's data (matching channel names and types). If not provided, a schema will be generated from the block's data. |
None
|
Returns:
| Type | Description |
|---|---|
RecordBatch
|
A record batch, with a 'time' column with the timestamp and channel columns with all channels to publish. |
Raises:
| Type | Description |
|---|---|
ArrowInvalid
|
If the provided schema is incompatible with the block's data, such as missing channels, mismatched channel names, or incompatible data types. |
Source code in arrakis/block.py
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 | |
to_row_batches ¶
to_row_batches(partitioned_channels)
Create column-based record batches from a series block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
partitioned_channels
|
dict[str, Channel]
|
Mapping between channel names and Channel objects that contain necessary partition information (partition names and indices). |
required |
Yields:
| Type | Description |
|---|---|
RecordBatch
|
Record batches, one per data type. The record batches have a 'time' column with the timestamp, a 'channel' column with the channel name, and a 'data' column containing the timeseries. |
Source code in arrakis/block.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 | |
combine_blocks ¶
combine_blocks(*blocks)
Combine multiple SeriesBlocks from the same time into a single SeriesBlock
Each block must contain a distinct set of channels, and the time properties of each block must agree, otherwise an AssertionError will be thrown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*blocks
|
SeriesBlock
|
The blocks to combine. |
()
|
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The combined block. |
Source code in arrakis/block.py
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 | |
concatenate_blocks ¶
concatenate_blocks(*blocks)
Join a sequence of timeseries blocks into a single block.
If the SeriesBlock arguments are not sequential in time an AssertionError will be thrown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*blocks
|
SeriesBlock
|
The timeseries blocks to concatenate. |
()
|
Returns:
| Type | Description |
|---|---|
SeriesBlock
|
The combined timeseries block. |
Source code in arrakis/block.py
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 | |
time_as_ns ¶
time_as_ns(time)
Convert a timestamp from seconds to nanoseconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float
|
The timestamp to convert, in seconds. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The converted timestamp, in nanoseconds. |
Source code in arrakis/block.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |