How to use the photutils.utils._wcs_helpers._pixel_to_world function in photutils

To help you get started, we’ve selected a few photutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / photutils / photutils / segmentation / properties.py View on Github external
def sky_centroid(self):
        """
        The sky coordinates of the centroid within the source segment,
        returned as a `~astropy.coordinates.SkyCoord` object.

        The output coordinate frame is the same as the input WCS.
        """

        return _pixel_to_world(self.xcentroid.value, self.ycentroid.value,
                               self._wcs)
github astropy / photutils / photutils / utils / wcs_helpers.py View on Github external
wcs : WCS object
        A world coordinate system (WCS) transformation that supports the
        `astropy shared interface for WCS
        `_ (e.g.
        `astropy.wcs.WCS`, `gwcs.wcs.WCS`).

    Returns
    -------
    ra : `~astropy.units.Quantity`
        The ICRS Right Ascension in degrees.

    dec : `~astropy.units.Quantity`
        The ICRS Declination in degrees.
    """

    icrs_coords = (_pixel_to_world(x, y, wcs)).icrs
    icrs_ra = icrs_coords.ra.degree * u.deg
    icrs_dec = icrs_coords.dec.degree * u.deg

    return icrs_ra, icrs_dec
github astropy / photutils / photutils / segmentation / properties.py View on Github external
if corner == 'll':
        xpos = bbox.ixmin - 0.5
        ypos = bbox.iymin - 0.5
    elif corner == 'ul':
        xpos = bbox.ixmin - 0.5
        ypos = bbox.iymax + 0.5
    elif corner == 'lr':
        xpos = bbox.ixmax + 0.5
        ypos = bbox.iymin - 0.5
    elif corner == 'ur':
        xpos = bbox.ixmax + 0.5
        ypos = bbox.iymax + 0.5
    else:
        raise ValueError('Invalid corner name.')

    return _pixel_to_world(xpos, ypos, wcs)
github astropy / photutils / photutils / segmentation / properties.py View on Github external
def sky_centroid(self):
        if self.wcs is None:
            return self._none_list
        else:
            # For a large catalog, it's much faster to calculate world
            # coordinates using the complete list of (x, y) instead of
            # looping through the individual (x, y).  It's also much
            # faster to recalculate the world coordinates than to create a
            # SkyCoord array from a loop-generated SkyCoord list.  The
            # assumption here is that the wcs is the same for each
            # SourceProperties instance.
            return _pixel_to_world(self.xcentroid, self.ycentroid, self.wcs)
github astropy / photutils / photutils / detection / core.py View on Github external
if centroid_func is not None:
        from ..centroids import centroid_sources  # prevents circular import

        if not callable(centroid_func):
            raise TypeError('centroid_func must be a callable object')

        x_centroids, y_centroids = centroid_sources(
            data, x_peaks, y_peaks, box_size=box_size,
            footprint=footprint, error=error, mask=mask,
            centroid_func=centroid_func)

        table['x_centroid'] = x_centroids
        table['y_centroid'] = y_centroids

    if (centroid_func is not None or subpixel) and wcs is not None:
        skycoord_centroids = _pixel_to_world(x_centroids, y_centroids, wcs)
        idx = table.colnames.index('y_centroid')
        table.add_column(skycoord_centroids, name='skycoord_centroid',
                         index=idx+1)

    return table
github astropy / photutils / photutils / detection / core.py View on Github external
idx = np.argsort(peak_values)[::-1][:npeaks]
        x_peaks = x_peaks[idx]
        y_peaks = y_peaks[idx]
        peak_values = peak_values[idx]

    if nxpeaks == 0:
        warnings.warn('No local peaks were found.', NoDetectionsWarning)
        return None

    # construct the output Table
    colnames = ['x_peak', 'y_peak', 'peak_value']
    coldata = [x_peaks, y_peaks, peak_values]
    table = Table(coldata, names=colnames)

    if wcs is not None:
        skycoord_peaks = _pixel_to_world(x_peaks, y_peaks, wcs)
        table.add_column(skycoord_peaks, name='skycoord_peak', index=2)

    # perform centroiding
    if centroid_func is not None:
        from ..centroids import centroid_sources  # prevents circular import

        if not callable(centroid_func):
            raise TypeError('centroid_func must be a callable object')

        x_centroids, y_centroids = centroid_sources(
            data, x_peaks, y_peaks, box_size=box_size,
            footprint=footprint, error=error, mask=mask,
            centroid_func=centroid_func)

        table['x_centroid'] = x_centroids
        table['y_centroid'] = y_centroids