astrohack.image_comparison_tool

Module Contents

Functions

compare_fits_images(image: Union[str, List[str]], reference_image: Union[str, List[str]], telescope_name: str, destination: str, comparison: str = 'direct', zarr_container_name: str = None, plot_resampled: bool = False, plot_percentuals: bool = False, plot_reference: bool = False, plot_original: bool = False, plot_divided_image: bool = False, plot_scatter: bool = True, z_scale_limits: Union[List[float], Tuple, numpy.array] = None, colormap: str = 'viridis', dpi: int = 300, display: bool = False, export_to_fits: bool = False, parallel: bool = False)

Compares a set of images to a set of reference images.

rms_table_from_zarr_datatree(zarr_data_tree: str, table_file: str, rms_unit: str = 'mm', print_table: bool = False)

Goes through the data in a zarr DataTree created by compare_fits_images.

compare_fits_images(image: Union[str, List[str]], reference_image: Union[str, List[str]], telescope_name: str, destination: str, comparison: str = 'direct', zarr_container_name: str = None, plot_resampled: bool = False, plot_percentuals: bool = False, plot_reference: bool = False, plot_original: bool = False, plot_divided_image: bool = False, plot_scatter: bool = True, z_scale_limits: Union[List[float], Tuple, numpy.array] = None, colormap: str = 'viridis', dpi: int = 300, display: bool = False, export_to_fits: bool = False, parallel: bool = False)[source]

Compares a set of images to a set of reference images.

Parameters
  • image (list or str) – FITS image or list of FITS images to be compared.

  • reference_image (list or str) – FITS image or list of FITS images that serve as references.

  • telescope_name (str) – Name of the telescope used. Used for masking.

  • destination (str) – Name of directory onto which save plots

  • comparison (str, optional) – Type of comparison to be made between images, “direct” or “scaled”, default is “direct”.

  • zarr_container_name (str, optional) – Name of the Zarr container to contain the created datatree, default is None, i.e. DataTree is not saved to disk.

  • plot_resampled (bool, optional) – Plot the resampled data array used in the comparison, default is False.

  • plot_reference (bool, optional) – Plot the reference image used in the comparison, default is False.

  • plot_original (bool, optional) – Plot the unresampled image used as input, default is False.

  • plot_percentuals (bool, optional) – Plot the residuals in percent of reference image as well, default is False.

  • plot_divided_image (bool, optional) – Plot the divided image between Image and its reference, default is False.

  • plot_scatter (bool, optional) – Make a scatter plot of the Image against its reference image, default is True.

  • z_scale_limits (list, np.array, tuple, optional) – Z scale for original, resampled, reference and residual images in the image units, default is None (get z scale limits from data)

  • colormap (str, optional) – Colormap to be used on image plots, default is “viridis”.

  • dpi (int, optional) – dots per inch to be used in plots, default is 300.

  • display (bool, optional) – Display plots inline or suppress, defaults to True

  • export_to_fits (bool, optional) – Export created images to FITS files inside destination, default is False.

  • parallel (bool, optional) – If True will use an existing astrohack client to do comparison in parallel, default is False

Returns

DataTree object containing all the comparisons executed

Return type

xr.DataTree

Compares pairs of FITS images pixel by pixel using a mask based on telescope parameters to exclude problematic regions such as shadows caused by the secondary mirror or the arms supporting it. By default, 2 products are produced, a plot of the residuals image, i.e. (Reference - Image) and a scatter plot of the Reference against the Image. If necessary a resample of Image is conducted to allow for pixel by pixel comparison.

Comparison:

Two types of comparison between the images are available:
  • direct: Where the residuals are simply computed as Reference - Image.

  • scaled: Where the residuals are Reference - Factor * Image, with Factor = median(Reference/Image).

Plots:

A plot of the residuals of the comparison is always produced. However, a few extra plots can be produced and their production is controlled by the plot_ parameters, these are:

  • plot_resampled: Activates plotting of the resampled data used in the comparison, default is False as this is just the data on the FITS file resampled to the reference sampling.

  • plot_percentuals: Activates the plotting of the residuals as a perdentage of the Reference Image, default is False as this is just another view on the residuals.

  • plot_reference: Activates the plotting of the reference image used in the comparison, default is False as this is just the data on the reference FITS file.

  • plot_original: Activates the plotting of the unresampled data, default is False as this is just the data on the FITS file

  • plot_divided_image: Activates the plotting of Reference/Image, default is False. This plot is only available when using “scaled” comparison.

  • plot_scatter: Activates the creation of a scatter plot of Reference vs Image, with a linear regression, default is True.

Storage on disk:

By default, this function only produces plots, but this can be changed using two parameters:
  • zarr_container_name: If this parameter is not None a Zarr container will be created on disk with the contents of the produced DataTree.

  • export_to_fits: If set to True will produce FITS files of the produced images and store them at destination.

Return type:

This funtion returns a Xarray DataTree containing the Xarray DataSets that represent Image and Reference. The nodes in this DataTree are labelled according to the filenames given as input for easier navigation.

rms_table_from_zarr_datatree(zarr_data_tree: str, table_file: str, rms_unit: str = 'mm', print_table: bool = False)[source]

Goes through the data in a zarr DataTree created by compare_fits_images.

Parameters
  • zarr_data_tree (str) – Name on disk of the Zarr container holding a compare_fits_image DataTree.

  • table_file (str) – Name of the ASCII file to be created on disk to contain the RMS table

  • rms_unit (str, optional) – Unit for the RMSes in the table, default is ‘mm’.

  • print_table (bool, optional) – Print table on terminal, default is False.

Returns

None

Return type

NoneType