write#

lsst.images.ndf.write(obj: Any, filename: str | None = None, *, metadata: dict[str, MetadataValue] | None = None, butler_info: ButlerInfo | None = None, compression_options: Mapping[str, Any] | None = None) ArchiveTree#

Write a serializable object to an NDF (HDS-on-HDF5) file.

Parameters#

obj

Object with a serialize method. May carry an _opaque_metadata attribute (a FitsOpaqueMetadata) whose primary-HDU header gets written to /MORE/FITS. This preserves FITS cards on objects that originated from a FITS read; butler provenance is conveyed through butler_info instead.

filename

Path to write to. Must not already exist. If None, an in-memory HDF5 file is used and the on-disk artefact is discarded; the returned tree still reflects all the writes the archive made (useful for tests).

metadata, butler_info

Optional caller-supplied entries that are written into the returned ArchiveTree.

compression_options

Optional dict forwarded to the archive constructor for h5py dataset compression.

Returns#

ArchiveTree

The Pydantic tree the object’s serialize produced (with metadata/butler_info applied).