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


Python numpy.rad2deg函数代码示例

本文整理汇总了Python中numpy.rad2deg函数的典型用法代码示例。如果您正苦于以下问题:Python rad2deg函数的具体用法?Python rad2deg怎么用?Python rad2deg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: xyz2eq

def xyz2eq(xin,yin,zin, units='deg'):
    """
    Convert x,y,z on the unit sphere to RA DEC.

    parameters
    ----------
    x,y,z: 
        scalars or arrays as given by eq2xyz
    units: string, optional
        'deg' if the output is to be degrees, 'rad' if it is to be radians.
        Default is degrees.

    Notes:
        This follows the same convention as the STOMP package.
    """

    x = numpy.array(xin, ndmin=1, copy=False)
    y = numpy.array(yin, ndmin=1, copy=False)
    z = numpy.array(zin, ndmin=1, copy=False)

    theta,phi = _xyz2thetaphi(x,y,z)
    theta += _sdsspar['node']

    if units == 'deg':
        numpy.rad2deg(theta,theta)
        numpy.rad2deg(phi,phi)

    atbound(theta, 0.0, 360.0)

    # theta->ra, phi->dec
    return theta,phi
开发者ID:blackdragon2016,项目名称:esutil,代码行数:31,代码来源:coords.py

示例2: load_star_data

    def load_star_data(self, name):
        
#         stetson_df = pandas.read_pickle('stetson.pd')
        files = glob.glob('cam1/*.fits')
        for thisFile in files:
            thisFits = pf.open(thisFile)
            fibreTable = thisFits['FIBRES'].data
            idx = fibreTable.field('NAME').strip()==name
            if fibreTable[idx].shape[0] >0: #if there is any star in this file...
                starInfo = fibreTable[idx][0] 

                self.name = starInfo.field('NAME').strip()
                self.RA = np.rad2deg(starInfo.field('RA'))
                self.Dec = np.rad2deg(starInfo.field('DEC'))        
                self.RA_deg, self.RA_min, self.RA_sec = toolbox.dec2sex(self.RA)   
                self.Dec_deg, self.Dec_min, self.Dec_sec = toolbox.dec2sex(self.Dec)
                self.Vmag = starInfo.field('MAGNITUDE')
            
#                 self.B = stetson_df[stetson_df.target == self.name].B.values[0]
#                 self.I = stetson_df[stetson_df.target == self.name].I.values[0]
#                 self.R = stetson_df[stetson_df.target == self.name].R.values[0]
#                 self.U = stetson_df[stetson_df.target == self.name].U.values[0]
#                 self.V = stetson_df[stetson_df.target == self.name].mag.values[0]
#                 self.BV = stetson_df[stetson_df.target == self.name].BV.values[0]
                print self.name,'star created'
                break
开发者ID:CarlosBacigalupo,项目名称:ipn,代码行数:26,代码来源:create_obj.py

示例3: plot_poses_vels_theta_omega

def plot_poses_vels_theta_omega(pylab, poses, vels):
    thetas = np.array([angle_from_SE2(p) for p in poses])
    omegas = np.array([linear_angular_from_se2(vel)[1] for vel in vels])
    positive = omegas > 0
    negative = np.logical_not(positive)
    pylab.plot(np.rad2deg(thetas)[positive], omegas[positive], 'r.')
    pylab.plot(np.rad2deg(thetas)[negative], omegas[negative], 'b.')
开发者ID:AndreaCensi,项目名称:yc1304,代码行数:7,代码来源:reports.py

示例4: __reverse_lambert

    def __reverse_lambert(self,x,y):

        p     = math.pi
        ln    = np.log
        power = np.power

        sin = np.sin
        cos = np.cos
        tan = np.tan
        cot = lambda x: 1./tan(x)
        sec = lambda x: 1./cos(x)

        ra0  = np.deg2rad(self.center[0])
        dec0 = np.deg2rad(self.center[1])

        dec1 = np.deg2rad(self.ref_dec1)
        dec2 = np.deg2rad(self.ref_dec2)

        n = ln(cos(dec1)*sec(dec2))/ln(tan(p/4+dec2/2)*cot(p/4+dec1/2))
        F = cos(dec1)*power(tan(p/4+dec1/2),n)/n
        rho0 = F*power(cos(p/4+dec0/2)/sin(p/4+dec0/2),n)
        
        rho = np.sign(n)*np.sqrt(x**2+(rho0-y)**2)
        theta = np.arctan(x/(rho0-y))
        dec = 2.*np.arctan(np.power((F/rho),(1./n))) - p/2
        ra = ra0 + theta/n
        return np.rad2deg(ra), np.rad2deg(dec)
开发者ID:wangleon,项目名称:keplermap,代码行数:27,代码来源:keplermap.py

示例5: test_degrees

    def test_degrees(self):

        # the following doesn't make much sense in terms of the name of the
        # routine, but we check it gives the correct result.
        q1 = np.rad2deg(60. * u.degree)
        assert_allclose(q1.value, 60.)
        assert q1.unit == u.degree

        q2 = np.degrees(60. * u.degree)
        assert_allclose(q2.value, 60.)
        assert q2.unit == u.degree

        q3 = np.rad2deg(np.pi * u.radian)
        assert_allclose(q3.value, 180.)
        assert q3.unit == u.degree

        q4 = np.degrees(np.pi * u.radian)
        assert_allclose(q4.value, 180.)
        assert q4.unit == u.degree

        with pytest.raises(TypeError):
            np.rad2deg(3. * u.m)

        with pytest.raises(TypeError):
            np.degrees(3. * u.m)
开发者ID:n0d,项目名称:astropy,代码行数:25,代码来源:test_quantity_ufuncs.py

示例6: __call__

 def __call__(self, phi, theta):
     phi = np.deg2rad(phi)
     theta = np.deg2rad(theta)
     rtheta = self._compute_rtheta(theta)
     x = np.rad2deg(rtheta * np.sin(phi))
     y = - np.rad2deg(rtheta * np.cos(phi))
     return x, y
开发者ID:bluescarni,项目名称:astropy,代码行数:7,代码来源:projections.py

示例7: main

def main():
    if args["<date>"]:
        date = args["<date>"]
        time = args["<timeutc>"]
    else:
        date, time = enter_datetime()

    valid = False
    while not valid:
        try:
            date = datetime.strptime(date + " " + time, "%Y-%m-%d %H:%M")
            valid = True
        except ValueError:
            print("Could not parse date/time, please use the given notation\n")
            date, time = enter_datetime()

    fact = fact_setup(date)
    stars = create_dataframe(fact)
    az, alt, ra, dec = dark_spot_gridsearch(fact, stars, min_altitude, 0.25, 2)
    stars_fov = get_stars_in_fov(az, alt, stars, fact)

    print(u"best ratescan position:")
    print(u"RA: {:1.3f} h".format(np.rad2deg(ra) * 24 / 360))
    print(u"DEC: {:1.3f}°".format(np.rad2deg(dec)))
    print(u"Az: {:1.3f}°".format(np.rad2deg(az)))
    print(u"Alt: {:1.3f}°".format(np.rad2deg(alt)))
    print(u"Brightest star in FOV: {:1.2f} mag".format(stars_fov.vmag.min()))

    if args["--plot"]:
        plot_dark_spot(stars, az, alt, min_altitude)
开发者ID:dneise,项目名称:find_dark_spot,代码行数:30,代码来源:find_dark_spot.py

示例8: get_lonlatalt

def get_lonlatalt(pos, utc_time):
    """Calculate sublon, sublat and altitude of satellite, considering the
    earth an ellipsoid.

    http://celestrak.com/columns/v02n03/
    """
    (pos_x, pos_y, pos_z) = pos / XKMPER
    lon = ((np.arctan2(pos_y * XKMPER, pos_x * XKMPER) - astronomy.gmst(utc_time))
           % (2 * np.pi))

    lon = np.where(lon > np.pi, lon - np.pi * 2, lon)
    lon = np.where(lon <= -np.pi, lon + np.pi * 2, lon)

    r = np.sqrt(pos_x ** 2 + pos_y ** 2)
    lat = np.arctan2(pos_z, r)
    e2 = F * (2 - F)

    while True:
        lat2 = lat
        c = 1 / (np.sqrt(1 - e2 * (np.sin(lat2) ** 2)))
        lat = np.arctan2(pos_z + c * e2 * np.sin(lat2), r)
        if np.all(abs(lat - lat2) < 1e-10):
            break
    alt = r / np.cos(lat) - c
    alt *= A
    return np.rad2deg(lon), np.rad2deg(lat), alt
开发者ID:rottenjonny88,项目名称:pyorbital,代码行数:26,代码来源:geoloc.py

示例9: interpolate_trajectory

 def interpolate_trajectory(self, t, return_degrees=True, **kw):
     lat = self.interpolate_timeseries('latitude', t, **kw)
     lon = self.interpolate_timeseries('longitude', t, **kw)
     dep = self.interpolate_timeseries('depth', t, **kw)
     if return_degrees and self.units('latitude') is 'radian':
         lat, lon = np.rad2deg(lat), np.rad2deg(lon)
     return lon, lat, dep
开发者ID:heavyB,项目名称:okeanidanalysis,代码行数:7,代码来源:logs.py

示例10: evaluate

    def evaluate(cls, x, y, mu, gamma):
        phi = np.arctan2(x / np.cos(gamma), -y)
        r = cls._compute_r_theta(x, y, gamma)
        pho = r / (cls.r0 * (mu + 1) + y * np.sin(gamma))
        psi = np.arctan2(1, pho)
        omega = np.arcsin((pho * mu) / np.sqrt(pho ** 2 + 1))

        theta1 = np.rad2deg(psi - omega)
        theta2 = np.rad2deg(psi + omega) + 180

        if np.abs(mu) < 1:
            if theta1 < 90 and theta1 > -90:
                theta = theta1
            else:
                theta = theta2
        else:
            # theta1dif = 90 - theta1
            # theta2dif = 90 - theta2
            if theta1 < theta2:
                theta = theta1
            else:
                theta = theta2

        phi = np.rad2deg(phi)
        return phi, theta
开发者ID:JaiPEG,项目名称:astropy,代码行数:25,代码来源:projections.py

示例11: getJointLimits

    def getJointLimits(self, input_urdf, use_deg=True):
        import xml.etree.ElementTree as ET
        tree = ET.parse(input_urdf)
        limits = {}
        for j in tree.findall('joint'):
            name = j.attrib['name']
            torque = 0
            lower = 0
            upper = 0
            velocity = 0
            if j.attrib['type'] == 'revolute':
                l = j.find('limit')
                if l != None:
                    torque = l.attrib['effort']   #this is not really the physical limit but controller limit, but well
                    lower = l.attrib['lower']
                    upper = l.attrib['upper']
                    velocity = l.attrib['velocity']

                    limits[name] = {}
                    limits[name]['torque'] = float(torque)
                    if use_deg:
                        limits[name]['lower'] = np.rad2deg(float(lower))
                        limits[name]['upper'] = np.rad2deg(float(upper))
                        limits[name]['velocity'] = np.rad2deg(float(velocity))
                    else:
                        limits[name]['lower'] = float(lower)
                        limits[name]['upper'] = float(upper)
                        limits[name]['velocity'] = float(velocity)
        return limits
开发者ID:kjyv,项目名称:dynamical-system-identification,代码行数:29,代码来源:helpers.py

示例12: compute_fiducial

def compute_fiducial(wcslist, domain=None):
    """
    For a celestial footprint this is the center.
    For a spectral footprint, it is the beginning of the range.

    This function assumes all WCSs have the same output coordinate frame.
    """
    output_frame = getattr(wcslist[0], 'output_frame')
    axes_types = getattr(wcslist[0], output_frame).axes_type
    spatial_axes = np.array(axes_types) == 'SPATIAL'
    spectral_axes = np.array(axes_types) == 'SPECTRAL'
    footprints = np.hstack([w.footprint(domain=domain) for w in wcslist])
    spatial_footprint = footprints[spatial_axes]
    spectral_footprint = footprints[spectral_axes]

    fiducial = np.empty(len(axes_types))
    if (spatial_footprint).any():
        lon, lat = spatial_footprint
        lon, lat = np.deg2rad(lon), np.deg2rad(lat)
        x_mean = np.mean(np.cos(lat) * np.cos(lon))
        y_mean = np.mean(np.cos(lat) * np.sin(lon))
        z_mean = np.mean(np.sin(lat))
        lon_fiducial = np.rad2deg(np.arctan2(y_mean, x_mean)) % 360.0
        lat_fiducial = np.rad2deg(np.arctan2(z_mean, np.sqrt(x_mean**2 + y_mean\
** 2)))
        fiducial[spatial_axes] = lon_fiducial, lat_fiducial
    if (spectral_footprint).any():
        fiducial[spectral_axes] = spectral_footprint.min()
    return fiducial
开发者ID:philhodge,项目名称:jwst,代码行数:29,代码来源:util.py

示例13: check_visible

def check_visible(src,aa,t=None,check27m=True,check2m=True):
    ''' Check whether a source is observable from the location of aa
        given the limits on az/el of the 2-m's and HA/dec of the 27-m's, at
        date/time dt. Returns True if visible, False otherwise.
        
        If no time is given, it checks for the current time.
        
        By default, returns True only if it is visible from both the 2-m's and the
        27-m's; use check27m=False or check2m=False to ignore either the 27-m's or
        the 2-m's, respectively.
    '''
    
    if t is None:
        t = util.Time.now()
    
    # get alt, az, ha, dec at given date/time    
    aa.set_jultime(t.jd)
    src.compute(aa)
    alt = rad2deg(src.alt)
    az  = rad2deg(src.az)
    ha  = rad2deg(eovsa_ha(src,t))
    dec = rad2deg(src.dec)
    
    if check27m and check2m:
        return check_27m_visible(ha,dec) and check_2m_visible(az,alt) and check_2meq_visible(ha,dec)
    elif check27m:
        return check_27m_visible(ha,dec)
    elif check2m:
        return check_2m_visible(az,alt) and check_2meq_visible(ha,dec)
    else:
        return True
开发者ID:binchensolar,项目名称:eovsa,代码行数:31,代码来源:eovsa_visibility.py

示例14: sphdist

def sphdist(ra1, dec1, ra2, dec2, units=['deg','deg']):
    """
    Get the arc length between two points on the unit sphere

    parameters
    ----------
    ra1,dec1,ra2,dec2: scalar or array
        Coordinates of two points or sets of points. 
        Must be the same length.
    units: sequence
        A sequence containing the units of the input and output.  Default
        ['deg',deg'], which means inputs and outputs are in degrees.  Units
        can be 'deg' or 'rad'
    """
    
    units_in,units_out = units

    # note x,y,z from eq2xyz always returns 8-byte float
    x1,y1,z1 = eq2xyz(ra1, dec1, units=units_in)
    x2,y2,z2 = eq2xyz(ra2, dec2, units=units_in)

    costheta = x1*x2 + y1*y2 + z1*z2
    costheta.clip(-1.0,1.0,out=costheta)

    theta = arccos(costheta)

    if units_out == 'deg':
        numpy.rad2deg(theta,theta)
    return theta
开发者ID:blackdragon2016,项目名称:esutil,代码行数:29,代码来源:coords.py

示例15: evaluate

    def evaluate(cls, alpha_C, delta_C, phi, theta, psi):
        """
        Evaluate ZXZ rotation into native coordinates.

        This is like RotateNative2Celestial.evaluate except phi and psi are
        swapped in ZXZ rotation.

        Note currently the parameter values are passed in as degrees so we need
        to convert all inputs to radians and all outputs back to degrees.
        """

        alpha_C = np.deg2rad(alpha_C)
        delta_C = np.deg2rad(delta_C)
        phi = np.deg2rad(phi)
        theta = np.deg2rad(theta)
        psi = np.deg2rad(psi)

        phi_N, theta_N = cls._rotate_zxz(alpha_C, delta_C, psi, theta, phi)

        phi_N = np.rad2deg(phi_N)
        theta_N = np.rad2deg(theta_N)

        mask = phi_N > 180
        if isinstance(mask, np.ndarray):
            phi_N[mask] -= 360
        elif mask:
            phi_N -= 360

        return phi_N, theta_N
开发者ID:AdrianPotter,项目名称:astropy,代码行数:29,代码来源:rotations.py


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