API#
- twirl.compute_wcs(pixel_coords: ndarray, radecs: ndarray, tolerance: int = 5, quads_tolerance: float = 0.1, asterism=4, min_match=0.8) WCS#
Compute the WCS solution for an image given pixel coordinates and some unordered RA-DEC values.
- Parameters:
pixel_coords (np.ndarray) – Pixel coordinates of the sources in the image, shape (n, 2)
radecs (np.ndarray) – RA-DEC coordinates of the sources in the image, shape (m, 2)
tolerance (int, optional) – Tolerance for the matching algorithm, by default 5
asterism (int, optional) – Number of sources to use for matching, by default 4
min_match (int, optional) – Minimum number of matches required, by default None
- Returns:
WCS solution for the image if a match can be computed, None otherwise. A match is considered to be computed if at least one source and one target star are located less than tolerance pixels away from each other.
- Return type:
astropy.wcs.WCS
- twirl.gaia_radecs(center: Union[Tuple[float, float], SkyCoord], fov: Union[float, Quantity], limit: int = 10000, circular: bool = True) ndarray#
Query the Gaia archive to retrieve the RA-DEC coordinates of stars within a given field-of-view (FOV) centered on a given sky position.
- Parameters:
center (tuple or astropy.coordinates.SkyCoord) – The sky coordinates of the center of the FOV. If a tuple is given, it should contain the RA and DEC in degrees.
fov (float or astropy.units.Quantity) – The field-of-view of the FOV in degrees. If a float is given, it is assumed to be in degrees.
limit (int, optional) – The maximum number of sources to retrieve from the Gaia archive. By default, it is set to 10000.
circular (bool, optional) – Whether to perform a circular or a rectangular query. By default, it is set to True.
- Returns:
An array of shape (n, 2) containing the RA-DEC coordinates of the retrieved sources in degrees.
- Return type:
np.ndarray
- Raises:
ImportError – If the astroquery package is not installed.
Examples
>>> from astropy.coordinates import SkyCoord >>> from twirl import gaia_radecs >>> center = SkyCoord(ra=10.68458, dec=41.26917, unit='deg') >>> fov = 0.1 >>> radecs = gaia_radecs(center, fov)
- twirl.find_peaks(data: ndarray, threshold: float = 2.0) ndarray#
Find the coordinates of the peaks in a 2D array.
- Parameters:
data (np.ndarray) – The 2D array to search for peaks.
threshold (float, optional) – The threshold (in unit of image standard deviation) above which a pixel is considered part of a peak, i.e. The default is 2.0.
- Returns:
An array of shape (N, 2) containing the (x, y) coordinates of the N peaks found in the input array. The peaks are sorted by decreasing flux.
- Return type:
np.ndarray