open_archive#
- lsst.images.serialization.open_archive(path, cls=None, *, format=None, partial=True, **backend_kwargs)#
Open an
lsst.imagesfile for incremental, component-wise reads.Dispatches to the appropriate backend by file extension (or, for stream input, by the leading bytes), resolves the registered in-memory type from the file’s schema, and returns a
Readercontext manager.A path with a
.gz/.zstcompression suffix is stream-decompressed into an anonymous temporary file first (in bounded-memory chunks, since compressed data has no random access;partialis ignored for it). zstd requires Python >= 3.14 or thezstandardpackage. Stream input must already be decompressed: whoever produced the stream knows how it was compressed.- Parameters:
path (
Union[str,ParseResult,ResourcePath,Path,IO[bytes]]) – File to read; convertible tolsst.resources.ResourcePath, or a seekable binary stream containing the file’s content.cls (
type[Any] |None, default:None) – Optional expected in-memory type. When given,open_archivevalidates that the file’s schema resolves to a subclass ofcls(raisingTypeErrorotherwise) and the returnedReaderis typed accordingly, soReader.readneeds no cast.format (
str|None, default:None) – Optional backend name ("fits","ndf", or"json") forcing the backend, instead of dispatching on the path’s extension or the stream’s leading bytes.partial (
bool, default:True) – Forwarded to the backendopen_tree; defaults toTrue(a reader is for incremental access). A no-op for the JSON and NDF backends and for stream input.**backend_kwargs (
Any) – Backend-specific open options (e.g.page_sizefor FITS).
- Raises:
ValueError – If the file extension or the stream’s leading bytes are not recognized, or
formatis not a known backend name.ArchiveReadError – If the file’s schema is not registered.
TypeError – If
clsis given and the file’s schema resolves to an incompatible type.
- Return type: