本文整理匯總了Python中numpy.degrees方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.degrees方法的具體用法?Python numpy.degrees怎麽用?Python numpy.degrees使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.degrees方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_bounds
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def test_bounds(self):
"""
Test that out-of-bounds coordinates return NaN reddening, and that
in-bounds coordinates do not return NaN reddening.
"""
for mode in (['random_sample', 'random_sample_per_pix',
'median', 'samples', 'mean']):
# Draw random coordinates on the sphere
n_pix = 10000
u, v = np.random.random((2,n_pix))
l = 360. * u
b = 90. - np.degrees(np.arccos(2.*v - 1.))
c = coords.SkyCoord(l, b, frame='galactic', unit='deg')
A_calc = self._iphas(c, mode=mode)
in_bounds = (l > 32.) & (l < 213.) & (b < 4.5) & (b > -4.5)
out_of_bounds = (l < 28.) | (l > 217.) | (b > 7.) | (b < -7.)
n_nan_in_bounds = np.sum(np.isnan(A_calc[in_bounds]))
n_finite_out_of_bounds = np.sum(np.isfinite(A_calc[out_of_bounds]))
self.assertTrue(n_nan_in_bounds == 0)
self.assertTrue(n_finite_out_of_bounds == 0)
示例2: plot_range_ring
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def plot_range_ring(self, range_ring_location_km, bm=None,
color='k', ls='-'):
"""
Plot a single range ring.
Parameters::
----------
range_ring_location_km : float
Location of range ring in km.
npts: int
Number of points in the ring, higher for better resolution.
ax : Axis
Axis to plot on. None will use the current axis.
"""
npts = 100
bm.tissot(self.rlon, self.rlat,
np.degrees(range_ring_location_km * 1000. / RE), npts,
fill=False, color='black', linestyle='dashed')
################
# Save methods #
################
示例3: calculate_clock_angle
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def calculate_clock_angle(inst):
""" Calculate IMF clock angle and magnitude of IMF in GSM Y-Z plane
Parameters
-----------
inst : pysat.Instrument
Instrument with OMNI HRO data
"""
# Calculate clock angle in degrees
clock_angle = np.degrees(np.arctan2(inst['BY_GSM'], inst['BZ_GSM']))
clock_angle[clock_angle < 0.0] += 360.0
inst['clock_angle'] = pds.Series(clock_angle, index=inst.data.index)
# Calculate magnitude of IMF in Y-Z plane
inst['BYZ_GSM'] = pds.Series(np.sqrt(inst['BY_GSM']**2 +
inst['BZ_GSM']**2),
index=inst.data.index)
return
示例4: __init__
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def __init__(self, rotation: Vector, translation: Vector, angle_unit: str, notation: str='XYZ'):
self.rotation = rotation
self.translation = translation
self.angle_unit = angle_unit
if self.angle_unit == 'degrees':
self.rotation = Vector(*[radians(alpha) for alpha in rotation])
self.R_x = None
self.R_y = None
self.R_z = None
self.T = None
self.matrix = None
self.notation = notation
self._update_matrix()
示例5: sind
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def sind(angle):
"""
Sine with angle input in degrees
Parameters
----------
angle : float
Angle in degrees
Returns
-------
result : float
Sin of the angle
"""
res = np.sin(np.radians(angle))
return res
示例6: tand
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def tand(angle):
"""
Tan with angle input in degrees
Parameters
----------
angle : float
Angle in degrees
Returns
-------
result : float
Tan of the angle
"""
res = np.tan(np.radians(angle))
return res
示例7: asind
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def asind(number):
"""
Inverse Sine returning an angle in degrees
Parameters
----------
number : float
Input number
Returns
-------
result : float
arcsin result
"""
res = np.degrees(np.arcsin(number))
return res
示例8: singleaxis
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def singleaxis(self, apparent_zenith, apparent_azimuth):
"""
Get tracking data. See :py:func:`pvlib.tracking.singleaxis` more
detail.
Parameters
----------
apparent_zenith : float, 1d array, or Series
Solar apparent zenith angles in decimal degrees.
apparent_azimuth : float, 1d array, or Series
Solar apparent azimuth angles in decimal degrees.
Returns
-------
tracking data
"""
tracking_data = singleaxis(apparent_zenith, apparent_azimuth,
self.axis_tilt, self.axis_azimuth,
self.max_angle,
self.backtrack, self.gcr)
return tracking_data
示例9: __str__
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def __str__(self):
return ('{name}:\n'
' Semimajor axis (a) = {a:10.3f} km\n'
' Eccentricity (e) = {self.e:13.6f}\n'
' Inclination (i) = {i:8.1f} deg\n'
' Right ascension of the ascending node (raan) = {raan:8.1f} deg\n'
' Argument of perigee (arg_pe) = {arg_pe:8.1f} deg\n'
' Mean anomaly at reference epoch (M0) = {M0:8.1f} deg\n'
' Period (T) = {T}\n'
' Reference epoch (ref_epoch) = {self.ref_epoch!s}\n'
' Mean anomaly (M) = {M:8.1f} deg\n'
' Time (t) = {t}\n'
' Epoch (epoch) = {self.epoch!s}'
).format(
name=self.__class__.__name__,
self=self,
a=self.a / kilo,
i=degrees(self.i),
raan=degrees(self.raan),
arg_pe=degrees(self.arg_pe),
M0=degrees(self.M0),
M=degrees(self.M),
T=timedelta(seconds=self.T),
t=timedelta(seconds=self.t))
示例10: _vlines
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def _vlines(lines, ctrs=None, lengths=None, vecs=None, angle_lo=20, angle_hi=160, ransac_options=RANSAC_OPTIONS):
ctrs = ctrs if ctrs is not None else lines.mean(1)
vecs = vecs if vecs is not None else lines[:, 1, :] - lines[:, 0, :]
lengths = lengths if lengths is not None else np.hypot(vecs[:, 0], vecs[:, 1])
angles = np.degrees(np.arccos(vecs[:, 0] / lengths))
points = np.column_stack([ctrs[:, 0], angles])
point_indices, = np.nonzero((angles > angle_lo) & (angles < angle_hi))
points = points[point_indices]
if len(points) > 2:
model_ransac = linear_model.RANSACRegressor(**ransac_options)
model_ransac.fit(points[:, 0].reshape(-1, 1), points[:, 1].reshape(-1, 1))
inlier_mask = model_ransac.inlier_mask_
valid_lines = lines[point_indices[inlier_mask], :, :]
else:
valid_lines = []
return valid_lines
示例11: _hlines
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def _hlines(lines, ctrs=None, lengths=None, vecs=None, angle_lo=20, angle_hi=160, ransac_options=RANSAC_OPTIONS):
ctrs = ctrs if ctrs is not None else lines.mean(1)
vecs = vecs if vecs is not None else lines[:, 1, :] - lines[:, 0, :]
lengths = lengths if lengths is not None else np.hypot(vecs[:, 0], vecs[:, 1])
angles = np.degrees(np.arccos(vecs[:, 1] / lengths))
points = np.column_stack([ctrs[:, 1], angles])
point_indices, = np.nonzero((angles > angle_lo) & (angles < angle_hi))
points = points[point_indices]
if len(points) > 2:
model_ransac = linear_model.RANSACRegressor(**ransac_options)
model_ransac.fit(points[:, 0].reshape(-1, 1), points[:, 1].reshape(-1, 1))
inlier_mask = model_ransac.inlier_mask_
valid_lines = lines[point_indices[inlier_mask], :, :]
else:
valid_lines = []
return valid_lines
示例12: set_default_locators_and_formatters
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def set_default_locators_and_formatters(self, axis):
"""
Override to set up the locators and formatters to use with the
scale. This is only required if the scale requires custom
locators and formatters. Writing custom locators and
formatters is rather outside the scope of this example, but
there are many helpful examples in ``ticker.py``.
In our case, the Mercator example uses a fixed locator from
-90 to 90 degrees and a custom formatter class to put convert
the radians to degrees and put a degree symbol after the
value::
"""
class DegreeFormatter(Formatter):
def __call__(self, x, pos=None):
return "%d\N{DEGREE SIGN}" % np.degrees(x)
axis.set_major_locator(FixedLocator(
np.radians(np.arange(-90, 90, 10))))
axis.set_major_formatter(DegreeFormatter())
axis.set_minor_formatter(DegreeFormatter())
示例13: __true_to_mean
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def __true_to_mean(T,e):
"""Converts true anomaly to mean anomaly.
Args:
T(float): true anomaly in degrees
e(float): eccentricity
Returns:
float: the mean anomaly in degrees
"""
T = np.radians(T)
E = np.arctan2((1-e**2)*np.sin(T),e+np.cos(T))
M = E - e*np.sin(E)
M = np.degrees(M)
M = M%360
return M
# Parts of this method have been copied from:
# https://github.com/brandon-rhodes/python-sgp4/blob/master/sgp4/io.py
示例14: convert_xy_to_dirdip
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def convert_xy_to_dirdip(self, event):
"""
Converts xy-coordinates of a matplotlib-event into dip-direction/dip
by using the inverse transformation of mplstereonet. Returns floats in
degree.
"""
alpha = np.arctan2(event.xdata, event.ydata)
alpha_deg = np.degrees(alpha)
if alpha_deg < 0:
alpha_deg += 360
xy = np.array([[event.xdata, event.ydata]])
xy_trans = self.inv.transform(xy)
x = float(xy_trans[0,0:1])
y = float(xy_trans[0,1:2])
array = mplstereonet.stereonet_math._rotate(np.degrees(x),
np.degrees(y), (-1)*alpha_deg)
gamma = float(array[1])
gamma_deg = 90 - np.degrees(gamma)
return alpha_deg, gamma_deg
示例15: add_eigenvector_feature
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import degrees [as 別名]
def add_eigenvector_feature(self, datastore, dip_direct=0, dip=0, value=0):
"""
Adds an eigenvector feature.
Checks if the values lie in the normal range of degrees. Then the
row is appended to the treestore that is passed to the method.
"""
while dip_direct > 360:
dip_direct = dip_direct - 360
while dip_direct < 0:
dip_direct = dip_direct + 360
while dip > 90:
dip = dip - 90
while dip < 0:
dip = dip + 90
itr = datastore.append([dip_direct, dip, value])
return itr