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
|
The timeseries data. |
required |
channel
|
Channel
|
Channel metadata associated with this timeseries. |
required |
data_type
property
data_type
Data type of the data array's elements.
dt
property
dt
The time separation in seconds between successive samples.
dtype
property
dtype
Data type of the data array's elements.
duration
cached
property
duration
Series duration in seconds.
duration_ns
cached
property
duration_ns
Series duration in nanoseconds.
has_nulls
property
has_nulls
Whether the timeseries data contains any null values.
name
property
name
Channel name.
sample_rate
property
sample_rate
Data rate for this series in samples per second (Hz).
t0
property
t0
Timestamp associated with this data, in seconds.
time
cached
property
time
Timestamp associated with this data, in seconds.
times
cached
property
times
The array of times corresponding to all data points in the series.
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()
|
duration
cached
property
duration
Duration of this block, in seconds.
duration_ns
property
duration_ns
Duration of this block, in nanoseconds.
end_ns
cached
property
end_ns
Block end time, in nanoseconds
start_ns
property
start_ns
Block start time, in nanoseconds
t0
property
t0
Timestamp associated with this block, in seconds.
time
cached
property
time
Timestamp associated with this block, in seconds.
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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 | |