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


Python units.mm方法代码示例

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


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

示例1: test_cam_to_hor

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_cam_to_hor():
    from ctapipe.coordinates import CameraFrame

    # Coordinates in any frame can be given as a numpy array of the xyz positions
    # e.g. in this case the position on pixels in the camera
    pix_x = [1] * u.m
    pix_y = [1] * u.m

    focal_length = 15000 * u.mm

    # first define the camera frame
    pointing = SkyCoord(alt=70 * u.deg, az=0 * u.deg, frame=AltAz())
    camera_frame = CameraFrame(focal_length=focal_length, telescope_pointing=pointing)

    # transform
    camera_coord = SkyCoord(pix_x, pix_y, frame=camera_frame)
    altaz_coord = camera_coord.transform_to(AltAz())

    # transform back
    altaz_coord2 = SkyCoord(az=altaz_coord.az, alt=altaz_coord.alt, frame=AltAz())
    camera_coord2 = altaz_coord2.transform_to(camera_frame)

    # check transform
    assert np.isclose(camera_coord.x.to_value(u.m), camera_coord2.y.to_value(u.m)) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:26,代码来源:test_coordinates.py

示例2: test_all_to_value

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_all_to_value():
    """test all_to_value"""
    x_m = np.arange(5) * u.m
    y_mm = np.arange(5) * 1000 * u.mm
    z_km = np.arange(5) * 1e-3 * u.km
    nono_deg = np.arange(5) * 1000 * u.deg

    # one argument
    x = all_to_value(x_m, unit=u.m)
    assert (x == np.arange(5)).all()

    # two arguments
    x, y = all_to_value(x_m, y_mm, unit=u.m)
    assert (x == np.arange(5)).all()
    assert (y == np.arange(5)).all()

    # three
    x, y, z = all_to_value(x_m, y_mm, z_km, unit=u.m)
    assert (x == np.arange(5)).all()
    assert (y == np.arange(5)).all()
    assert (z == np.arange(5)).all()

    # cannot be converted
    with pytest.raises(u.UnitConversionError):
        all_to_value(x_m, nono_deg, unit=x_m.unit) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:27,代码来源:test_quantities.py

示例3: test_blackbody_array_temperature

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_blackbody_array_temperature():
    """Regression test to make sure that the temperature can be an array."""
    multibb = BlackBody([100, 200, 300] * u.K)
    flux = multibb(1.2 * u.mm)
    np.testing.assert_allclose(
        flux.value, [1.804908e-12, 3.721328e-12, 5.638513e-12], rtol=1e-5
    )

    flux = multibb([2, 4, 6] * u.mm)
    np.testing.assert_allclose(
        flux.value, [6.657915e-13, 3.420677e-13, 2.291897e-13], rtol=1e-5
    )

    multibb = BlackBody(np.ones(4) * u.K)
    flux = multibb(np.ones((3, 4)) * u.mm)
    assert flux.shape == (3, 4) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:test_physical_models.py

示例4: test_ufunc_inplace_non_standard_dtype

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_ufunc_inplace_non_standard_dtype(self):
        """Check that inplace operations check properly for casting.

        First two tests that check that float32 is kept close #3976.
        """
        a1 = u.Quantity([1, 2, 3, 4], u.m, dtype=np.float32)
        a1 *= np.float32(10)
        assert a1.unit is u.m
        assert a1.dtype == np.float32
        a2 = u.Quantity([1, 2, 3, 4], u.m, dtype=np.float32)
        a2 += (20.*u.km)
        assert a2.unit is u.m
        assert a2.dtype == np.float32
        # For integer, in-place only works if no conversion is done.
        a3 = u.Quantity([1, 2, 3, 4], u.m, dtype=np.int32)
        a3 += u.Quantity(10, u.m, dtype=np.int64)
        assert a3.unit is u.m
        assert a3.dtype == np.int32
        a4 = u.Quantity([1, 2, 3, 4], u.m, dtype=np.int32)
        with pytest.raises(TypeError):
            a4 += u.Quantity(10, u.mm, dtype=np.int64) 
开发者ID:holzschu,项目名称:Carnets,代码行数:23,代码来源:test_quantity_ufuncs.py

示例5: test_quantity_equality_error

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_quantity_equality_error():
    """Test equality for different quantity values."""
    param1 = uvp.UVParameter(
        name="p1", value=np.array([0, 1, 3]) * units.m, tols=1 * units.mJy
    )
    param2 = uvp.UVParameter(
        name="p2",
        value=units.Quantity([0 * units.cm, 100 * units.cm, 3000 * units.mm]),
        tols=1 * units.mm,
    )
    with pytest.raises(units.UnitsError):
        assert param1 == param2 
开发者ID:RadioAstronomySoftwareGroup,项目名称:pyuvdata,代码行数:14,代码来源:test_parameter.py

示例6: test_quantity_inequality

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_quantity_inequality(vals, p2_atol):
    param1 = uvp.UVParameter(
        name="p1", value=np.array([0, 1, 3]) * units.m, tols=1 * units.mm
    )
    param2 = uvp.UVParameter(name="p2", value=vals, tols=p2_atol)
    assert param1 != param2 
开发者ID:RadioAstronomySoftwareGroup,项目名称:pyuvdata,代码行数:8,代码来源:test_parameter.py

示例7: rainfall_rate

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def rainfall_rate(lat, lon, p):
    """
    A method to compute the rainfall rate exceeded for p% of the average year


    Parameters
    ----------
    lat : number, sequence, or numpy.ndarray
        Latitudes of the receiver points
    lon : number, sequence, or numpy.ndarray
        Longitudes of the receiver points
    p : number
        Percentage of time exceeded for p% of the average year


    Returns
    -------
    R001: numpy.ndarray
        Rainfall rate exceeded for p% of the average year


    References
    ----------
    [1] Characteristics of precipitation for propagation modelling
    https://www.itu.int/rec/R-REC-P.837/en
    """
    global __model
    type_output = type(lat)
    lat = prepare_input_array(lat)
    lon = prepare_input_array(lon)
    lon = np.mod(lon, 360)
    val = __model.rainfall_rate(lat, lon, p)
    return prepare_output_array(val, type_output) * u.mm / u.hr 
开发者ID:iportillo,项目名称:ITU-Rpy,代码行数:35,代码来源:itu837.py

示例8: unavailability_from_rainfall_rate

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def unavailability_from_rainfall_rate(lat, lon, R):
    """
    A method to estimate the percentage of time of the average year that a
    given rainfall rate (R) is exceeded. This method calls successively to the
    `rainfall_rate` method and interpolates its value.


    Parameters
    ----------
    lat : number, sequence, or numpy.ndarray
        Latitudes of the receiver points
    lon : number, sequence, or numpy.ndarray
        Longitudes of the receiver points
    R : number, sequence, or numpy.ndarray
        Rainfall rate (mm/h)


    Returns
    -------
    p: numpy.ndarray
        Rainfall rate exceeded for p% of the average year


    References
    ----------
    [1] Characteristics of precipitation for propagation modelling
    https://www.itu.int/rec/R-REC-P.837/en
    """
    global __model
    lat = prepare_input_array(lat)
    lon = prepare_input_array(lon)
    lon = np.mod(lon, 360)
    # TODO: write this function 
开发者ID:iportillo,项目名称:ITU-Rpy,代码行数:35,代码来源:itu837.py

示例9: rain_specific_attenuation

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def rain_specific_attenuation(R, f, el, tau):
    """
    A method to compute the specific attenuation γ_R (dB/km) from rain. The
    value is obtained from hte rain rate R (mm/h) using a power law
    relationship.

    ..math:
        \\gamma_R = k R^\\alpha


    Parameters
    ----------
    R : number, sequence, numpy.ndarray or Quantity
        Rain rate (mm/h)
    f : number or Quantity
        Frequency (GHz)
    el : number, sequence, or numpy.ndarray
        Elevation angle of the receiver points
    tau : number, sequence, or numpy.ndarray
        Polarization tilt angle relative to the horizontal (degrees). Tau = 45
        deg for circular polarization)


    Returns
    -------
    gamma_R: numpy.ndarray
        Specific attenuation from rain (dB/km)


    References
    ----------
    [1] Rain height model for prediction methods:
    https://www.itu.int/rec/R-REC-P.838/en
    """
    global __model
    R = prepare_quantity(R, u.mm / u.hr, 'Rain rate')
    f = prepare_quantity(f, u.GHz, 'Frequency')
    return __model.rain_specific_attenuation(R, f, el, tau) * u.dB / u.km 
开发者ID:iportillo,项目名称:ITU-Rpy,代码行数:40,代码来源:itu838.py

示例10: test_diffprop_matches_airydisk

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_diffprop_matches_airydisk(efl, epd, wvl):
    fno = efl / epd

    p = Pupil(dia=epd, xy_unit=u.mm, z_unit=u.nm, wavelength=mkwvl(wvl, u.um))
    psf = PSF.from_pupil(p, efl, Q=3)  # use Q=3 not Q=4 for improved accuracy
    s = psf.slices()
    u_, sx = s.x
    u_, sy = s.y
    analytic = airydisk(u_, fno, wvl)
    assert np.allclose(sx, analytic, atol=PRECISION)
    assert np.allclose(sy, analytic, atol=PRECISION) 
开发者ID:brandondube,项目名称:prysm,代码行数:13,代码来源:test_physics.py

示例11: test_diffprop_matches_analyticmtf

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_diffprop_matches_analyticmtf(efl, epd, wvl):
    fno = efl / epd
    p = Pupil(dia=epd, xy_unit=u.mm, z_unit=u.nm, wavelength=mkwvl(wvl, u.um))
    psf = PSF.from_pupil(p, efl)
    mtf = MTF.from_psf(psf)
    s = mtf.slices()
    u_, x = s.x
    u__, y = s.y

    analytic_1 = diffraction_limited_mtf(fno, wvl, frequencies=u_)
    analytic_2 = diffraction_limited_mtf(fno, wvl, frequencies=u__)
    assert np.allclose(analytic_1, x, atol=PRECISION)
    assert np.allclose(analytic_2, y, atol=PRECISION) 
开发者ID:brandondube,项目名称:prysm,代码行数:15,代码来源:test_physics.py

示例12: synthesize_surface_from_psd

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def synthesize_surface_from_psd(psd, nu_x, nu_y):
    """Synthesize a surface height map from PSD data.

    Parameters
    ----------
    psd : `numpy.ndarray`
        PSD data, units nm²/(cy/mm)²
    nu_x : `numpy.ndarray`
        x spatial frequency, cy/mm
    nu_y : `numpy.ndarray`
        y spatial frequency, cy_mm

    """
    # generate a random phase to be matched to the PSD
    randnums = e.random.rand(*psd.shape)
    randfft = e.fft.fft2(randnums)
    phase = e.angle(randfft)

    # calculate the output window
    # the 0th element of nu_y has the greatest frequency in magnitude because of
    # the convention to put the nyquist sample at -fs instead of +fs for even-size arrays
    fs = -2 * nu_y[0]
    dx = dy = 1 / fs
    ny, nx = psd.shape
    x, y = e.arange(nx) * dx, e.arange(ny) * dy

    # calculate the area of the output window, "S2" in GH_FFT notation
    A = x[-1] * y[-1]

    # use ifft to compute the PSD
    signal = e.exp(1j * phase) * e.sqrt(A * psd)

    coef = 1 / dx / dy
    out = e.fft.ifftshift(e.fft.ifft2(e.fft.fftshift(signal))) * coef
    out = out.real
    return x, y, out 
开发者ID:brandondube,项目名称:prysm,代码行数:38,代码来源:interferogram.py

示例13: latcal

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def latcal(self, plate_scale, unit='mm'):
        """Perform lateral calibration.

        This probably won't do what you want if your data already has spatial
        units of anything but pixels (px).

        Parameters
        ----------
        plate_scale : `float`
            center-to-center sample spacing of pixels, in (unit)s.
        unit : `str`, optional
            unit associated with the plate scale.

        Returns
        -------
        self
            modified `Interferogram` instance.

        """
        self.strip_latcal()
        unit = sanitize_unit(unit, self.wavelength)
        self.xy_unit = unit
        # sloppy to do this here...
        self.x *= plate_scale
        self.y *= plate_scale
        return self 
开发者ID:brandondube,项目名称:prysm,代码行数:28,代码来源:interferogram.py

示例14: render_from_psd

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def render_from_psd(size, samples, rms=None,  # NOQA
                        mask='circle', xyunit='mm', zunit='nm', psd_fcn=abc_psd, **psd_fcn_kwargs):
        """Render a synthetic surface with a given RMS value given a PSD function.

        Parameters
        ----------
        size : `float`
            diameter of the output surface, mm
        samples : `int`
            number of samples across the output surface
        rms : `float`
            desired RMS value of the output, if rms=None, no normalization is done
        mask : `str`, optional
            mask defining the clear aperture
        xyunit : `astropy.unit` or `str`, optional
            astropy unit or string which satisfies hasattr(astropy.units, xyunit)
        zunit : `astropy.unit` or `str`, optional
             astropy unit or string which satisfies hasattr(astropy.units, xyunit)
        psd_fcn : `callable`
            function used to generate the PSD
        **psd_fcn_kwargs:
            keyword arguments passed to psd_fcn in addition to nu
            if psd_fcn == abc_psd, kwargs are a, b, c
            elif psd_Fcn == ab_psd kwargs are a, b

            kwargs will be user-defined for user PSD functions

        Returns
        -------
        `Interferogram`
            new interferogram instance

        """
        x, y, z = render_synthetic_surface(size=size, samples=samples, rms=rms,
                                           mask=mask, psd_fcn=psd_fcn, **psd_fcn_kwargs)
        return Interferogram(phase=z, x=x, y=y, xy_unit=xyunit, z_unit=zunit, wavelength=HeNe) 
开发者ID:brandondube,项目名称:prysm,代码行数:38,代码来源:interferogram.py

示例15: test_barycorr

# 需要导入模块: from astropy import units [as 别名]
# 或者: from astropy.units import mm [as 别名]
def test_barycorr():
    # this is the result of calling _get_barycorr_bvcs
    barycorr_bvcs = u.Quantity([
       -10335.93326096, -14198.47605491, -2237.60012494, -14198.47595363,
       -17425.46512587, -17131.70901174, 2424.37095076, 2130.61519166,
       -17425.46495779, -19872.50026998, -24442.37091097, -11017.08975893,
         6978.0622355, 11547.93333743, -1877.34772637, -19872.50004258,
       -21430.08240017, -27669.14280689, -16917.08506807, 2729.57222968,
        16476.49569232, 13971.97171764, -2898.04250914, -21430.08212368,
       -22028.51337105, -29301.92349394, -21481.13036199, -3147.44828909,
        14959.50065514, 22232.91155425, 14412.11903105, -3921.56359768,
       -22028.51305781, -21641.01479409, -29373.0512649, -24205.90521765,
        -8557.34138828, 10250.50350732, 23417.2299926, 24781.98057941,
        13706.17339044, -4627.70005932, -21641.01445812, -20284.92627505,
       -28193.91696959, -22908.51624166, -6901.82132125, 12336.45758056,
        25804.51614607, 27200.50029664, 15871.21385688, -2882.24738355,
       -20284.9259314, -18020.92947805, -25752.96564978, -20585.81957567,
        -4937.25573801, 13870.58916957, 27037.31568441, 28402.06636994,
        17326.25977035, -1007.62209045, -18020.92914212, -14950.33284575,
       -22223.74260839, -14402.94943965, 3930.73265119, 22037.68163353,
        29311.09265126, 21490.30070307, 3156.62229843, -14950.33253252,
       -11210.53846867, -17449.59867676, -6697.54090389, 12949.11642965,
        26696.03999586, 24191.5164355, 7321.50355488, -11210.53819218,
        -6968.89359681, -11538.76423011, 1886.51695238, 19881.66902396,
        24451.54039956, 11026.26000765, -6968.89336945, -2415.20201758,
        -2121.44599781, 17434.63406085, 17140.87871753, -2415.2018495,
         2246.76923076, 14207.64513054, 2246.76933194, 6808.40787728],
         u.m/u.s)

    # this tries the *other* way of calling radial_velocity_correction relative
    # to the IRAF tests
    targets = _get_test_input_radecs()
    bvcs_astropy = targets.radial_velocity_correction(obstime=test_input_time,
                                                      location=test_input_loc,
                                                      kind='barycentric')

    assert_quantity_allclose(bvcs_astropy, barycorr_bvcs, atol=10*u.mm/u.s)
    return bvcs_astropy, barycorr_bvcs  # for interactively examination 
开发者ID:holzschu,项目名称:Carnets,代码行数:40,代码来源:test_velocity_corrs.py


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