flint.leakage ============= .. py:module:: flint.leakage .. autoapi-nested-parse:: Construct a leakge map between two polarisations, typically V/I Attributes ---------- .. autoapisummary:: flint.leakage.TableOrPath Classes ------- .. autoapisummary:: flint.leakage.FITSImage flint.leakage.LeakageFilters flint.leakage.PixelCoords flint.leakage.PolStatistics Functions --------- .. autoapisummary:: flint.leakage._get_output_catalogue_path flint.leakage._load_component_table flint.leakage._load_fits_image flint.leakage.cli flint.leakage.create_leakge_component_table flint.leakage.extract_pol_stats_in_box flint.leakage.filter_components flint.leakage.get_parser flint.leakage.get_xy_pixel_coords flint.leakage.load_and_filter_components Module Contents --------------- .. py:class:: FITSImage Bases: :py:obj:`NamedTuple` Container to couple FITS header, image and WCS .. py:attribute:: data :type: numpy.ndarray The data of the fits image .. py:attribute:: header :type: dict Header of the fits image .. py:attribute:: path :type: pathlib.Path Path of the loaded FITS image on disk .. py:attribute:: wcs :type: astropy.wcs.WCS Celestial WCS of the fits image .. py:class:: LeakageFilters Bases: :py:obj:`NamedTuple` Description of the filtering options to apply to components when characterising leakage .. py:attribute:: isolation_radius_deg :type: float :value: 0.0155 The minimum distance to the nearest component .. py:attribute:: lower_int_peak_ratio :type: float :value: 0.8 The lower limit on acceptable int/peak ratios .. py:attribute:: mean_box_size :type: int :value: 10 The size of abox to compute a local mean measure over .. py:attribute:: noise_box_size :type: int :value: 30 the size of a box to compute a local RMS noise measure from .. py:attribute:: search_box_size :type: int :value: 1 The size of a box to search for peak polarised signal in .. py:attribute:: source_snr :type: float :value: 40 Minimum stokes-I signal-to-noise ratio .. py:attribute:: upper_int_peak_ratio :type: float :value: 1.2 The upper limit on acceptable int/peak ratios .. py:class:: PixelCoords Bases: :py:obj:`NamedTuple` Slim container to help collect and maintain pixel coordinates. Not intended for extensive use .. py:attribute:: x :type: numpy.ndarray The x-coordinate of a set of pixels .. py:attribute:: y :type: numpy.ndarray The y-coordinate of a set of pixels .. py:class:: PolStatistics Bases: :py:obj:`NamedTuple` Simple container for statistics around the extraction of leakage polarisation statistics .. py:attribute:: mean :type: numpy.ndarray The mean of pixels within a box .. py:attribute:: noise :type: numpy.ndarray The standard deviation of pixels within a box .. py:attribute:: peak :type: numpy.ndarray The peak pixel value .. py:function:: _get_output_catalogue_path(input_path: pathlib.Path, pol: str, output_path: pathlib.Path | None = None) -> pathlib.Path Create the output leakage catalogue name .. py:function:: _load_component_table(catalogue: TableOrPath) -> astropy.table.Table Return a table given either a loaded table or a path to a table on disk .. py:function:: _load_fits_image(fits_path: pathlib.Path) -> FITSImage Load in a FITS image and package the components into a consistent form. Not intended for extensive use. :param fits_path: The path of the FITS image to examining :type fits_path: Path :returns: Loaded FITS properties :rtype: FITSImage .. py:function:: cli() -> None .. py:function:: create_leakge_component_table(pol_image: pathlib.Path, catalogue: astropy.table.Table | pathlib.Path, pol: str = 'v', output_path: pathlib.Path | None = None) -> pathlib.Path Create a component catalogue that includes enough information to describe the polarisation fraction of sources across a field. This is intended to be used for leakage characterisation. New catalogue columns will be added: * pol_fraction: The POL/I fraction. The peak flux is taken from the catalogue, using the appropriate column name * pol_peak: The peak polarised signal in the nearby region of a component position * pol_noise: The noise in the polarised image pixels around the component position :param pol_image: The polarised image that will be used to extract peak polarised flux from :type pol_image: Path :param catalogue: Component table describing positions to extract flux from :type catalogue: Union[Table, Path] :param pol: The polarisation stokes being considered. Defaults to "v". :type pol: str, optional :param output_path: The path of the new catalogue. If `None` it is derived from the input `catalogue` path. Defaults to None. :type output_path: Optional[Path], optional :returns: Path to the new catalogue use for leakage :rtype: Path .. py:function:: extract_pol_stats_in_box(pol_image: numpy.ndarray, pixel_coords: PixelCoords, search_box_size: int, noise_box_size: int, mean_box_size: int) -> PolStatistics Construct two boxes around nominated pixel coordinates to: * extract the peak signal within * calculate a local RMS value for :param pol_image: The loaded polarised image :type pol_image: np.ndarray :param pixel_coords: Collection of pixel positioncs to evaluate the peak polarisation and noise at :type pixel_coords: PixelCoords :param search_box_size: Size of box to extract the maximum polarised signal from :type search_box_size: int :param noise_box_size: Size of box to calculate the RMS over :type noise_box_size: int :param mean_box_size: Size of box to calculate an mean over :type mean_box_size: int :returns: Extracted statistics, including peak polarised signal, noise and mean :rtype: PolStatistics .. py:function:: filter_components(table: astropy.table.Table, peak_col: str, int_col: str, int_err_col: str, leakage_filters: LeakageFilters, ra_col: str | None = None, dec_col: str | None = None) -> astropy.table.Table Apply the pre-processing operations to catalogue components to select an optimal sample of sources for leakage characterisation. Sources will be selected based on: * how isolated they are * compactness, as traced by their int/peak :param table: Collection of sources, as produced from a source finder :type table: Table :param peak_col: The column name describing the peak flux density :type peak_col: str :param int_col: The column name describing integrated flux :type int_col: str :param int_err_col: The column container errors that correspond to `int_col` to use when computing signal-to-noise :type int_err_col: str :param leakage_filters: Criteria applied to the source components in the table :type leakage_filters: LeakageFilters :param ra_col: The RA column name. If None, it will be guessed. Defaults to None. :type ra_col: Optional[str], optional :param dec_col: The Dec column name. If None, it will be guessed. Defaults to None. :type dec_col: Optional[str], optional :returns: A filtered table :rtype: Table .. py:function:: get_parser() -> argparse.ArgumentParser .. py:function:: get_xy_pixel_coords(table: astropy.table.Table, wcs: astropy.wcs.WCS, ra_col: str | None = None, dec_col: str | None = None) -> PixelCoords Convert (RA, Dec) positions in a catalogue into (x, y)-pixels given an WCS :param table: The table containing sources to collect (x, y)-coordinates :type table: Table :param wcs: The WCS description to use to resolve (RA, Dec) to (x, y) :type wcs: WCS :param ra_col: The RA column name. If None, it will be guessed. Defaults to None. :type ra_col: Optional[str], optional :param dec_col: The Dec column name. If None, it will be guessed. Defaults to None. :type dec_col: Optional[str], optional :returns: _description_ :rtype: PixelCoords .. py:function:: load_and_filter_components(catalogue: TableOrPath, leakage_filters: LeakageFilters) -> astropy.table.Table Load in a component catalogue table and apply filters to them. The remaining components will be used to characterise leakage :param catalogue: The path to a component catalogue, or a loaded component catalogue :type catalogue: TableOrPath :param leakage_filters: Filtering options to find ideal components for leakage characterisation :type leakage_filters: LeakageFilters :returns: Filtered component catalogue :rtype: Table .. py:data:: TableOrPath