当前位置: 首页>>代码示例>>Python>>正文


Python units.pixel方法代码示例

本文整理汇总了Python中astropy.units.pixel方法的典型用法代码示例。如果您正苦于以下问题:Python units.pixel方法的具体用法?Python units.pixel怎么用?Python units.pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astropy.units的用法示例。


在下文中一共展示了units.pixel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_header

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def get_header(self, ext=0):
        """Returns the metadata embedded in the file.

        Target Pixel Files contain embedded metadata headers spread across three
        different FITS extensions:

        1. The "PRIMARY" extension (``ext=0``) provides a metadata header
           providing details on the target and its CCD position.
        2. The "PIXELS" extension (``ext=1``) provides details on the
           data column and their coordinate system (WCS).
        3. The "APERTURE" extension (``ext=2``) provides details on the
           aperture pixel mask and the expected coordinate system (WCS).

        Parameters
        ----------
        ext : int or str
            FITS extension name or number.

        Returns
        -------
        header : `~astropy.io.fits.header.Header`
            Header object containing metadata keywords.
        """
        return self.hdu[ext].header 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:26,代码来源:targetpixelfile.py

示例2: to_original_position

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def to_original_position(self, cutout_position):
        """
        Convert an ``(x, y)`` position in the cutout array to the original
        ``(x, y)`` position in the original large array.

        Parameters
        ----------
        cutout_position : tuple
            The ``(x, y)`` pixel position in the cutout array.

        Returns
        -------
        original_position : tuple
            The corresponding ``(x, y)`` pixel position in the original
            large array.
        """
        return tuple(cutout_position[i] + self.origin_original[i]
                     for i in [0, 1]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:utils.py

示例3: to_cutout_position

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def to_cutout_position(self, original_position):
        """
        Convert an ``(x, y)`` position in the original large array to
        the ``(x, y)`` position in the cutout array.

        Parameters
        ----------
        original_position : tuple
            The ``(x, y)`` pixel position in the original large array.

        Returns
        -------
        cutout_position : tuple
            The corresponding ``(x, y)`` pixel position in the cutout
            array.
        """
        return tuple(original_position[i] - self.origin_original[i]
                     for i in [0, 1]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:utils.py

示例4: test_cutout

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def test_cutout(self):
        sizes = [3, 3*u.pixel, (3, 3), (3*u.pixel, 3*u.pix), (3., 3*u.pixel),
                 (2.9, 3.3)]
        for size in sizes:
            position = (2.1, 1.9)
            c = Cutout2D(self.data, position, size)
            assert c.data.shape == (3, 3)
            assert c.data[1, 1] == 10
            assert c.origin_original == (1, 1)
            assert c.origin_cutout == (0, 0)
            assert c.input_position_original == position
            assert_allclose(c.input_position_cutout, (1.1, 0.9))
            assert c.position_original == (2., 2.)
            assert c.position_cutout == (1., 1.)
            assert c.center_original == (2., 2.)
            assert c.center_cutout == (1., 1.)
            assert c.bbox_original == ((1, 3), (1, 3))
            assert c.bbox_cutout == ((0, 2), (0, 2))
            assert c.slices_original == (slice(1, 4), slice(1, 4))
            assert c.slices_cutout == (slice(0, 3), slice(0, 3)) 
开发者ID:holzschu,项目名称:Carnets,代码行数:22,代码来源:test_utils.py

示例5: hdu

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def hdu(self, value, keys=('FLUX', 'QUALITY')):
        """Verify the file format when setting the value of `self.hdu`.

        Raises a ValueError if `value` does not appear to be a Target Pixel File.
        """
        for key in keys:
            if ~(np.any([value[1].header[ttype] == key
                         for ttype in value[1].header['TTYPE*']])):
                raise ValueError("File {} does not have a {} column, "
                                 "is this a target pixel file?".format(self.path, key))
        self._hdu = value 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:13,代码来源:targetpixelfile.py

示例6: column

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def column(self):
        """CCD pixel column number ('1CRV5P' header keyword)."""
        return self.get_keyword('1CRV5P', hdu=1, default=0) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:5,代码来源:targetpixelfile.py

示例7: row

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def row(self):
        """CCD pixel row number ('2CRV5P' header keyword)."""
        return self.get_keyword('2CRV5P', hdu=1, default=0) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:5,代码来源:targetpixelfile.py

示例8: wcs

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def wcs(self) -> WCS:
        """Returns an `astropy.wcs.WCS` object with the World Coordinate System
        solution for the target pixel file.

        Returns
        -------
        w : `astropy.wcs.WCS` object
            WCS solution
        """
        if 'MAST' in self.hdu[0].header['ORIGIN']:  # Is it a TessCut TPF?
            # TPF's generated using the TESSCut service in early 2019 only appear
            # to contain a valid WCS in the second extension (the aperture
            # extension), so we treat such files as a special case.
            return WCS(self.hdu[2])
        else:
            # For standard (Ames-pipeline-produced) TPF files, we use the WCS
            # keywords provided in the first extension (the data table extension).
            # Specifically, we use the WCS keywords for the 5th data column (FLUX).
            wcs_keywords = {'1CTYP5': 'CTYPE1',
                            '2CTYP5': 'CTYPE2',
                            '1CRPX5': 'CRPIX1',
                            '2CRPX5': 'CRPIX2',
                            '1CRVL5': 'CRVAL1',
                            '2CRVL5': 'CRVAL2',
                            '1CUNI5': 'CUNIT1',
                            '2CUNI5': 'CUNIT2',
                            '1CDLT5': 'CDELT1',
                            '2CDLT5': 'CDELT2',
                            '11PC5': 'PC1_1',
                            '12PC5': 'PC1_2',
                            '21PC5': 'PC2_1',
                            '22PC5': 'PC2_2',
                            'NAXIS1': 'NAXIS1',
                            'NAXIS2': 'NAXIS2'}
            mywcs = {}
            for oldkey, newkey in wcs_keywords.items():
                if (self.hdu[1].header[oldkey] != Undefined):
                   mywcs[newkey] = self.hdu[1].header[oldkey]
            return WCS(mywcs) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:41,代码来源:targetpixelfile.py

示例9: to_lightcurve

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def to_lightcurve(self, method='aperture', **kwargs):
        """Performs photometry on the pixel data and returns a LightCurve object.

        See the docstring of `aperture_photometry()` for valid
        arguments if the method is 'aperture'.  Otherwise, see the docstring
        of `prf_photometry()` for valid arguments if the method is 'prf'.

        Parameters
        ----------
        method : 'aperture' or 'prf'.
            Photometry method to use.
        **kwargs : dict
            Extra arguments to be passed to the `aperture_photometry` or the
            `prf_photometry` method of this class.

        Returns
        -------
        lc : LightCurve object
            Object containing the resulting lightcurve.
        """
        if method == 'aperture':
            return self.extract_aperture_photometry(**kwargs)
        elif method == 'prf':
            return self.prf_lightcurve(**kwargs)
        else:
            raise ValueError("Photometry method must be 'aperture' or 'prf'.") 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:28,代码来源:targetpixelfile.py

示例10: _estimate_centroids_via_moments

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def _estimate_centroids_via_moments(self, aperture_mask):
        """Compute the "center of mass" of the light based on the 2D moments;
        this is a helper method for `estimate_centroids()`."""
        aperture_mask = self._parse_aperture_mask(aperture_mask)
        yy, xx = np.indices(self.shape[1:]) + 0.5
        yy = self.row + yy
        xx = self.column + xx
        total_flux = np.nansum(self.flux[:, aperture_mask], axis=1)
        with warnings.catch_warnings():
            # RuntimeWarnings may occur below if total_flux contains zeros
            warnings.simplefilter("ignore", RuntimeWarning)
            col_centr = np.nansum(xx * aperture_mask * self.flux, axis=(1, 2)) / total_flux
            row_centr = np.nansum(yy * aperture_mask * self.flux, axis=(1, 2)) / total_flux
        return col_centr*u.pixel, row_centr*u.pixel 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:16,代码来源:targetpixelfile.py

示例11: extract_prf_photometry

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def extract_prf_photometry(self, cadences=None, parallel=True, **kwargs):
        """Returns the results of PRF photometry applied to the pixel file.

        Parameters
        ----------
        cadences : list of int
            Cadences to fit.  If `None` (default) then all cadences will be fit.
        parallel : bool
            If `True`, fitting cadences will be distributed across multiple
            cores using Python's `multiprocessing` module.
        **kwargs : dict
            Keywords to be passed to `tpf.get_model()` to create the
            `TPFModel` object that will be fit.

        Returns
        -------
        results : PRFPhotometry object
            Object that provides access to PRF-fitting photometry results and
            various diagnostics.
        """
        from .prf import PRFPhotometry
        log.warning('Warning: PRF-fitting photometry is experimental '
                    'in this version of lightkurve.')
        prfphot = PRFPhotometry(model=self.get_model(**kwargs))
        prfphot.run(self.flux + self.flux_bkg, cadences=cadences, parallel=parallel,
                    pos_corr1=self.pos_corr1, pos_corr2=self.pos_corr2)
        return prfphot 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:29,代码来源:targetpixelfile.py

示例12: extract_aperture_photometry

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def extract_aperture_photometry(self, aperture_mask='pipeline', centroid_method='moments'):
        """Returns a LightCurve obtained using aperture photometry.

        Parameters
        ----------
        aperture_mask : array-like, 'pipeline', 'threshold' or 'all'
            A boolean array describing the aperture such that `True` means
            that the pixel will be used.
            If None or 'all' are passed, all pixels will be used.
            If 'pipeline' is passed, the mask suggested by the official pipeline
            will be returned.
            If 'threshold' is passed, all pixels brighter than 3-sigma above
            the median flux will be used.
            The default behaviour is to use the TESS pipeline mask.
        centroid_method : str, 'moments' or 'quadratic'
            For the details on this arguments, please refer to the documentation
            for `TargetPixelFile.estimate_centroids`.

        Returns
        -------
        lc : TessLightCurve object
            Contains the summed flux within the aperture for each cadence.
        """
        flux, flux_err, centroid_col, centroid_row = \
            self._aperture_photometry(aperture_mask=aperture_mask,
                                      centroid_method=centroid_method)
        keys = {'centroid_col': centroid_col,
                'centroid_row': centroid_row,
                'quality': self.quality,
                'sector': self.sector,
                'camera': self.camera,
                'ccd': self.ccd,
                'cadenceno': self.cadenceno,
                'ra': self.ra,
                'dec': self.dec,
                'label': self.get_keyword('OBJECT'),
                'targetid': self.targetid}
        return TessLightCurve(time=self.time,
                              flux=flux,
                              flux_err=flux_err,
                              **keys) 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:43,代码来源:targetpixelfile.py

示例13: test_get_cube_units

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def test_get_cube_units(self, galaxy):
        model_cube = ModelCube(filename=galaxy.modelpath)
        unit = '1E-17 erg/s/cm^2/ang/spaxel'
        fileunit = model_cube.data['EMLINE'].header['BUNIT']
        assert unit == fileunit

        unit = fileunit.replace('ang', 'angstrom').split('/spaxel')[0]
        spaxel = u.Unit('spaxel', represents=u.pixel,
                        doc='A spectral pixel', parse_strict='silent')
        newunit = (u.Unit(unit) / spaxel)
        #unit = '1e-17 erg / (Angstrom cm2 s spaxel)'
        dmunit = model_cube.emline_fit.unit
        assert newunit == dmunit 
开发者ID:sdss,项目名称:marvin,代码行数:15,代码来源:test_modelcube.py

示例14: subpixel_indices

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def subpixel_indices(position, subsampling):
    """
    Convert decimal points to indices, given a subsampling factor.

    This discards the integer part of the position and uses only the decimal
    place, and converts this to a subpixel position depending on the
    subsampling specified. The center of a pixel corresponds to an integer
    position.

    Parameters
    ----------
    position : `~numpy.ndarray` or array_like
        Positions in pixels.
    subsampling : int
        Subsampling factor per pixel.

    Returns
    -------
    indices : `~numpy.ndarray`
        The integer subpixel indices corresponding to the input positions.

    Examples
    --------

    If no subsampling is used, then the subpixel indices returned are always 0:

    >>> from astropy.nddata.utils import subpixel_indices
    >>> subpixel_indices([1.2, 3.4, 5.6], 1)  # doctest: +FLOAT_CMP
    array([0., 0., 0.])

    If instead we use a subsampling of 2, we see that for the two first values
    (1.1 and 3.4) the subpixel position is 1, while for 5.6 it is 0. This is
    because the values of 1, 3, and 6 lie in the center of pixels, and 1.1 and
    3.4 lie in the left part of the pixels and 5.6 lies in the right part.

    >>> subpixel_indices([1.2, 3.4, 5.5], 2)  # doctest: +FLOAT_CMP
    array([1., 1., 0.])
    """
    # Get decimal points
    fractions = np.modf(np.asanyarray(position) + 0.5)[0]
    return np.floor(fractions * subsampling) 
开发者ID:holzschu,项目名称:Carnets,代码行数:43,代码来源:utils.py

示例15: _calc_bbox

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import pixel [as 别名]
def _calc_bbox(slices):
        """
        Calculate a minimal bounding box in the form ``((ymin, ymax),
        (xmin, xmax))``.  Note these are pixel locations, not slice
        indices.  For ``mode='partial'``, the bounding box indices are
        for the valid (non-filled) cutout values.
        """
        # (stop - 1) to return the max pixel location, not the slice index
        return ((slices[0].start, slices[0].stop - 1),
                (slices[1].start, slices[1].stop - 1)) 
开发者ID:holzschu,项目名称:Carnets,代码行数:12,代码来源:utils.py


注:本文中的astropy.units.pixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。