import dascore as dc
# Get a spool from a single file. An examples:// name refers to a
# file in DASCore's example data registry; use your own path here.
file_spool = dc.spool("examples://example_dasdae_event_1.h5")
# get a spool from a directory of files
directory_path = dc.examples.spool_to_directory(dc.get_example_spool())
directory_spool = dc.spool(directory_path).update()
# open the directory's index read-only; its data root is the
# index's directory. An HTTP URL of an index works the same way.
index = directory_path / ".dascore_index.sqlite3"
read_only_spool = dc.spool(index=index)
# get a spool from a single patch
patch = dc.get_example_patch()
spool = dc.spool(patch)
# get a spool spanning several files
paths = sorted(directory_path.glob("*.hdf5"))
several = dc.spool(paths)
assert len(several) == len(directory_spool)spool
spool(
obj: str | Path | UPath | Spool | Patch | collections.abc.Sequence[Patch] | collections.abc.Sequence[str | pathlib._local.Path | upath.core.UPath[str, Path, UPath]] | None = None,
index: str | pathlib._local.Path | upath.core.UPath | None[str, Path, UPath, None] = None,
**kwargs ,
)-> ‘Spool’
Create a spool from a data source, an index, or both.
This is the main function for loading in DASCore.
Parameters
| Parameter | Description |
|---|---|
| obj |
An object from which a spool can be derived: a path, a sequence of paths (each opened as a path is, then combined), a patch, a sequence of patches, or a spool. With index, the data root ofthe index’s relative paths (default: the index’s parent). |
| index |
Path to a spool index. With a local directory obj and a localindex, the directory is indexed at index as usual. Otherwise(no obj, or either one remote, e.g. an HTTP URL) the index opensread-only: nothing is scanned, update raises, and a snap ordascore.config.max_shift other than the recorded one raises. Aremote index is cached locally and re-downloaded when it changes. |
| **kwargs |
For a path, file_format and file_version name its format, andsnap chooses which dimensions its patches read on a grid, as inread. A directory’s index records the snap,and dascore.config.max_shift, it was scanned under, and rescanswhen opened with others. index_path is the deprecated spellingof index.
|