mirar.processors package

This module contains the processors that are used to process the raw data

Subpackages

Submodules

mirar.processors.base_catalog_xmatch_processor module

Base processor for any functionality requiring cross-matching a reference catalog to a Sextractor catalog

class mirar.processors.base_catalog_xmatch_processor.BaseProcessorWithCrossMatch(ref_catalog_generator: Callable[[Image], BaseCatalog], crossmatch_radius_arcsec: float, required_parameters: list[str], catalogs_purifier: Callable[[Table, Table, Image], list[Table, Table]], write_regions: bool = False, cache: bool = False, temp_output_sub_dir: str = 'astrom_stats')[source]

Bases: BaseImageProcessor, ABC

Photometric calibrator processor Attributes:

ref_catalog_generator: function to generate reference catalog temp_output_sub_dir: subdirectory to store temporary files catalogs_purifier: function to purify photometric catalog and reference catalog crossmatch_radius_arcsec: crossmatch radius in arcsec write_regions: whether to write regions file cache: whether to cache the temporary files made by this processor

base_key = 'astrometrystatswriter'
check_prerequisites()[source]

Check to see if any prerequisite processors are missing

Returns:

None

description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_sextractor_apertures() list[float][source]

Function to extract sextractor aperture sizes from config file Returns:

get_sextractor_module() Sextractor[source]

Get the Sextractor module from the preceding steps

setup_catalogs(image)[source]

Setup the reference catalog and image catalog

write_regions_files(image: Image, ref_cat: Table, img_cat: Table)[source]

Write regions files for the reference catalog and the image catalog

mirar.processors.base_catalog_xmatch_processor.default_image_sextractor_catalog_purifier(sci_catalog: ~astropy.table.table.Table, ref_catalog: ~astropy.table.table.Table | None, image: ~mirar.data.image_data.Image, edge_width_pixels: float = 100.0, fwhm_threshold_arcsec: float = 4.0) -> (<class 'astropy.table.table.Table'>, <class 'astropy.table.table.Table'>)[source]

Default function to purify the photometric image catalog

mirar.processors.base_catalog_xmatch_processor.xmatch_catalogs(ref_cat: ~astropy.table.table.Table, image_cat: ~astropy.table.table.Table, crossmatch_radius_arcsec: float) -> (<class 'astropy.table.table.Table'>, <class 'astropy.table.table.Table'>, <class 'astropy.coordinates.angles.core.Angle'>)[source]

Cross-match the reference catalog to the image catalog

mirar.processors.base_processor module

Module containing the BaseProcessor

class mirar.processors.base_processor.BaseImageProcessor[source]

Bases: BaseProcessor, ImageHandler, ABC

Base processor handling images in/images out

class mirar.processors.base_processor.BaseProcessor[source]

Bases: object

Base processor class, to be inherited from for all processors

apply(batch: DataBatch)[source]

Function applying the processor to a DataBatch. Also updates the processing history.

Parameters:

batch – input data batch

Returns:

updated data batch

apply_to_batch(queue, cache_id: int)[source]

Function to run self.apply on a batch in the queue, catch any errors, and then update the internal cache with the results.

Parameters:
  • queue – python threading queue

  • cache_id – key for cache

Returns:

None

base_apply(dataset: Dataset) tuple[Dataset, ErrorStack][source]

Core function to act on a dataset, and return an updated dataset

Parameters:

dataset – Input dataset

Returns:

Updated dataset, and any caught errors

property base_key

Unique key for the processor, to be used e.g in processing history tracking

Returns:

None

check_duplicates(batch: DataBatch)[source]

Function to check for duplicate names in a batch

Parameters:

batch – Input data batch

Returns:

None

check_prerequisites()[source]

Check to see if any prerequisite processors are missing

Returns:

None

clean_cache(cache_id: int)[source]

Function to clean the internal cache filled by base_apply

Parameters:

cache_id – key for cache

Returns:

None

description() str[source]

Return a description of the processor

Returns:

A description of the processor

generate_error_report(exception: Exception, batch: DataBatch) ErrorReport[source]

Generates an error report based on a python Exception

Parameters:
  • exception – exception raised

  • batch – batch which generated exception

Returns:

error report

max_n_cpu: int = 1
set_night(night_sub_dir: str | int = '')[source]

Sets the night subdirectory for the processor to read/write data

Parameters:

night_sub_dir – String/int subdirectory for night

Returns:

None

set_preceding_steps(previous_steps: list)[source]

Provides processor with the list of preceding processors, and saves this

Parameters:

previous_steps – list of processors

Returns:

None

subclasses = {'APERPHOT': <class 'mirar.processors.photometry.aperture_photometry.AperturePhotometry'>, 'AVRO': <class 'mirar.processors.avro.ipac_avro_exporter.IPACAvroExporter'>, 'CSVEXPORT': <class 'mirar.processors.sources.csv_exporter.CSVExporter'>, 'DETCANDS': <class 'mirar.processors.sources.source_detector.ZOGYSourceDetector'>, 'DETSOURC': <class 'mirar.processors.sources.sextractor_source_detector.SextractorSourceDetector'>, 'IMGUPDATE': <class 'mirar.processors.sources.image_updater.ImageUpdater'>, 'JSONEXPORT': <class 'mirar.processors.sources.json_exporter.JSONExporter'>, 'JSONLOAD': <class 'mirar.processors.sources.json_loader.JSONLoader'>, 'PARQUETWRITE': <class 'mirar.processors.sources.parquet_writer.ParquetWriter'>, 'PRQULOAD': <class 'mirar.processors.sources.parquet_loader.ParquetLoader'>, 'PSFPHOT': <class 'mirar.processors.photometry.psf_photometry.PSFPhotometry'>, 'REFPREP': <class 'mirar.processors.reference.ProcessReference'>, 'REGWRIT': <class 'mirar.processors.sources.utils.regions_writer.RegionsWriter'>, 'SRCLOAD': <class 'mirar.processors.sources.source_loader.SourceLoader'>, 'SRCWRITE': <class 'mirar.processors.sources.source_exporter.SourceWriter'>, 'XMATCH': <class 'mirar.processors.xmatch.XMatch'>, 'ZOGY': <class 'mirar.processors.zogy.zogy.ZOGY'>, 'ZOGYPREP': <class 'mirar.processors.zogy.zogy.ZOGYPrepare'>, 'a-net': <class 'mirar.processors.astrometry.anet.anet_processor.AstrometryNet'>, 'astrometry_from_file': <class 'mirar.processors.astrometry.utils.AstrometryFromFile'>, 'astrometrystatswriter': <class 'mirar.processors.astrometry.validate.AstrometryStatsWriter'>, 'autoastrometry': <class 'mirar.processors.astrometry.autoastrometry.autoastrometry_processor.AutoAstrometry'>, 'batch': <class 'mirar.processors.sources.source_selector.SourceBatcher'>, 'bias': <class 'mirar.processors.bias.MasterBiasCalibrator'>, 'calhunt': <class 'mirar.processors.utils.cal_hunter.CalHunter'>, 'catlimmagcalc': <class 'mirar.processors.catalog_limiting_mag.CatalogLimitingMagnitudeCalculator'>, 'csvlog': <class 'mirar.processors.csvlog.CSVLog'>, 'custom_image_modifier': <class 'mirar.processors.utils.image_modifier.CustomImageBatchModifier'>, 'custom_source_modifier': <class 'mirar.processors.sources.source_table_modifier.CustomSourceTableModifier'>, 'dark': <class 'mirar.processors.dark.MasterDarkCalibrator'>, 'dbinserter': <class 'mirar.processors.database.database_inserter.DatabaseImageBatchInserter'>, 'dbselector': <class 'mirar.processors.database.database_selector.DatabaseHistorySelector'>, 'dbupdater': <class 'mirar.processors.database.database_updater.ImageDatabaseMultiEntryUpdater'>, 'debatch': <class 'mirar.processors.sources.source_selector.SourceDebatcher'>, 'egdemask': <class 'mirar.processors.sources.edge_mask.EdgeSourcesMask'>, 'errorannotate': <class 'mirar.processors.utils.error_annotator.ErrorStackAnnotator'>, 'filter': <class 'mirar.processors.sources.source_filter.BaseSourceFilter'>, 'flat': <class 'mirar.processors.flat.MasterFlatCalibrator'>, 'forcedphot': <class 'mirar.processors.sources.forced_photometry.ForcedPhotometryDetector'>, 'header_annotator': <class 'mirar.processors.utils.header_annotate.HeaderAnnotator'>, 'header_editor': <class 'mirar.processors.utils.header_annotate.HeaderEditor'>, 'header_reader': <class 'mirar.processors.utils.header_reader.HeaderReader'>, 'imagebatchrefcatdownloader': <class 'mirar.processors.photcal.photcalibrator.ImageBatchReferenceCatalogDownloader'>, 'lacosmic': <class 'mirar.processors.cosmic_rays.LACosmicCleaner'>, 'load': <class 'mirar.processors.utils.multi_ext_parser.MultiExtParser'>, 'load_from_header': <class 'mirar.processors.utils.image_loader.LoadImageFromHeader'>, 'load_mef': <class 'mirar.processors.utils.image_loader.MEFLoader'>, 'loadlist': <class 'mirar.processors.utils.image_loader.ImageListLoader'>, 'maskdatasec': <class 'mirar.processors.mask.MaskDatasecPixels'>, 'maskfromfunction': <class 'mirar.processors.mask.MaskPixelsFromFunction'>, 'maskfrompath': <class 'mirar.processors.mask.MaskPixelsFromPath'>, 'maskfrompathinverted': <class 'mirar.processors.mask.MaskPixelsFromPathInverted'>, 'maskthresh': <class 'mirar.processors.mask.MaskAboveThreshold'>, 'maskwcs': <class 'mirar.processors.mask.MaskPixelsFromWCS'>, 'modemask': <class 'mirar.processors.utils.mode_masker.ModeMasker'>, 'namer': <class 'mirar.processors.sources.namer.CandidateNamer'>, 'nanfill': <class 'mirar.processors.utils.nan_filler.NanFiller'>, 'photcalibrator': <class 'mirar.processors.photcal.photcalibrator.PhotCalibrator'>, 'plot': <class 'mirar.processors.utils.image_plotter.ImagePlotter'>, 'psfex': <class 'mirar.processors.astromatic.psfex.psfex.PSFex'>, 'pytorch': <class 'mirar.processors.sources.machine_learning.pytorch.Pytorch'>, 'rebatch': <class 'mirar.processors.sources.source_selector.SourceRebatcher'>, 'ref_aligner': <class 'mirar.processors.zogy.reference_aligner.AlignReference'>, 'refimg_returner': <class 'mirar.processors.reference.GetReferenceImage'>, 'reject': <class 'mirar.processors.utils.image_rejector.ImageRejector'>, 'save': <class 'mirar.processors.utils.image_saver.ImageSaver'>, 'scamp': <class 'mirar.processors.astromatic.scamp.scamp.Scamp'>, 'select': <class 'mirar.processors.sources.source_selector.SourceSelector'>, 'sextractor': <class 'mirar.processors.astromatic.sextractor.sextractor.Sextractor'>, 'sextractorbkgsubtractor': <class 'mirar.processors.astromatic.sextractor.background_subtractor.SextractorBkgSubtractor'>, 'simrealtime': <class 'mirar.processors.utils.simulate_realtime.RealtimeImageSimulator'>, 'sky': <class 'mirar.processors.sky.MasterSkyCalibrator'>, 'skyportalsender': <class 'mirar.processors.skyportal.skyportal_candidate.SkyportalCandidateUploader'>, 'split': <class 'mirar.processors.split.SwarpImageSplitter'>, 'swarp': <class 'mirar.processors.astromatic.swarp.swarp.Swarp'>, 'swarp_component_images': <class 'mirar.processors.astromatic.swarp.component_images.ReloadSwarpComponentImages'>, 'writemaskedcoords': <class 'mirar.processors.mask.WriteMaskedCoordsToFile'>, 'xgboost': <class 'mirar.processors.sources.machine_learning.xgboost.XGBoost'>, <property object>: <class 'mirar.processors.photometry.base_photometry.BasePhotometryProcessor'>}
update_dataset(dataset: Dataset) Dataset[source]

Update a dataset after processing

Parameters:

dataset – Initial dataset

Returns:

Updated dataset

class mirar.processors.base_processor.BaseSourceGenerator[source]

Bases: CleanupProcessor, ImageHandler, ABC

Base CandidateGenerator processor (image batch in, source batch out)

get_metadata(image: Image) dict[source]

Get metadata from image

Parameters:

image – Image to get metadata from

Returns:

Metadata dictionary

class mirar.processors.base_processor.BaseSourceProcessor[source]

Bases: BaseProcessor, ABC

Base dataframe processor (Source batch in, source batch out)

static generate_super_dict(metadata: dict, source_row: Series) dict[source]

Generate a dictionary of metadata and candidate row, with lower case keys

Parameters:
  • metadata – Metadata for the source table

  • source_row – Individual row of the source table

Returns:

Combined dictionary

class mirar.processors.base_processor.CleanupProcessor[source]

Bases: BaseProcessor, ABC

Processor which ‘cleans up’ by deleting empty batches

update_dataset(dataset: Dataset) Dataset[source]

Update a dataset after processing

Parameters:

dataset – Initial dataset

Returns:

Updated dataset

exception mirar.processors.base_processor.DuplicationError[source]

Bases: ProcessorError

An error raised if a processor returns multiple images with the same name

class mirar.processors.base_processor.ImageHandler[source]

Bases: object

Base class for handling images

static get_hash(image_batch: ImageBatch)[source]

Get a unique hash for an image batch

Parameters:

image_batch – image batch

Returns:

unique hash for that batch

static open_fits(path: str | Path) Image[source]

Opens a fits file, and returns an Image object

Parameters:

path – Path of image

Returns:

Image object

static save_fits(image: Image, path: str | Path, compress: bool = False)[source]

Save an Image to path

Parameters:
  • image – Image to save

  • path – path

  • compress – whether to compress the fits file

Returns:

None

save_mask_image(image: Image, img_path: Path, compress: bool = False) Path[source]

Saves a mask image, following the astromatic software convention of masked value = 0. and non-masked value = 1.

Parameters:
  • image – Science image

  • img_path – Path of parent image

  • compress – Whether to compress the mask image

Returns:

Path of mask image

exception mirar.processors.base_processor.NoCandidatesError[source]

Bases: ProcessorError

An error raised if a CandidateGenerator produces no candidates

exception mirar.processors.base_processor.PrerequisiteError[source]

Bases: ProcessorError

An error raised if a processor requires another one as a prerequisite, but that processor is not present

class mirar.processors.base_processor.ProcessorPremadeCache(master_image_path_generator: Callable[[ImageBatch], Path], *args, **kwargs)[source]

Bases: ProcessorWithCache, ABC

Processor with pre-made master image

get_cache_path(images: ImageBatch) Path[source]

Gets path for saving/loading cached image

Parameters:

images – Images to process

Returns:

Path to cached image

class mirar.processors.base_processor.ProcessorWithCache(try_load_cache: bool = True, write_to_cache: bool = True, overwrite: bool = True, cache_sub_dir: str = 'calibration', cache_image_name_header_keys: str | list[str] | None = None)[source]

Bases: BaseImageProcessor, ABC

Image processor with cached images associated to it, e.g a master flat

get_cache_file(images: ImageBatch) Image[source]

Return the appropriate cached image for the batch

Parameters:

images – images to process

Returns:

cached image to use

get_cache_file_name(images: ImageBatch) str[source]

Get unique cache name for images

Parameters:

images – images to process

Returns:

unique hashed name

get_cache_path(images: ImageBatch) Path[source]

Gets path for saving/loading cached image

Parameters:

images – images to process

Returns:

cache path

make_image(images: ImageBatch) Image[source]

Make a cached image (e.g master flat)

Parameters:

images – images to use

Returns:

cached image

select_cache_images(images: ImageBatch) ImageBatch[source]

Select the appropriate cached image for the batch

Parameters:

images – images to process

Returns:

cached images to use

mirar.processors.bias module

Module containing processors for bias correction

class mirar.processors.bias.BiasCalibrator(*args, select_bias_images: ~collections.abc.Callable[[~mirar.data.image_data.ImageBatch], ~mirar.data.image_data.ImageBatch] = <function default_select_bias>, **kwargs)[source]

Bases: ProcessorWithCache

Processor to bias-correct images

base_key = 'bias'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

make_image(images: ImageBatch) Image[source]

Make a cached image (e.g master flat)

Parameters:

images – images to use

Returns:

cached image

class mirar.processors.bias.MasterBiasCalibrator(master_image_path_generator: Callable[[ImageBatch], Path], *args, **kwargs)[source]

Bases: ProcessorPremadeCache, BiasCalibrator

Processor to bias-correct with a master bias

description() str[source]

Return a description of the processor

Returns:

A description of the processor

mirar.processors.bias.default_select_bias(images: ImageBatch) ImageBatch[source]

Returns images in a batch with are tagged as bias

Parameters:

images – set of images

Returns:

subset of bias images

mirar.processors.catalog_limiting_mag module

Module to calculate the brightest and faintest stars detected in the image

class mirar.processors.catalog_limiting_mag.CatalogLimitingMagnitudeCalculator(image_photometric_catalog_purifier: ~typing.Callable[[~astropy.table.table.Table, ~mirar.data.image_data.Image], ~astropy.table.table.Table] = <function default_lim_mag_sextractor_catalog_purifier>, sextractor_mag_key_name: str = 'MAG_AUTO', write_regions: bool = False)[source]

Bases: BaseImageProcessor

Processor to calculate the limiting magnitude of an image based on the SEXTRACTOR catalog

base_key = 'catlimmagcalc'
check_prerequisites()[source]

Check to see if any prerequisite processors are missing

Returns:

None

description() str[source]

Return a description of the processor

Returns:

A description of the processor

mirar.processors.catalog_limiting_mag.default_lim_mag_sextractor_catalog_purifier(catalog: Table, image: Image) Table[source]

Default function to purify the photometric image catalog

Parameters:
  • catalog – Catalog to purify

  • image – Image object

Returns:

Purified catalog

mirar.processors.cosmic_rays module

Module containing processors that mask cosmic rays

exception mirar.processors.cosmic_rays.CRCleanError[source]

Bases: NoncriticalProcessingError

Error derived from running cosmic ray cleaning processor

class mirar.processors.cosmic_rays.LACosmicCleaner(contrast=2, cr_threshold=5, neighbor_threshold=0.3, error=None, background=None, effective_gain=None, readnoise=None, maxiter=4, border_mode='mirror', min_exptime=None, effective_gain_key=None, readnoise_key=None)[source]

Bases: BaseImageProcessor

Processor to mask out cosmic rays.

base_key = 'lacosmic'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

max_n_cpu: int = 1

mirar.processors.csvlog module

Module to generate a CSV log of observations

class mirar.processors.csvlog.CSVLog(export_keys: list[str] | None = None, output_sub_dir: str = '', output_base_dir: str | None = None, output_name: str = 'log')[source]

Bases: BaseImageProcessor

Processor to generate a CSV log

base_key = 'csvlog'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_log_name() str[source]

Returns the custom log name

Returns:

Log file name

get_output_path() Path[source]

Returns the full log output path

Returns:

log path

max_n_cpu: int = 1

mirar.processors.dark module

Module for applying dark corrections

class mirar.processors.dark.DarkCalibrator(*args, select_cache_images: ~collections.abc.Callable[[~mirar.data.image_data.ImageBatch], ~mirar.data.image_data.ImageBatch] = <function default_select_dark>, **kwargs)[source]

Bases: ProcessorWithCache

Processor for applying dark correction

base_key = 'dark'
base_name = 'master_dark'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

make_image(images: ImageBatch) Image[source]

Make a cached image (e.g master flat)

Parameters:

images – images to use

Returns:

cached image

class mirar.processors.dark.MasterDarkCalibrator(master_image_path_generator: Callable[[ImageBatch], Path], *args, **kwargs)[source]

Bases: ProcessorPremadeCache, DarkCalibrator

Processor to apply master dark corrections

exception mirar.processors.dark.MissingDarkError[source]

Bases: ImageNotFoundError

Error for when a dark image is missing

mirar.processors.dark.default_select_dark(images: ImageBatch) ImageBatch[source]

Function to select images in a batch tagged as ‘dark’

Parameters:

images – images to filter

Returns:

batch of dark images

mirar.processors.flat module

Module containing processors for flat calibration

class mirar.processors.flat.FlatCalibrator(*args, x_min: int = 0, x_max: int = 9223372036854775807, y_min: int = 0, y_max: int = 9223372036854775807, flat_nan_threshold: float = 0.0, select_flat_images: ~collections.abc.Callable[[~mirar.data.image_data.ImageBatch], ~mirar.data.image_data.ImageBatch] = <function default_select_flat>, flat_mask_key: str = None, flat_mode: str = 'median', **kwargs)[source]

Bases: ProcessorWithCache

Processor to apply flat calibration

base_key = 'flat'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

make_image(images: ImageBatch) Image[source]

Make a cached image (e.g master flat)

Parameters:

images – images to use

Returns:

cached image

class mirar.processors.flat.MasterFlatCalibrator(master_image_path_generator: Callable[[ImageBatch], Path], *args, **kwargs)[source]

Bases: ProcessorPremadeCache, FlatCalibrator

Processor to do flat calibration with a master flate

exception mirar.processors.flat.MissingFlatError[source]

Bases: ImageNotFoundError

Error for when a dark image is missing

class mirar.processors.flat.SkyFlatCalibrator(*args, flat_mask_key=None, **kwargs)[source]

Bases: FlatCalibrator

Processor to do flat calibration using sky flats

description() str[source]

Return a description of the processor

Returns:

A description of the processor

static select_sky_flat(images: ImageBatch) ImageBatch[source]

Select science images to use as sky flats

Parameters:

images – set of images

Returns:

subset of ‘sky’ images

mirar.processors.flat.construct_smooth_gradient_for_image(data: ndarray) ndarray[source]

Construct a smooth gradient for the image :param data: np.ndarray :return: np.ndarray

mirar.processors.flat.default_select_flat(images: ImageBatch) ImageBatch[source]

Select images tagged as flat

Parameters:

images – set of images

Returns:

subset of flat images

mirar.processors.flat.get_convolution(data: ndarray, kernel_width: int) ndarray[source]

Convolve data with a tophat kernel

Parameters:
  • data – Image data

  • kernel_width – Width of the kernel (pixels)

Returns:

Smoothed image

mirar.processors.flat.get_outlier_pixel_mask(img: ndarray, thresh: float = 3.0) ndarray[source]

Get oulier pixels that are above or below a threshold :param img: np.ndarray :param thresh: float

mirar.processors.flat.get_smoothened_outlier_pixel_mask_from_list(img_data_list: list[ndarray], threshold: float = 3.0) ndarray[source]

Take a list of images and return a mask of outlier pixels after removing a smooth gradient from them :param img_data_list: list[np.ndarray] :param threshold: float :return: np.ndarray

mirar.processors.flat.smooth_and_normalize_image(data: ndarray) ndarray[source]

Smooth and normalize the image :param data: np.ndarray :return: np.ndarray

mirar.processors.mask module

Module containing processors which mask pixels

class mirar.processors.mask.BaseMask(write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseImageProcessor, ABC

Base class for masking processors

get_mask(image) ndarray[bool][source]

Function to get the mask for a given image

class mirar.processors.mask.MaskAboveThreshold(threshold: float = None, threshold_key: str = None, write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to mask pixels above a threshold

base_key = 'maskthresh'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image) ndarray[source]

Returns a mask for pixels above a threshold

Returns:

mask

class mirar.processors.mask.MaskDatasecPixels(write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to mask the data section of an image

base_key = 'maskdatasec'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image: Image) ndarray[source]

Function to mask the data section of an image

class mirar.processors.mask.MaskPixelsFromFunction(mask_function: Callable[[Image], ndarray], write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to apply a mask to images using a function

base_key = 'maskfromfunction'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image) ndarray[source]

Function to get the mask for a given image

class mirar.processors.mask.MaskPixelsFromPath(mask_path: str | Path = None, mask_path_key: str = None, write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to apply a mask to images using another `mask image’. Following the general mirar convention, every zero pixel in the mask image will be masked in the science image.

base_key = 'maskfrompath'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image) ndarray[source]

loads mask if needed, and returns it

Returns:

mask

class mirar.processors.mask.MaskPixelsFromPathInverted(mask_path: str | Path = None, mask_path_key: str = None, write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: MaskPixelsFromPath

Processor to apply a mask to images using another `mask image’. In contrast to the general mirar convention, every non-zero pixel in the mask image will be masked in the science image.

base_key = 'maskfrompathinverted'
get_mask(image) ndarray[source]

Mask pixels which are non-zero in the mask file. This is the inverse of MaskPixelsFromPath, which masks pixels which are zero in the mask file.

Parameters:

image – image to mask

Returns:

Boolean mask

class mirar.processors.mask.MaskPixelsFromWCS(mask_pixels_ra: float | list[float] = None, mask_pixels_dec: float | list[float] = None, mask_file_key: str = 'MASKFITS', write_masked_pixels_to_file: bool = False, output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to mask pixels from a file where WCS coordinates of masked pixels are given

base_key = 'maskwcs'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image) ndarray[source]

loads mask if needed, and returns it

Returns:

mask

class mirar.processors.mask.WriteMaskedCoordsToFile(output_dir: str | Path = 'mask', only_write_mask: bool = False)[source]

Bases: BaseMask

Processor to write masked coordinates to a file

base_key = 'writemaskedcoords'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_mask(image) ndarray[source]

Function to get the mask for a given image

mirar.processors.reference module

This module contains the ProcessReference class, which is used to generate reference images.

class mirar.processors.reference.GetReferenceImage(ref_image_generator: Callable[[...], BaseReferenceGenerator], output_sub_dir: str = 'ref')[source]

Bases: BaseImageProcessor

Processor to get reference images and save them to a directory

base_key = 'refimg_returner'
description()[source]

Return a description of the processor

Returns:

A description of the processor

class mirar.processors.reference.ProcessReference(ref_image_generator: Callable[[...], BaseReferenceGenerator], swarp_resampler: Callable[[...], Swarp], sextractor: Callable[[...], Sextractor], ref_psfex: Callable[[...], PSFex], phot_sextractor: Callable[[...], Sextractor] = None, temp_output_subtract_dir: str = 'subtract')[source]

Bases: BaseImageProcessor

Processor to process reference images.

base_key = 'REFPREP'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

static get_image_header_params(image: Image)[source]

Get the header parameters from the image.

get_sub_output_dir() Path[source]

Get the output directory for the subtracted images.

max_n_cpu: int = 15

mirar.processors.sky module

Module for sky subtraction

class mirar.processors.sky.MasterSkyCalibrator(master_image_path_generator: Callable[[ImageBatch], Path], *args, **kwargs)[source]

Bases: ProcessorPremadeCache, NightSkyMedianCalibrator

Processor to subtract a master sky image

class mirar.processors.sky.NightSkyMedianCalibrator(*args, flat_mask_key=None, **kwargs)[source]

Bases: SkyFlatCalibrator

Processor for sky subtraction

base_key = 'sky'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

mirar.processors.split module

Module for splitting images into sub-images

exception mirar.processors.split.ImageSplittingError[source]

Bases: ProcessorError

Error raised when there is an issue with splitting images

class mirar.processors.split.SplitImage(buffer_pixels: int = 0, n_x: int = 1, n_y: int = 1)[source]

Bases: BaseImageProcessor

Processor for splitting images

base_key = 'split'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_range(n_chunks: int, pixel_width: int, i: int) tuple[int, int][source]

Function to return pixel index range for sub images

Parameters:
  • n_chunks – number of chunks to divide axis into

  • pixel_width – total pixel width of axis

  • i – index of chunk to evaluate

Returns:

lower pixel index and upper pixel index of chunk

update_dataset(dataset: Dataset) Dataset[source]

Update a dataset after processing

Parameters:

dataset – Initial dataset

Returns:

Updated dataset

class mirar.processors.split.SwarpImageSplitter(swarp_config_path: str, output_sub_dir: str = 'swarp_split', buffer_pixels: int = 0, n_x: int = 1, n_y: int = 1)[source]

Bases: SplitImage

Processor for splitting images using Swarp

mirar.processors.xmatch module

Module to cross-match a candidate_table with different catalogs

class mirar.processors.xmatch.XMatch(catalog: BaseXMatchCatalog)[source]

Bases: BaseSourceProcessor

Class to cross-match a candidate_table to a catalog

base_key = 'XMATCH'
description()[source]

Return a description of the processor

Returns:

A description of the processor

max_n_cpu: int = 4