Data Loading¶
The ovro_lwa_portal.io module provides a unified interface for loading
OVRO-LWA datasets from local paths, remote URLs, and DOI identifiers.
Quick Reference¶
import ovro_lwa_portal
# Local path
ds = ovro_lwa_portal.open_dataset("/path/to/data.zarr")
# Remote URL (S3, HTTPS, GCS)
ds = ovro_lwa_portal.open_dataset("s3://bucket/data.zarr")
# DOI identifier
ds = ovro_lwa_portal.open_dataset("doi:10.5281/zenodo.1234567")
# Custom chunking
ds = ovro_lwa_portal.open_dataset(
"path/to/data.zarr",
chunks={"time": 100, "frequency": 50},
)
Supported Protocols¶
| Protocol | Example | Notes |
|---|---|---|
| Local path | /data/obs.zarr |
Checks existence before loading |
| S3 | s3://bucket/data.zarr |
Via fsspec |
| HTTPS | https://example.com/data.zarr |
Via fsspec |
| GCS | gs://bucket/data.zarr |
Via fsspec |
| Azure | abfs://container/data.zarr |
Via fsspec |
| DOI | doi:10.5281/zenodo.1234567 |
Resolves via DataCite API |
Full API Reference¶
io
¶
Data loading utilities for OVRO-LWA datasets.
This module provides a unified interface for loading OVRO-LWA data from multiple sources including local paths, remote URLs, and DOI identifiers.
DataSourceError
¶
resolve_source(source, production=True, storage_options=None)
¶
Resolve a data source to its final URL without loading data.
Performs DOI resolution and URL normalization, returning the full resolution chain. Useful for debugging DOI→URL→S3 resolution without actually loading any data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or Path
|
Data source, can be: - Local file path (e.g., "/path/to/data.zarr") - Remote URL (e.g., "s3://bucket/data.zarr", "https://...") - DOI string (e.g., "doi:10.xxxx/xxxxx" or "10.xxxx/xxxxx") |
required |
production
|
bool
|
Which DataCite API to use when resolving DOI identifiers. |
True
|
storage_options
|
dict
|
Options passed to the filesystem backend (e.g., S3 credentials). Used to determine if OSN HTTPS→S3 conversion should be applied. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Resolution details with keys:
- |
Raises:
| Type | Description |
|---|---|
DataSourceError
|
If DOI resolution fails. |
Examples:
Resolve a DOI to see the full chain:
>>> from ovro_lwa_portal import resolve_source
>>> info = resolve_source("10.33569/9wsys-h7b71", production=False)
>>> info["source_type"]
'doi'
>>> info["resolved_url"]
'https://caltech1.osn.mghpcc.org/...'
Resolve with S3 credentials to see OSN conversion:
>>> info = resolve_source(
... "10.33569/9wsys-h7b71",
... production=False,
... storage_options={"key": "ACCESS_KEY", "secret": "SECRET_KEY"},
... )
>>> info["s3_url"]
's3://...'
Source code in src/ovro_lwa_portal/io.py
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 | |
open_dataset(source, chunks='auto', production=True, storage_options=None, engine='zarr', validate=True, **kwargs)
¶
Load OVRO-LWA data as an xarray Dataset.
This function provides a unified interface for loading OVRO-LWA data from multiple sources including local file paths, remote URLs, and DOI identifiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or Path
|
Data source, can be: - Local file path (e.g., "/path/to/data.zarr") - Remote URL (e.g., "s3://bucket/data.zarr", "https://...") - DOI string (e.g., "doi:10.xxxx/xxxxx" or "10.xxxx/xxxxx") |
required |
chunks
|
dict, str, or None
|
Chunking strategy for lazy loading: - dict: Explicit chunk sizes per dimension, e.g., {"time": 100, "frequency": 50} - "auto": Let xarray/dask determine optimal chunks - None: Load entire dataset into memory (not recommended for large data) |
"auto"
|
production
|
bool
|
Which DataCite API to use when resolving DOI identifiers: - True: production API (api.datacite.org) - False: test API (api.test.datacite.org) |
True
|
storage_options
|
dict
|
Options passed to the filesystem backend (e.g., S3 credentials). Example: storage_options={"key": "ACCESS_KEY", "secret": "SECRET_KEY"} |
None
|
engine
|
str
|
Backend engine for loading data. Currently supports "zarr". |
"zarr"
|
validate
|
bool
|
If True, validate that loaded data conforms to OVRO-LWA data model. |
True
|
**kwargs
|
Any
|
Additional arguments passed to the underlying loader (xr.open_zarr, etc.) |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
OVRO-LWA dataset with standardized structure. |
Raises:
| Type | Description |
|---|---|
DataSourceError
|
If source cannot be accessed or loaded. |
FileNotFoundError
|
If local file path doesn't exist. |
ImportError
|
If required dependencies for remote/DOI access are not installed. |
Examples:
Load from local zarr store:
Load from S3 bucket:
Load from HTTP/HTTPS URL:
Load via DOI (with or without prefix):
>>> ds = ovro_lwa_portal.open_dataset("doi:10.5281/zenodo.1234567")
>>> ds = ovro_lwa_portal.open_dataset("10.5281/zenodo.1234567")
Load from test DataCite API with S3 credentials:
>>> ds = ovro_lwa_portal.open_dataset(
... "10.33569/4q7nb-ahq31",
... production=False,
... storage_options={"key": "ACCESS_KEY", "secret": "SECRET_KEY"}
... )
Customize chunking:
>>> ds = ovro_lwa_portal.open_dataset(
... "path/to/data.zarr",
... chunks={"time": 100, "frequency": 50}
... )
Notes
For remote data sources (S3, GCS), authentication is handled via environment variables or configuration files specific to each cloud provider:
- AWS S3: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, or ~/.aws/credentials
- Google Cloud Storage: GOOGLE_APPLICATION_CREDENTIALS
- Azure: AZURE_STORAGE_ACCOUNT_NAME, AZURE_STORAGE_ACCOUNT_KEY
For large datasets, lazy loading with dask is used by default (chunks="auto"). This allows working with datasets larger than memory.
Source code in src/ovro_lwa_portal/io.py
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 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 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 | |