retrievers
Attributes#
Classes#
DefaultRetriever #
Bases: Retriever
Default API for retrieving data from one or more input sources.
Reads data from one or more inputs, renames coordinates and data variables according to retrieval and dataset configurations, and applies registered DataConverters to retrieved data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
readers |
Dict[Pattern[str], DataReader]
|
A mapping of patterns to DataReaders that the retriever uses to determine which DataReader to use for reading any given input key. |
required |
coords |
Dict[str, Dict[Pattern[str], VariableRetriever]]
|
A dictionary mapping output coordinate variable names to rules for how they should be retrieved. |
required |
data_vars |
Dict[str, Dict[Pattern[str], VariableRetriever]]
|
A dictionary mapping output data variable names to rules for how they should be retrieved. |
required |
Attributes#
readers
instance-attribute
#
A dictionary of DataReaders that should be used to read data provided an input key.
Classes#
Parameters #
Functions#
retrieve #
Source code in tsdat/io/retrievers.py
GlobalARMTransformParams #
Bases: BaseModel
Attributes#
alignment
instance-attribute
#
dim_range
class-attribute
instance-attribute
#
Functions#
default_pattern #
Source code in tsdat/io/retrievers.py
select_parameters #
Source code in tsdat/io/retrievers.py
GlobalFetchParams #
InputKeyRetrievalRules #
InputKeyRetrievalRules(
input_key: InputKey,
coord_rules: Dict[
VarName, Dict[Pattern[Any], RetrievedVariable]
],
data_var_rules: Dict[
VarName, Dict[Pattern[Any], RetrievedVariable]
],
)
Gathers variable retrieval rules for the given input key.
Source code in tsdat/io/retrievers.py
StorageRetriever #
Bases: Retriever
Retriever API for pulling input data from the storage area.
Attributes#
Classes#
TransParameters #
Functions#
retrieve #
retrieve(
input_keys: List[str],
dataset_config: DatasetConfig,
storage: Optional[Storage] = None,
input_data_hook: Optional[
Callable[
[Dict[str, xr.Dataset]], Dict[str, xr.Dataset]
]
] = None,
**kwargs: Any
) -> xr.Dataset
Retrieves input data from the storage area.
Note that each input_key is expected to be formatted according to the following format:
e.g.,
"--datastream sgp.met.b0 --start 20230801 --end 20230901"
"--datastream sgp.met.b0 --start 20230801 --end 20230901 --location_id sgp --data_level b0"
This format allows the retriever to pull datastream data from the Storage API for the desired dates for each desired input source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_keys |
List[str]
|
A list of input keys formatted as described above. |
required |
dataset_config |
DatasetConfig
|
The output dataset configuration. |
required |
storage |
Storage
|
Instance of a Storage class used to fetch saved data. |
None
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: The retrieved dataset |
Source code in tsdat/io/retrievers.py
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 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 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 |
|
StorageRetrieverInput #
Returns an object representation of an input storage key.
Input storage keys should be formatted like:
"--datastream sgp.met.b0 --start 20230801 --end 20230901"
"--datastream sgp.met.b0 --start 20230801 --end 20230901 --location_id sgp --data_level b0"
Source code in tsdat/io/retrievers.py
Functions#
perform_data_retrieval #
perform_data_retrieval(
input_data: Dict[InputKey, xr.Dataset],
coord_rules: Dict[
VarName, Dict[Pattern[Any], RetrievedVariable]
],
data_var_rules: Dict[
VarName, Dict[Pattern[Any], RetrievedVariable]
],
) -> Tuple[RetrievedDataset, RetrievalRuleSelections]
Source code in tsdat/io/retrievers.py
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 |
|