Input Files =========== KBMOD expects Vera C. Rubin Science Pipelines calexp-style data with at least a science and variance plane for each image. The core unit of data is the :py:class:`~kbmod.work_unit.WorkUnit` object, which holds the images and related metadata. WorkUnits objects can be created from a variety of sources including a set of multi-extension FITS files or references to the data's location on a Butler instance. They can also be saved to disk and reloaded for future analyis. WorkUnit Files -------------- The :py:class:`~kbmod.work_unit.WorkUnit` objects provide functions for writing to and loading from files. In addition to image data, the :py:class:`~kbmod.work_unit.WorkUnit` includes configuration data for the run and all necessary metadata (e.g. the WCS). To load a :py:class:`~kbmod.work_unit.WorkUnit` from a file, use:: my_wu = WorkUnit.from_fits(input_filename) The images in a :py:class:`~kbmod.work_unit.WorkUnit` can either be in their original frame or reprojected to a common pixel grid. If they have been reprojected, the object’s `reprojected` is set to true. Reprojected sets of images have additional metadata, such as a mapping for the image’s index to those of the constituent images from which it was created. The metadata for the original images is stored in an AstroPy Table in the `org_img_meta` attribute. This contains details such as each image’s WCS, data location and filter. Butler ------ TODO FITS Files ---------- If loading data from raw FITS files, these must be Vera C. Rubin Science Pipelines calexp-style FITS files that contain: * photometrically and astometrically calibrated single-CCD image, usually referred to as the "science image", * variance image, representing per-pixel noise levels, and a * pixel bitmask stored in 1st, 2nd and 3rd header extension/plane respectively. The zeroth header extension is expected to contain the image metadata. A single FITS file can be loaded with the :py:meth:`~kbmod.util_functions.load_deccam_layered_image` function, which takes the file name and an optional numpy array of the PSF kernel and produces a :py:class:`~kbmod.core.image_stack_py.LayeredImagePy`. To build an :py:class:`~kbmod.image_collection.ImageCollection` from multiple FITS files, use the class's :py:meth:`~kbmod.image_collection.ImageCollection.fromDir()` function. The images within a single run are expected to be warped, i.e. geometrically transformed to a set of images with a consistent and uniform relationship between sky coordinates and image pixels on a shared pixel grid.