Fiducial#

class radiotools.fiducial.Fiducial(fits_path: str)[source]#

Bases: object

Methods Summary

get_hdu()

Get the Primary Header Data Unit (HDU) of the FITS file.

get_header([hdu])

Get the FITS Header of the fiducial image.

get_image([ra_incr_right, flux_unit, ...])

Get the image data of the fiducial image.

get_maximum_info([unit, hdu])

get_metadata([hdu])

Get the metadata of the fiducial image.

plot([display_beam, ra_incr_right, ax_unit, ...])

Plots the uncleaned model

preprocess(clean[, remove_negatives, crop, ...])

Preprocesses the fiducial image by cropping and cleaning it.

Methods Documentation

get_hdu()[source]#

Get the Primary Header Data Unit (HDU) of the FITS file.

Returns:
astropy.io.fits.PrimaryHDU

The HDU of the FITS file

get_header(hdu: PrimaryHDU | None = None)[source]#

Get the FITS Header of the fiducial image.

Parameters:
hduastropy.io.fits.PrimaryHDU | None, optional

The Primary Header Data Unit of the FITS file. Can be provided to avoid consecutive opening and closing of the file. If set to None, the file will be opened. Default is None.

Returns:
astropy.io.fits.Header

The FITS Header of the fiducial image

get_image(ra_incr_right: bool = True, flux_unit: str | None = None, allow_unit_prefixes: bool = True, hdu: PrimaryHDU | None = None)[source]#

Get the image data of the fiducial image.

Parameters:
ra_incr_rightbool, optional

Determines whether the image should be returned with the Right Ascension (RA) increasing to the right like a normal coordinate axis. Default is True.

flux_unitstr, optional

The flux density unit the image is supposed to have. Valid values are: 'Jy/pix', "Jy/beam" or None. The nominator of the unit ('Jy') may also include prefixes like 'm' for milli etc. if the parameter allow_unit_prefixes is set to True. Otherwise an error will be raised. If set to None, the unit from the FITS file will be used. Default is None.

allow_unit_prefixesbool, optional

Whether the Jansky unit (nominator of the flux_unit) may include unit prefixes. Default is True.

hduastropy.io.fits.PrimaryHDU | None, optional

The Primary Header Data Unit of the FITS file. Can be provided to avoid consecutive opening and closing of the file. If set to None, the file will be opened. Default is None.

Returns:
numpy.ndarray

The image data.

get_maximum_info(unit: str | Unit = 'deg', hdu: PrimaryHDU | None = None)[source]#
get_metadata(hdu: PrimaryHDU | None = None)[source]#

Get the metadata of the fiducial image.

Parameters:
hduastropy.io.fits.PrimaryHDU | None, optional

The Primary Header Data Unit of the FITS file. Can be provided to avoid consecutive opening and closing of the file. If set to None, the file will be opened. Default is None.

Returns:
dict

The metadata of the fiducial image as a dictionary.

plot(display_beam: bool = True, ra_incr_right: bool = True, ax_unit: str | Unit = 'pixel', use_relative_ax: bool = True, flux_unit: str | None = None, display_title: bool = True, norm: str | Normalize | None = None, cmap: str | Colormap | None = 'inferno', plot_args: dict = None, fig_args: dict = None, save_to: str | None = None, save_args: dict = None, fig: Figure | None = None, ax: Axes | None = None)[source]#

Plots the uncleaned model

Parameters:
display_beambool, optional

Whether to display size and orientation of the beam as a white ellipse in the lower left of the image. Default is True.

ra_incr_rightbool, optional

Whether the Right Ascension coordinate (x-axis) should increase to the right. Default is True.

ax_unitstr | astropy.units.Unit, optional

The unit in which to show the ticks of the x and y-axes in. The y-axis is the Declination (DEC) and the x-axis is the Right Ascension (RA). The unit has to be given as a string or an astropy.units.Unit. The string must correspond to the string representation of an astropy.units.Unit.

Valid units are either pixel or angle units like arcsec, degree etc.. Default is pixel.

use_relative_axbool, optional

Whether to display the coordinate relative to the center of the image (not the source position). Default is True.

flux_unitstr | None, optional

The flux density unit the image is supposed to have. Valid values are: 'Jy/pix', "Jy/beam" or None. The nominator of the unit ('Jy') may also include prefixes like 'm' for milli etc.. If set to None, the unit from the FITS file will be used. Default is None.

display_title: bool, optional

Whether to display the name of the source as the title of the plot. Default is True.

norm: str | matplotlib.colors.Normalize | None, optional

The name of the norm or the norm itself. Possible values are:

  • log: Returns a logarithmic norm with clipping on (!), meaning

    values above the maximum will be mapped to the maximum and values below the minimum will be mapped to the minimum, thus avoiding the appearance of a colormaps ‘over’ and ‘under’ colors (e.g. in case of negative values). Depending on the use case this is desirable but in case that it is not, one can set the norm to log_noclip or provide a custom norm.

  • log_noclip: Returns a logarithmic norm with clipping off.

  • centered: Returns a linear norm which centered around zero.

  • sqrt: Returns a power norm with exponent 0.5, meaning the

    square-root of the values.

  • other: A value not declared above will be returned as is,

    meaning that this could be any value which exists in matplotlib itself.

Default is None, meaning no norm will be applied.

cmap: str | matplotlib.colors.Colormap, optional

The colormap to be used for the plot. Default is 'inferno'.

plot_argsdict, optional

The additional arguments passed to the scatter plot. Default is {"color":"royalblue"}.

fig_argsdict, optional

The additional arguments passed to the figure. If a figure object is given in the fig parameter, this value will be discarded. Default is {}.

save_tostr | None, optional

The name of the file to save the plot to. Default is None, meaning the plot won’t be saved.

save_argsdict, optional

The additional arguments passed to the fig.savefig call. Default is {"bbox_inches":"tight"}.

figmatplotlib.figure.Figure | None, optional

A custom figure object. If set to None, the ax parameter also has to be None! Default is None.

axmatplotlib.axes.Axes | None, optional

A custom axes object. If set to None, the fig parameter also has to be None! Default is None.

Returns:
figmatplotlib.figure.Figure

The figure object.

axmatplotlib.axes.Axes

The axes object.

preprocess(clean: bool, remove_negatives: bool = True, crop: tuple[list[float | None]] = ([None, None], [None, None]), rms_cut_args: dict | None = None, dbscan_args: dict | None = None, output_path: str | None = None, flux_unit: str | None = None, fov: float | None = None, source_name: str | None = None, overwrite: bool = False)[source]#

Preprocesses the fiducial image by cropping and cleaning it.

Parameters:
cleanbool

Whether to perform noise cleaning on the image.

remove_negativesbool, optional

Whether to set negative values to zero. If clean=True this value is automatically True. Default is True.

croptuple[list[float | None]], optional

The crop of the image. This has to have the format ([x_left, x_right], [y_left, y_right]), where the left and right values for each axis are the upper and lower limits of the axes which should be shown. The limits have to create a quadratic image.

rms_cut_argsdict, optional

The arguments to pass to the radio_stats.cuts.dbscan_clean.rms_cut method. Default is {'sigma': 2.9}.

dbscan_argsdict, optional

The arguments to pass to the radio_stats.cuts.dyn_range.dbscan_clean method. Default is {'min_brightness': 1e-4}.

output_pathstr | None, optional

The path to save the cleaned model at. If None same directory is used and name is appended a ‘_cleaned’ suffix) Default is None.

flux_unitstr, optional

The flux density unit in which the image should be saved. Available values are 'Jy/beam', 'Jy/pix' or None. The unit may not contain unit prefixes! If set to None, the unit from the original FITS file will be used. Default is None.

fovfloat | None, optional

The field of view of the observation. This can be changed by setting this value to a not-None float. If a crop is performed, the fov will be assumed for the cropped image! If set to None, the fov from the original FITS file will be used. Default is None.

source_namestr | NOne, optional

The name of the observed source. If set to None, the name from the FITS file will be used. Default is None.

overwritebool, optional

Whether to overwrite an existing file. Default is False

Returns:
Fiducial

The processed Fiducial object.