pypeit.images.buildimage module

Uber object for calibration images, e.g. arc, flat

class pypeit.images.buildimage.AlignImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Alignment Image

calib_type = 'Align'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'ALIGN_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('ALIGN_IMAGE', 'ALIGN_FULLMASK', 'ALIGN_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.ArcImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Arc Image

calib_type = 'Arc'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'ARC_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('ARC_IMAGE', 'ARC_FULLMASK', 'ARC_DETECTOR', 'ARC_DET_IMG')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.BiasImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Bias Image

calib_type = 'Bias'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'BIAS_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('BIAS_IMAGE', 'BIAS_IVAR', 'BIAS_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.DarkImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Dark Image

calib_type = 'Dark'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'DARK_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('DARK_IMAGE', 'DARK_IVAR', 'DARK_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.ScatteredLightImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Scattered Light Image

calib_type = 'ScattLight'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'SCATTLIGHT_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('SCATTLIGHT_IMAGE', 'SCATTLIGHT_FULLMASK', 'SCATTLIGHT_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.SkyRegions(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the SkyRegions Image

calib_file_format = 'fits.gz'

The extension and file format of the output file. Should be 'fits' or 'fits.gz' (for gzipped output).

calib_type = 'SkyRegions'

The type of the calibration frame, primarily used to set the name of the output file.

classmethod construct_file_name(calib_key, calib_dir=None, basename=None)[source]

Override the base-class filename construction to optionally include a basename.

Parameters:
  • calib_key (str) – String identifier of the calibration group. See construct_calib_key().

  • calib_dir (str, Path, optional) – If provided, return the full path to the file given this directory.

  • basename (str, optional) – If provided include this in the output file name.

Returns:

File path or file name

Return type:

str

hdu_prefix = 'SKYREG_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = 'SKYREG_IMAGE'

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.TiltImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Tilt Image

calib_type = 'Tiltimg'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'TILT_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('TILT_IMAGE', 'TILT_FULLMASK', 'TILT_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

class pypeit.images.buildimage.TraceImage(image, ivar=None, nimg=None, amp_img=None, det_img=None, rn2img=None, base_var=None, img_scale=None, fullmask=None, detector=None, spat_flexure=None, PYP_SPEC=None, units=None, exptime=None, noise_floor=None, shot_noise=None, bpm=None, crmask=None, usermask=None, clean_mask=False)[source]

Bases: PypeItCalibrationImage

Simple DataContainer for the Trace Image

calib_type = 'Trace'

The type of the calibration frame, primarily used to set the name of the output file.

hdu_prefix = 'TRACE_'

If set, all HDUs generated for this DataContainer will have this prefix. This can be set independently for each DataContainer derived class; however, it always defaults to None for the base class. Be wary of nested DataContainer’s!!

output_to_disk = ('TRACE_IMAGE', 'TRACE_FULLMASK', 'TRACE_DETECTOR')

If set, this limits the HDU extensions that are written to the output file. Note this is the name of the extension, including the hdu_prefix, not necessarily the names of specific datamodel components.

pypeit.images.buildimage.buildimage_fromlist(spectrograph, det, frame_par, file_list, bias=None, bpm=None, dark=None, scattlight=None, flatimages=None, maxiters=5, ignore_saturation=True, slits=None, mosaic=None, calib_dir=None, setup=None, calib_id=None)[source]

Perform basic image processing on a list of images and combine the results.

Warning

For image mosaics (when det is a tuple) the processing behavior is hard-coded such that bias and dark frames are not reformatted into a mosaic image. They are saved in their native multi-image format. Bad-pixel masks are also expected to be in multi-image format. See RawImage.

Parameters:
  • spectrograph (Spectrograph) – Spectrograph used to take the data.

  • det (int, tuple) – The 1-indexed detector number(s) to process. If a tuple, it must include detectors viable as a mosaic for the provided spectrograph; see allowed_mosaics().

  • frame_par (FrameGroupPar) – Parameters that dictate the processing of the images. See ProcessImagesPar for the defaults.

  • file_list (list) – List of files

  • bias (BiasImage, optional) – Bias image for bias subtraction; passed directly to process() for all images.

  • bpm (numpy.ndarray, optional) – Bad pixel mask; passed directly to process() for all images.

  • dark (DarkImage, optional) – Dark-current image; passed directly to process() for all images.

  • scattlight (ScatteredLight, optional) – Scattered light model to be used to determine scattered light.

  • flatimages (FlatImages, optional) – Flat-field images for flat fielding; passed directly to process() for all images.

  • maxiters (int, optional) – When combine_method='mean') and sigma-clipping (sigma_clip is True), this sets the maximum number of rejection iterations. If None, rejection iterations continue until no more data are rejected; see weighted_combine().

  • ignore_saturation (bool, optional) – If True, turn off the saturation flag in the individual images before stacking. This avoids having such values set to 0, which for certain images (e.g. flat calibrations) can have unintended consequences.

  • slits (SlitTraceSet, optional) – Edge traces for all slits. These are used to calculate spatial flexure between the image and the slits, and for constructing the slit-illumination correction. See pypeit.images.rawimage.RawImage.process.

  • mosaic (bool, optional) – Flag processed image will be a mosaic of multiple detectors. By default, this is determined by the format of det and whether or not this is a bias or dark frame. Only used for testing purposes.

  • calib_dir (str, Path, optional) – The directory for processed calibration files. Required for elements of frame_image_classes, ignored otherwise.

  • setup (str, optional) – The setup/configuration identifier to use for this dataset. Required for elements of frame_image_classes, ignored otherwise.

  • calib_id (str, optional) – The string listing the set of calibration groups associated with this dataset. Required for elements of frame_image_classes, ignored otherwise.

Returns:

PypeItImage, PypeItCalibrationImage: The processed and combined image.

pypeit.images.buildimage.frame_image_classes = {'align': <class 'pypeit.images.buildimage.AlignImage'>, 'arc': <class 'pypeit.images.buildimage.ArcImage'>, 'bias': <class 'pypeit.images.buildimage.BiasImage'>, 'dark': <class 'pypeit.images.buildimage.DarkImage'>, 'scattlight': <class 'pypeit.images.buildimage.ScatteredLightImage'>, 'tilt': <class 'pypeit.images.buildimage.TiltImage'>, 'trace': <class 'pypeit.images.buildimage.TraceImage'>}

The list of classes that buildimage_fromlist() should use to decorate the output for the specified frame types.

All of these must subclass from PypeItCalibrationImage.