Coverage for python / lsst / images / serialization / __init__.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-07 08:34 +0000

1# This file is part of lsst-images. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12"""The `OutputArchive` and `InputArchive` classes, which abstract over 

13different file formats, and various related utilities. 

14 

15These archive interfaces are designed with two specific implementations in 

16mind: 

17 

18- FITS augmented with a JSON block in a special BINTABLE HDU (see the `.fits` 

19 module for details), inspired by the now-defunct ASDF-in-FITS concept. 

20 

21- ASDF (just hypothetical for now). 

22 

23The base classes make some concessions to both FITS and ASDF in order to make 

24the representations in those formats conform to their respective expectations. 

25 

26For ASDF, this is simple: we use ASDF schemas whenever possible to represent 

27primitive types, from units and times to multidimensional arrays. While the 

28archive interfaces use Pydantic, which maps to JSON, not YAML, the expectation 

29is that by encoding YAML tag information in the JSON Schema (which Pydantic 

30allows us to customize), it should be straightforward for an ASDF archive 

31implementation to have Pydantic dump to a Python `dict` (etc) tree, and then 

32convert that to tagged YAML by walking the tree along with its schema. 

33 

34For FITS, the challenge is primarily to populate standard FITS header cards 

35when writing, despite the fact that FITS headers are generally too limiting to 

36be our preferred way of round-tripping any information. To do this, the 

37archive interfaces accept ``update_header`` and ``strip_header`` callback 

38arguments that are only called by FITS implementations. 

39 

40An implementation that writes HDF5 while embedding JSON should also be possible 

41with these interfaces, but is not something we've designed around. A more 

42natural HDF5 implementation might be possible by translating the JSON tree into 

43a binary HDF5 hierarchy as well, but this would be considerably more effort at 

44best. 

45""" 

46 

47from ._asdf_utils import * 

48from ._common import * 

49from ._dtypes import * 

50from ._output_archive import * 

51from ._input_archive import * 

52from ._tables import *