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


Python units.arcmin方法代码示例

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


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

示例1: nside_to_pixel_resolution

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def nside_to_pixel_resolution(nside):
    """
    Find the resolution of HEALPix pixels given the pixel dimensions of one of
    the 12 'top-level' HEALPix tiles.

    Parameters
    ----------
    nside : int
        The number of pixels on the side of one of the 12 'top-level' HEALPix tiles.

    Returns
    -------
    resolution : :class:`~astropy.units.Quantity`
        The resolution of the HEALPix pixels

    See also
    --------
    pixel_resolution_to_nside
    """
    nside = np.asanyarray(nside, dtype=np.int64)
    _validate_nside(nside)
    return (nside_to_pixel_area(nside) ** 0.5).to(u.arcmin) 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:24,代码来源:core.py

示例2: test_pixel_resolution_to_nside

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_pixel_resolution_to_nside():

    # Check the different rounding options
    nside = pixel_resolution_to_nside(13 * u.arcmin, round='nearest')
    assert nside == 256

    nside = pixel_resolution_to_nside(13 * u.arcmin, round='up')
    assert nside == 512

    nside = pixel_resolution_to_nside(13 * u.arcmin, round='down')
    assert nside == 256

    # Check that it works with arrays
    nside = pixel_resolution_to_nside([1e3, 10, 1e-3] * u.deg, round='nearest')
    assert_equal(nside, [1, 8, 65536])

    with pytest.raises(ValueError) as exc:
        pixel_resolution_to_nside(13 * u.arcmin, round='peaches')
    assert exc.value.args[0] == "Invalid value for round: 'peaches'"

    with pytest.raises(AttributeError) as exc:
        pixel_resolution_to_nside(13)
    assert exc.value.args[0] == "'int' object has no attribute 'to'" 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:25,代码来源:test_core.py

示例3: test_regression_6347

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_regression_6347():
    sc1 = SkyCoord([1, 2]*u.deg, [3, 4]*u.deg)
    sc2 = SkyCoord([1.1, 2.1]*u.deg, [3.1, 4.1]*u.deg)
    sc0 = sc1[:0]

    idx1_10, idx2_10, d2d_10, d3d_10 = sc1.search_around_sky(sc2, 10*u.arcmin)
    idx1_1, idx2_1, d2d_1, d3d_1 = sc1.search_around_sky(sc2, 1*u.arcmin)
    idx1_0, idx2_0, d2d_0, d3d_0 = sc0.search_around_sky(sc2, 10*u.arcmin)

    assert len(d2d_10) == 2

    assert len(d2d_0) == 0
    assert type(d2d_0) is type(d2d_10)

    assert len(d2d_1) == 0
    assert type(d2d_1) is type(d2d_10) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_regression.py

示例4: kpc_proper_per_arcmin

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def kpc_proper_per_arcmin(self, z):
        """ Separation in transverse proper kpc corresponding to an
        arcminute at redshift ``z``.

        Parameters
        ----------
        z : array_like
          Input redshifts.  Must be 1D or scalar.

        Returns
        -------
        d : `~astropy.units.Quantity`
          The distance in proper kpc corresponding to an arcmin at each
          input redshift.
        """
        return (self.angular_diameter_distance(z).to(u.kpc) *
                arcmin_in_radians / u.arcmin) 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:core.py

示例5: test_spacing

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_spacing(self):

        with pytest.raises(TypeError) as exc:
            AngleFormatterLocator(spacing=3.)
        assert exc.value.args[0] == "spacing should be an astropy.units.Quantity instance with units of angle"

        fl = AngleFormatterLocator(spacing=3. * u.degree)
        assert fl.values is None
        assert fl.number is None
        assert fl.spacing == 3. * u.degree

        values, spacing = fl.locator(34.3, 55.4)
        assert_almost_equal(values.to_value(u.degree), [36., 39., 42., 45., 48., 51., 54.])

        fl.spacing = 30. * u.arcmin
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.to_value(u.degree), [34.5, 35., 35.5, 36.])

        with pytest.warns(UserWarning, match=r'Spacing is too small'):
            fl.format = 'dd'
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.to_value(u.degree), [35., 36.]) 
开发者ID:holzschu,项目名称:Carnets,代码行数:24,代码来源:test_formatter_locator.py

示例6: test_values_unit

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_values_unit(self):

        # Make sure that the intrinsic unit and format unit are correctly
        # taken into account when using the locator

        fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.arcsec, decimal=True)
        assert_quantity_allclose(fl.locator(850, 2150)[0],
                                 [1000., 1200., 1400., 1600., 1800., 2000.] * u.arcsec)

        fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.degree, decimal=False)
        assert_quantity_allclose(fl.locator(850, 2150)[0],
                                 [15., 20., 25., 30., 35.] * u.arcmin)

        fl = AngleFormatterLocator(unit=u.arcsec, format_unit=u.hourangle, decimal=False)
        assert_quantity_allclose(fl.locator(850, 2150)[0],
                                 [60., 75., 90., 105., 120., 135.] * (15 * u.arcsec))

        fl = AngleFormatterLocator(unit=u.arcsec)
        fl.format = 'dd:mm:ss'
        assert_quantity_allclose(fl.locator(0.9, 1.1)[0], [1] * u.arcsec)

        fl = AngleFormatterLocator(unit=u.arcsec, spacing=0.2 * u.arcsec)
        assert_quantity_allclose(fl.locator(0.3, 0.9)[0], [0.4, 0.6, 0.8] * u.arcsec) 
开发者ID:holzschu,项目名称:Carnets,代码行数:25,代码来源:test_formatter_locator.py

示例7: test_select_step_degree

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_select_step_degree():
    assert_almost_equal_quantity(select_step_degree(127 * u.deg), 180. * u.deg)
    assert_almost_equal_quantity(select_step_degree(44 * u.deg), 45. * u.deg)
    assert_almost_equal_quantity(select_step_degree(18 * u.arcmin), 15 * u.arcmin)
    assert_almost_equal_quantity(select_step_degree(3.4 * u.arcmin), 3 * u.arcmin)
    assert_almost_equal_quantity(select_step_degree(2 * u.arcmin), 2 * u.arcmin)
    assert_almost_equal_quantity(select_step_degree(59 * u.arcsec), 1 * u.arcmin)
    assert_almost_equal_quantity(select_step_degree(33 * u.arcsec), 30 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(2.2 * u.arcsec), 2 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.8 * u.arcsec), 1 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.2 * u.arcsec), 0.2 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.11 * u.arcsec), 0.1 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.022 * u.arcsec), 0.02 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.0043 * u.arcsec), 0.005 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.00083 * u.arcsec), 0.001 * u.arcsec)
    assert_almost_equal_quantity(select_step_degree(0.000027 * u.arcsec), 0.00002 * u.arcsec) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_utils.py

示例8: test_select_step_hour

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_select_step_hour():
    assert_almost_equal_quantity(select_step_hour(127 * u.deg), 8. * u.hourangle)
    assert_almost_equal_quantity(select_step_hour(44 * u.deg), 3. * u.hourangle)
    assert_almost_equal_quantity(select_step_hour(18 * u.arcmin), 15 * u.arcmin)
    assert_almost_equal_quantity(select_step_hour(3.4 * u.arcmin), 3 * u.arcmin)
    assert_almost_equal_quantity(select_step_hour(2 * u.arcmin), 1.5 * u.arcmin)
    assert_almost_equal_quantity(select_step_hour(59 * u.arcsec), 1 * u.arcmin)
    assert_almost_equal_quantity(select_step_hour(33 * u.arcsec), 30 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(2.2 * u.arcsec), 3. * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.8 * u.arcsec), 0.75 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.2 * u.arcsec), 0.15 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.11 * u.arcsec), 0.15 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.022 * u.arcsec), 0.03 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.0043 * u.arcsec), 0.003 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.00083 * u.arcsec), 0.00075 * u.arcsec)
    assert_almost_equal_quantity(select_step_hour(0.000027 * u.arcsec), 0.00003 * u.arcsec) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_utils.py

示例9: test_radian

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_radian(self, function):
            q1 = function(180. * u.degree, 0. * u.arcmin, 0. * u.arcsec)
            assert_allclose(q1.value, np.pi)
            assert q1.unit == u.radian

            q2 = function(0. * u.degree, 30. * u.arcmin, 0. * u.arcsec)
            assert_allclose(q2.value, (30. * u.arcmin).to(u.radian).value)
            assert q2.unit == u.radian

            q3 = function(0. * u.degree, 0. * u.arcmin, 30. * u.arcsec)
            assert_allclose(q3.value, (30. * u.arcsec).to(u.radian).value)

            # the following doesn't make much sense in terms of the name of the
            # routine, but we check it gives the correct result.
            q4 = function(3. * u.radian, 0. * u.arcmin, 0. * u.arcsec)
            assert_allclose(q4.value, 3.)
            assert q4.unit == u.radian

            with pytest.raises(TypeError):
                function(3. * u.m, 2. * u.s, 1. * u.kg) 
开发者ID:holzschu,项目名称:Carnets,代码行数:22,代码来源:test_quantity_ufuncs.py

示例10: test_dNbackground

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def test_dNbackground(self):
        """
        Test to ensure that dN returned has correct length, units, and is >= 0.
        """
        coords = self.TL.coords
        intDepths = np.random.uniform(15.0, 25.0, len(coords))

        for mod in self.allmods:
            with RedirectStreams(stdout=self.dev_null):
                obj = mod()
            dN = obj.dNbackground(coords, intDepths)

            self.assertTrue(len(dN) == len(intDepths),'dNbackground returns different length than input for %s'%mod.__name__)
            self.assertTrue(dN.unit == 1/u.arcmin**2,'dNbackground does not return 1/arcmin**2 for %s'%mod.__name__)
            self.assertTrue(np.all(dN >= 0.0),'dNbackground returns negative values for %s'%mod.__name__) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:17,代码来源:test_BackgroundSources.py

示例11: dNbackground

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def dNbackground(self, coords, intDepths):
        """Returns background source number densities
        
        Args:
            coords (astropy SkyCoord array):
                SkyCoord object containing right ascension, declination, and 
                distance to star of the planets of interest in units of deg, deg and pc
            intDepths (float ndarray):
                Integration depths equal to the planet magnitude (Vmag+dMag), 
                i.e. the V magnitude of the dark hole to be produced for each target. 
                Must be of same length as coords.
                
        Returns:
            dN (astropy Quantity array):
                Number densities of background sources for given targets in 
                units of 1/arcmin2. Same length as inputs.
        
        """
        
        assert isinstance(intDepths,(tuple,list,np.ndarray)), \
                "intDepths is not array-like."
        if isinstance(coords,SkyCoord):
            assert coords.shape, "coords is not array-like."
        else:
            assert isinstance(coords,(tuple,list,np.ndarray)), \
                    "coords is not array-like."
        assert len(coords) == len(intDepths), "Input size mismatch."
        
        dN = np.zeros(len(intDepths))
        
        return dN/u.arcmin**2 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:33,代码来源:BackgroundSources.py

示例12: nside2resol

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def nside2resol(nside, arcmin=False):
    """Drop-in replacement for healpy `~healpy.pixelfunc.nside2resol`."""
    resolution = nside_to_pixel_resolution(nside)
    if arcmin:
        return resolution.to(u.arcmin).value
    else:
        return resolution.to(u.rad).value 
开发者ID:astropy,项目名称:astropy-healpix,代码行数:9,代码来源:healpy.py

示例13: get_ukidss_catalog

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def get_ukidss_catalog(ra=165., dec=34.8, radius=3, database='UKIDSSDR9PLUS',
                       programme_id='LAS'):
    """Query for objects in the UKIDSS catalogs

    Parameters
    ----------
    ra, dec : float
        Center of the query region, decimal degrees

    radius : float
        Radius of the query, in arcmin

    Returns
    -------
    table : `~astropy.table.Table`
        Result of the query

    """

    from astroquery.ukidss import Ukidss

    coo = coord.SkyCoord(ra*u.deg, dec*u.deg)

    table = Ukidss.query_region(coo, radius=radius*u.arcmin,
                                database=database, programme_id=programme_id)

    return table 
开发者ID:gbrammer,项目名称:grizli,代码行数:29,代码来源:prep.py

示例14: get_sdss_catalog

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def get_sdss_catalog(ra=165.86, dec=34.829694, radius=3):
    """Query for objects in the SDSS photometric catalog

    Parameters
    ----------
    ra, dec : float
        Center of the query region, decimal degrees

    radius : float
        Radius of the query, in arcmin

    Returns
    -------
    table : `~astropy.table.Table`
        Result of the query

    """
    from astroquery.sdss import SDSS

    coo = coord.SkyCoord(ra*u.deg, dec*u.deg)

    fields = ['ra', 'dec', 'raErr', 'decErr', 'petroMag_r', 'petroMagErr_r']
    # print fields
    fields = None

    table = SDSS.query_region(coo, radius=radius*u.arcmin, spectro=False,
                              photoobj_fields=fields)

    return table 
开发者ID:gbrammer,项目名称:grizli,代码行数:31,代码来源:prep.py

示例15: get_irsa_catalog

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import arcmin [as 别名]
def get_irsa_catalog(ra=165.86, dec=34.829694, tab=None, radius=3, catalog='allwise_p3as_psd', wise=False, twomass=False, ROW_LIMIT=500000, TIMEOUT=3600):
    """Query for objects in the `AllWISE <http://wise2.ipac.caltech.edu/docs/release/allwise/>`_ source catalog

    Parameters
    ----------
    ra, dec : float
        Center of the query region, decimal degrees

    radius : float
        Radius of the query, in arcmin

    Returns
    -------
    table : `~astropy.table.Table`
        Result of the query

    """
    from astroquery.irsa import Irsa
    Irsa.ROW_LIMIT = ROW_LIMIT
    Irsa.TIMEOUT = TIMEOUT

    #all_wise = 'wise_allwise_p3as_psd'
    #all_wise = 'allwise_p3as_psd'
    if wise:
        catalog = 'allwise_p3as_psd'
    elif twomass:
        catalog = 'fp_psc'

    coo = coord.SkyCoord(ra*u.deg, dec*u.deg)

    table = Irsa.query_region(coo, catalog=catalog, spatial="Cone",
                              radius=radius*u.arcmin, get_query_payload=False)

    return table 
开发者ID:gbrammer,项目名称:grizli,代码行数:36,代码来源:prep.py


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