opticam.utils.fits_handlers

Functions

get_header_info(file, barycenter, logger)

Get the BMJD, filter, binning, gain, and dark current from a file header.

get_time(header, file)

Parse the time from the header of a FITS file.

get_data(file, flat_corrector, rebin_factor, ...)

Get the image data from a FITS file. The dark current "flux" contribution is automatically computed and subtracted

get_header(file)

Get the header of a FITS file.

save_stacked_images(stacked_images, out_directory, ...)

Save the stacked images to a compressed FITS cube.

get_stacked_images(out_directory)

Unpacked the stacked catalog images from out_directory/cat.

get_image_noise_info(file_path)

Given a FITS file, get the image and corresponding filter, exposure time, dark current, and gain.

Module Contents

opticam.utils.fits_handlers.get_header_info(file, barycenter, logger)

Get the BMJD, filter, binning, gain, and dark current from a file header.

Parameters

filestr

The file path.

barycenterbool

Whether to apply a Barycentric correction to the image time stamps.

loggerLogger | None

The logger.

Returns

Tuple[float | None, str | None, str | None, float | None, float | None]

The BMJD, filter, binning, gain, and dark current.

Parameters:
  • file (str)

  • barycenter (bool)

  • logger (logging.Logger | None)

Return type:

Tuple[float | None, str | None, str | None, float | None, float | None]

opticam.utils.fits_handlers.get_time(header, file)

Parse the time from the header of a FITS file.

Parameters

header

The FITS file header.

filestr

The path to the file.

Returns

float

The time of the observation in MJD.

Raises

ValueError

If the time cannot be parsed from the header.

KeyError

If neither ‘GPSTIME’ nor ‘UT’ keys are found in the header.

Parameters:
  • header (astropy.io.fits.Header)

  • file (str)

Return type:

float

opticam.utils.fits_handlers.get_data(file, flat_corrector, rebin_factor, remove_cosmic_rays)

Get the image data from a FITS file. The dark current “flux” contribution is automatically computed and subtracted from the returned image.

Parameters

filestr

The file.

flat_correctorFlatFieldCorrector | None

The FlatFieldCorrector instance (if specified).

rebin_factorint

The rebin factor.

remove_cosmic_raysbool

Whether to remove cosmic rays from the image.

Returns

Tuple[NDArray, float]

The image data (after subtracting the dark current “flux” contribution) and the dark current “flux” contribution.

Raises

ValueError

If file could not be opened.

Parameters:
Return type:

Tuple[numpy.typing.NDArray, float]

opticam.utils.fits_handlers.get_header(file)

Get the header of a FITS file.

Parameters

filestr

_description_

Returns

fits.Header

_description_

Parameters:

file (str)

Return type:

astropy.io.fits.Header

opticam.utils.fits_handlers.save_stacked_images(stacked_images, out_directory, overwrite)

Save the stacked images to a compressed FITS cube.

Parameters

stacked_imagesDict[str, NDArray]

The stacked images (filter: stacked image).

Parameters:
  • stacked_images (Dict[str, numpy.typing.NDArray])

  • out_directory (str)

  • overwrite (bool)

Return type:

None

opticam.utils.fits_handlers.get_stacked_images(out_directory)

Unpacked the stacked catalog images from out_directory/cat.

Parameters

out_directorystr

The directory path to the reduction output.

Returns

Dict[str, NDArray]

The stacked images {filter: image}.

Parameters:

out_directory (str)

Return type:

Dict[str, numpy.typing.NDArray]

opticam.utils.fits_handlers.get_image_noise_info(file_path)

Given a FITS file, get the image and corresponding filter, exposure time, dark current, and gain.

Parameters

file_pathstr

The path to the FITS file.

Returns

Tuple[NDArray, float, Quantity]

The image, dark flux, and gain.

Parameters:

file_path (str)

Return type:

Tuple[numpy.typing.NDArray, float, float]