open#
- lsst.images.serialization.open(path: ResourcePathExpression, cls: type[T], *, partial: bool = True, **backend_kwargs: Any) AbstractContextManager[Reader[T]]#
- lsst.images.serialization.open(path: ResourcePathExpression, cls: None = None, *, partial: bool = True, **backend_kwargs: Any) AbstractContextManager[Reader[Any]]
Open an
lsst.imagesfile for incremental, component-wise reads.Dispatches to the appropriate backend by file extension, resolves the registered in-memory type from the file’s schema, and returns a
Readercontext manager.Parameters#
- path
File to read; convertible to
lsst.resources.ResourcePath.- cls
Optional expected in-memory type. When given,
openvalidates that the file’s schema resolves to a subclass ofcls(raisingTypeErrorotherwise) and the returnedReaderis typed accordingly, soReader.readneeds no cast.- partial
Forwarded to the backend
open_tree; defaults toTrue(a reader is for incremental access). A no-op for the JSON and NDF backends.- **backend_kwargs
Backend-specific open options (e.g.
page_sizefor FITS).
Raises#
- ValueError
If the file extension is not recognized.
- ArchiveReadError
If the file’s schema is not registered.
- TypeError
If
clsis given and the file’s schema resolves to an incompatible type.