Module: reprojection#

kbmod.reprojection.image_add_to_hdu(add, name, obstime, wcs=None)[source]#

Helper function that creates a HDU out of post reproject added image.

Parameters:
addnp.ndarray

The image to convert.

namestr

The name of the image (type + index).

obstimefloat

The observation time.

wcsastropy.wcs.WCS

An optional WCS to include in the header.

Returns:
hduastropy.io.fits.hdu.image.ImageHDU

The image extension.

kbmod.reprojection.reproject_image(image, original_wcs, common_wcs)[source]#

Given an ndarray representing image data (either science or variance, when used with reproject_work_unit), as well as a common wcs, return the reprojected image and footprint as a numpy.ndarray.

Returns:
new_imagenumpy.ndarray

The image data reprojected with a common astropy.wcs.WCS.

footprintnumpy.ndarray

An array containing the footprint of pixels that have data. for footprint[i][j], it’s 1 if there is a corresponding reprojected pixel and 0 if there is no data.

Attributes:
imagekbmod.search.RawImage or numpy.ndarray

The image data to be reprojected.

original_wcsastropy.wcs.WCS

The WCS of the original image.

common_wcsastropy.wcs.WCS

The WCS to reproject all the images into.

kbmod.reprojection.reproject_lazy_work_unit(work_unit, common_wcs, directory, filename, frame='original', max_parallel_processes=8, show_progress=None)[source]#

Given a WorkUnit and a WCS, reproject all of the images in the ImageStack into a common WCS. This function is used with lazily evaluated WorkUnit`s and multiprocessing to reproject the images in parallel, and only loads the individual image frames at runtime. Currently only works for sharded `WorkUnit`s loaded with the `lazy option.

Attributes:
work_unitkbmod.WorkUnit

The WorkUnit to be reprojected.

common_wcsastropy.wcs.WCS

The WCS to reproject all the images into.

directorystr

The directory where the WorkUnit fits shards will be output.

filenamestr

The base filename (will be the actual name of the primary/metadata fits file and included with the index number in the filename of the shards).

framestr

The WCS frame of reference to use when reprojecting. Can either be ‘original’ or ‘ebd’ to specify which WCS to access from the WorkUnit.

max_parallel_processesint

The maximum number of parallel processes to use when reprojecting. Default is 8. For more see concurrent.futures.ProcessPoolExecutor in the Python docs.

show_progressbool or None, optional

If None use default settings, when a boolean forces the progress bar to be displayed or hidden.

kbmod.reprojection.reproject_work_unit(work_unit, common_wcs, frame='original', parallelize=True, max_parallel_processes=8, write_output=False, directory=None, filename=None, show_progress=None)[source]#

Given a WorkUnit and a WCS, reproject all of the images in the ImageStack into a common WCS.

Returns:
A kbmod.WorkUnit reprojected with a common astropy.wcs.WCS, or None in the case
where write_output is set to True.
Attributes:
work_unitkbmod.WorkUnit

The WorkUnit to be reprojected.

common_wcsastropy.wcs.WCS

The WCS to reproject all the images into.

framestr

The WCS frame of reference to use when reprojecting. Can either be ‘original’ or ‘ebd’ to specify which WCS to access from the WorkUnit.

parallelizebool

If True, use multiprocessing to reproject the images in parallel. Default is True.

max_parallel_processesint

The maximum number of parallel processes to use when reprojecting. Only used when parallelize is True. Default is 8. For more see concurrent.futures.ProcessPoolExecutor in the Python docs.

write_outputbool

Whether or not to write the reprojection results out as a sharded WorkUnit.

directorystr

The directory where output will be written if write_output is set to True.

filenamestr

The base filename where output will be written if write_output is set to True.

show_progressbool or None, optional

If None use default settings, when a boolean forces the progress bar to be displayed or hidden.