Catalog

class Catalog[source]

Catalog class for handling source catalog data.

This class is designed to handle source catalog data from a FITS file. It automatically loads the corresponding target image from the FITS file.

__init__(path, catalog_type='all', info=None, load=True)[source]

Initialize the Catalog instance.

Parameters:
  • path (Union[Path, str]) – Path to the catalog file.

  • catalog_type (str, optional) – Catalog type. Default is β€˜all’. [β€˜all’, β€˜reference’, β€˜valid’, β€˜transient’, β€˜forced’]

  • info (Info, optional) – Info object. Default is None.

  • load (bool, optional) – Whether to load the catalog data. Default is True.

Methods

select_sources(self, x, y, unit='coord', matching_radius=5.0, x_key='X_WORLD', y_key='Y_WORLD')

Select all sources within matching_radius.

show_source(self, ra, dec, radius_arcsec=5.0, downsample=4, zoom_radius_pixel=50, matching_radius_arcsec=3.0, ra_key='X_WORLD', dec_key='Y_WORLD')

Show two-panel view of the target image with a single source marked (red). The left panel shows the full image, and the right panel shows a zoomed-in view of the target position. If a source is matched, it is marked with a blue circle.

Parameters:
  • ra (float) – Right ascension of the target source.

  • dec (float) – Declination of the target source.

  • downsample (int, optional) – Downsampling factor for the image. Default is 4.

  • zoom_radius_pixel (float, optional) – Radius of the zoomed-in view in pixels. Default is 50.

  • matching_radius_arcsec (float, optional) – Matching radius in arcseconds. Default is 3.0.

Returns:

fig – Figure object.

Return type:

matplotlib.figure.Figure

copy(self)

Return a deep copy of this Catalog instance.

Returns:

copied_catalog – A deep copy of the Catalog instance.

Return type:

Catalog

Examples

>>> catalog = Catalog(path='catalog.fits')
>>> copied_catalog = catalog.copy()
>>> copied_catalog.path
'catalog.fits'
write(self, format='ascii', verbose=True)

Write catalog data to the savepath (self.savepath.savepath).

Parameters:

format (str, optional) – Format of the output file. Default is β€˜ascii’.

Return type:

None

Examples

remove(self, remove_main=True, remove_connected_files=True, skip_patterns=[['*.png', '*.cat']], verbose=True)
Return type:

dict

apply_mask(self, target_ivpmask, x_key='X_IMAGE', y_key='Y_IMAGE')

Apply a mask to the catalog.

Parameters:
  • target_ivpmask (Mask) – Mask to apply to the catalog.

  • x_key (str, optional) – Column name for X coordinates. Default is β€˜X_IMAGE’.

  • y_key (str, optional) – Column name for Y coordinates. Default is β€˜Y_IMAGE’.

Returns:

masked_sources – Catalog with sources that are not masked.

Return type:

Table

to_stamp(self, target_img, sort_by='FLUX_AUTO', max_number=50000, x_key='X_WORLD', y_key='Y_WORLD')

Convert X_WORLD and Y_WORLD to pixel coordinates and save to a stamp catalog.

Parameters:
  • target_img (ScienceImage or ReferenceImage) – Target image to convert to pixel coordinates.

  • sort_by (str, optional) – Column name to sort the catalog by. Default is β€˜FLUX_AUTO’.

  • max_number (int, optional) – Maximum number of sources to save. Default is 50000.

Returns:

stamppath – Path to the stamp catalog.

Return type:

str

to_region(self, reg_size=6.0, shape='circle')

Convert X_IMAGE and Y_IMAGE to a region file.

Parameters:
  • reg_size (float, optional) – Size of the region in pixels. Default is 6.0.

  • shape (str, optional) – Shape of the region. Default is β€˜circle’.

Additional Methods

save_info(self, verbose=False)

Save processing info to a JSON file.

Parameters:

verbose (bool, optional) – If True, print the path of the info file. Default is False.

Return type:

None

load_info(self, verbose=False)

Load processing info from a JSON file.

Parameters:

verbose (bool, optional) – If True, print the path of the info file. Default is False.

Returns:

info – Info object loaded from the JSON file.

Return type:

Info

Properties

Key Properties

Property

Description

connected_files

Return all associated files that would be deleted in remove() if remove_connected_files=True,

data

Lazy-load table data from path by trying multiple formats.

is_data_loaded

Check if the data is loaded.

is_exists

Check if the catalog file exists.

is_saved

Check if the catalog has been saved.

nselected

Number of selected sources in the target data.

nsources

Number of sources in the catalog.

savedir

Return the directory where this image and associated files will be saved.

savepath

Dynamically builds save paths based on the path

target_data

Return the selected sources by self.select_sources().