Here are the examples of the python api numpy.radians taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
606 Examples
5
Source : geometry.py
with BSD 3-Clause "New" or "Revised" License
from sdss
with BSD 3-Clause "New" or "Revised" License
from sdss
def _setC(self):
"""
Set the transformation matrix and calculate its LU
decomposition for inverse operations.
"""
cosr = numpy.cos( numpy.radians(self.rot) )
sinr = numpy.sin( numpy.radians(self.rot) )
cosp = numpy.cos( numpy.radians(self.pa) )
sinp = numpy.sin( numpy.radians(self.pa) )
self.C = numpy.array([ [ cosr, sinr, -1.0, 0.0 ],
[ -sinr, cosr, 0.0, -1.0 ],
[ 0.0, 0.0, sinp, cosp ],
[ 0.0, 0.0, -cosp, sinp ] ])
self.Clu, self.Cpiv = linalg.lu_factor(self.C)
def _setD(self, x, y):
3
Source : CustomNestedSampler.py
with MIT License
from 3fon3fonov
with MIT License
from 3fon3fonov
def circ_mean_np(self, angles,azimuth=True):
"""find circular mean"""
rads = np.radians(angles)
av_sin = np.mean(np.sin(rads))
av_cos = np.mean(np.cos(rads))
ang_rad = np.arctan2(av_sin,av_cos)
ang_deg = np.degrees(ang_rad)
if azimuth:
ang_deg = np.mod(ang_deg,360.)
return ang_deg
def get_meadians(self,f):
3
Source : functions.py
with MIT License
from 3fon3fonov
with MIT License
from 3fon3fonov
def ma_from_t0(per, ecc, om, t_transit, epoch):
'''
'''
om = np.radians(om)
E = 2.0*np.arctan( np.sqrt( ( (1.0-ecc)/(1.0+ecc) ) ) * np.tan( (np.pi/4.0)-(om/2.0) ) )
# t_transit = epoch - ((ma/TAU)*per) + (E + ecc*np.sin(E)) * (per/TAU)
ma = ((epoch - t_transit + (E + ecc*np.sin(E)) * (per/TAU))*TAU)/per
ma = np.degrees(ma)%360.0
return ma
def ma_from_epoch(per, t_peri, epoch):
3
Source : functions.py
with MIT License
from 3fon3fonov
with MIT License
from 3fon3fonov
def mut_incl(i1,i2,capOm):
'''
Calculates the mutual inclination of two planets
input parameters:
i1,i2, Delta Omega: inclinations and diffence of the line of nodes in deg.
output parameters:
Delta i: mutual orbital inclination in deg.
'''
fb = np.degrees(np.arccos(((np.cos(np.radians(i1))*np.cos(np.radians(i2)))+
(np.sin(np.radians(i1))*np.sin(np.radians(i2))*np.cos(np.radians(capOm))))))
return fb
def add_jitter(obj, errors, ind):
3
Source : make_cornerplot.py
with MIT License
from 3fon3fonov
with MIT License
from 3fon3fonov
def circ_mean_np(angles,azimuth=True):
"""find circular mean"""
rads = np.radians(angles)
av_sin = np.mean(np.sin(rads))
av_cos = np.mean(np.cos(rads))
ang_rad = np.arctan2(av_sin,av_cos)
ang_deg = np.degrees(ang_rad)
if azimuth:
ang_deg = np.mod(ang_deg,360.)
return ang_deg
def mcmc_satb(obj,samp_i):
3
Source : acas_planes.py
with MIT License
from 95616ARG
with MIT License
from 95616ARG
def load_scenario(self, scenario):
"""Loads a particular scenario into self.
@scenario should be a 3-tuple:
(intruder_heading, own_velocity, intruder_velocity)
"""
attacker_heading_deg, own_velocity, attacker_velocity = scenario
self.intruder_heading = np.radians(attacker_heading_deg)
self.own_velocity = own_velocity
self.intruder_velocity = attacker_velocity
def run_for_network(self, network_name, data_csv):
3
Source : rotation_utils.py
with MIT License
from airalcorn2
with MIT License
from airalcorn2
def get_dolly_zoom_z(initial_aov, camera_z, initial_z, new_aov):
# See: https://en.wikipedia.org/wiki/Dolly_zoom#Calculating_distances.
width = (camera_z - initial_z) * 2 * np.tan(np.radians(initial_aov / 2))
camera_distance = width / (2 * np.tan(np.radians(new_aov / 2)))
# The object's new z after doing a dolly zoom.
return camera_z - camera_distance
def gen_single_angle_rotation_matrix(which_angle, angle):
3
Source : app.py
with GNU General Public License v3.0
from airalcorn2
with GNU General Public License v3.0
from airalcorn2
def change_angle_of_view(self, step):
initial_aov = self.angle_of_view
initial_tan_angle = np.tan(np.radians(initial_aov / 2))
initial_z = self.total_z
width = 2 * initial_tan_angle * np.abs(self.camera_distance - initial_z)
new_aov = initial_aov + step
new_aov = max(self.min_angle_of_view, min(new_aov, 180))
new_camera_distance = width / (2 * np.tan(np.radians(new_aov / 2)))
new_z = self.camera_distance - new_camera_distance
if self.too_far < new_z < self.too_close:
self.set_angle_of_view(new_aov)
self.set_z(new_z)
def set_z(self, z):
3
Source : scene.py
with GNU General Public License v3.0
from airalcorn2
with GNU General Public License v3.0
from airalcorn2
def adjust_angle_of_view(self, angle_of_view):
self.angle_of_view = angle_of_view
self.TAN_ANGLE = np.tan(np.radians(self.angle_of_view / 2))
perspective = Matrix44.perspective_projection(
self.angle_of_view, RATIO, 0.1, 1000.0
)
self.PROG["VP"].write((perspective * LOOK_AT).astype("f4").tobytes())
def gen_rot_matrix_yaw(self, yaw):
3
Source : scene.py
with GNU General Public License v3.0
from airalcorn2
with GNU General Public License v3.0
from airalcorn2
def set_param(self, name, value):
if name in self.angle2func:
rads = np.radians(value)
rads_x = np.cos(rads)
rads_y = np.sin(rads)
value = np.arctan2(rads_y, rads_x)
R_obj = np.array(self.PROG["R_obj"].value).reshape((3, 3)).T
angles = self.get_angles_from_matrix(R_obj)
angles[name] = value
R_obj = self.gen_rotation_matrix(**angles)
self.PROG["R_obj"].write(R_obj.T.astype("f4").tobytes())
elif name in self.prog_vals:
self.PROG[name].value = value
elif name == "angle_of_view":
self.adjust_angle_of_view(value)
elif name == "DirLight":
self.PROG["DirLight"].value = value
self.PROG["R_light"].write(np.eye(3).astype("f4").tobytes())
3
Source : colors.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def direction(self):
""" The unit vector direction towards the light source """
# Azimuth is in degrees clockwise from North. Convert to radians
# counterclockwise from East (mathematical notation).
az = np.radians(90 - self.azdeg)
alt = np.radians(self.altdeg)
return np.array([
np.cos(az) * np.cos(alt),
np.sin(az) * np.cos(alt),
np.sin(alt)
])
def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
3
Source : test_colors.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def _azimuth2math(azimuth, elevation):
"""Converts from clockwise-from-north and up-from-horizontal to
mathematical conventions."""
theta = np.radians((90 - azimuth) % 360)
phi = np.radians(90 - elevation)
return theta, phi
def test_pandas_iterable(pd):
3
Source : pet_shape_gallery.py
with GNU General Public License v3.0
from AntSimi
with GNU General Public License v3.0
from AntSimi
def build_circle(x0, y0, r):
angle = radians(linspace(0, 360, 50))
x_norm, y_norm = cos(angle), sin(angle)
return local_to_coordinates(x_norm * r, y_norm * r, x0, y0)
# %%
# We iterate over closed contours and sort with regards of shape error
g = RegularGridDataset(
3
Source : pet_fit_contour.py
with GNU General Public License v3.0
from AntSimi
with GNU General Public License v3.0
from AntSimi
def build_circle(x0, y0, r):
angle = radians(linspace(0, 360, 50))
x_norm, y_norm = cos(angle), sin(angle)
return local_to_coordinates(x_norm * r, y_norm * r, x0, y0)
def build_ellipse(x0, y0, a, b, theta):
3
Source : pet_fit_contour.py
with GNU General Public License v3.0
from AntSimi
with GNU General Public License v3.0
from AntSimi
def build_ellipse(x0, y0, a, b, theta):
angle = radians(linspace(0, 360, 50))
x = a * cos(theta) * cos(angle) - b * sin(theta) * sin(angle)
y = a * sin(theta) * cos(angle) + b * cos(theta) * sin(angle)
return local_to_coordinates(x, y, x0, y0)
# %%
# Plot fitted circle or ellipse on stored contour
xs, ys = a.contour_lon_s, a.contour_lat_s
3
Source : generic.py
with GNU General Public License v3.0
from AntSimi
with GNU General Public License v3.0
from AntSimi
def build_circle(x0, y0, r):
"""
Build circle from center coordinates.
:param float x0: center coordinate
:param float y0: center coordinate
:param float r: radius i meter
:return: x,y
:rtype: (array,array)
"""
angle = radians(linspace(0, 360, 50))
x_norm, y_norm = cos(angle), sin(angle)
return x_norm * r + x0, y_norm * r + y0
3
Source : __init__.py
with GNU General Public License v3.0
from arcadelab
with GNU General Public License v3.0
from arcadelab
def radians(
*ts: Union[float, np.ndarray], degrees: bool = True
) -> Union[float, List[float]]:
"""Convert to radians.
Args:
ts: the angle or array of angles.
degrees (bool, optional): whether the inputs are in degrees. If False, this is a no-op. Defaults to True.
Returns:
Union[float, List[float]]: each argument, converted to radians.
"""
if degrees:
ts = [np.radians(t) for t in ts]
return ts[0] if len(ts) == 1 else ts
def generate_uniform_angles(
3
Source : renderer_pt3d.py
with MIT License
from Arthur151
with MIT License
from Arthur151
def get_renderer(test=False,**kwargs):
renderer = Renderer(**kwargs)
if test:
import cv2
dist = 1/np.tan(np.radians(args().FOV/2.))
print('dist:', dist)
model = pickle.load(open(os.path.join(args().smpl_model_path,'smpl','SMPL_NEUTRAL.pkl'),'rb'), encoding='latin1')
np_v_template = torch.from_numpy(np.array(model['v_template'])).cuda().float()[None]
face = torch.from_numpy(model['f'].astype(np.int32)).cuda()[None]
np_v_template = np_v_template.repeat(2,1,1)
np_v_template[1] += 0.3
np_v_template[:,:,2] += dist
face = face.repeat(2,1,1)
result = renderer(np_v_template, face).cpu().numpy()
for ri in range(len(result)):
cv2.imwrite('test{}.png'.format(ri),(result[ri,:,:,:3]*255).astype(np.uint8))
return renderer
if __name__ == '__main__':
3
Source : xloc_utils.py
with GNU General Public License v3.0
from awech
with GNU General Public License v3.0
from awech
def rotate_coords(x, y, x0, y0, angle):
angle = np.radians(angle) # "+" for counter-clockwise rotation , "-" for clockwise rotation
R = np.array([[np.cos(angle), -np.sin(angle)],
[np.sin(angle), np.cos(angle)]])
A = np.array([x, y])
newX, newY = np.matmul(R, A)
newX = newX + x0
newY = newY + y0
return newX, newY
def create_rotated_grid(rotate_params):
3
Source : in_static_equilibrium.py
with MIT License
from bellshade
with MIT License
from bellshade
def polar_force(
magnitude: float, angle: float, radian_mode: bool = False
) -> List[float]:
# Menghitung force pada suatu sistem dengan menggunakan matriks
# rotasi dan magnitudenya.
# polar 10, 45 = 7.0710678118654755, 7.071067811865475
# polar 10, 3.14, True = -9.999987317275394, 0.01592652916486828
if radian_mode:
return [magnitude * cos(angle), magnitude * sin(angle)]
return [magnitude * cos(radians(angle)), magnitude * sin(radians(angle))]
def in_static_equilibrium(
3
Source : koch.py
with MIT License
from bellshade
with MIT License
from bellshade
def rotate(vector: np.ndarray, angle_in_degrees: float) -> np.ndarray:
"""
>>> import numpy
>>> rotate(numpy.array([1, 0]), 60)
array([0.5 , 0.8660254])
>>> rotate(numpy.array([1, 0]), 90)
array([6.123234e-17, 1.000000e+00])
"""
theta = np.radians(angle_in_degrees)
c, s = np.cos(theta), np.sin(theta)
rotation_matrix = np.array(((c, -s), (s, c)))
return np.dot(rotation_matrix, vector)
def plot(vectors: list[np.ndarray]) -> None:
3
Source : geometry.py
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
def cross_track_distance(start_lat, start_lon, end_lat, end_lon, d_lat, d_lon):
# ref: http://www.movable-type.co.uk/scripts/latlong.html
d13 = great_circle_distance_haversine(start_lat, start_lon, d_lat, d_lon) / EARTH_RADIUS
theta12 = np.radians(initial_bearing(start_lat, start_lon, end_lat, end_lon))
theta13 = np.radians(initial_bearing(start_lat, start_lon, d_lat, d_lon))
return -(np.arcsin(np.sin(d13) * np.sin(theta13 - theta12)) * EARTH_RADIUS)
def great_circle_distance_haversine(start_lat, start_lon, end_lat, end_lon):
3
Source : geometry.py
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
def great_circle_distance_haversine(start_lat, start_lon, end_lat, end_lon):
phi1, phi2 = np.radians(start_lat), np.radians(end_lat)
dphi, dlambda = np.radians(start_lat - end_lat), np.radians(start_lon - end_lon)
a = np.sin(dphi / 2) * np.sin(dphi / 2) + np.cos(phi1) * np.cos(phi2) * \
np.sin(dlambda / 2) * np.sin(dlambda / 2)
c = 2 * np.arctan2(np.sqrt(a), np.sqrt(1 - a))
return c * EARTH_RADIUS
def initial_bearing(start_lat, start_lon, end_lat, end_lon):
3
Source : geometry.py
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
with BSD 3-Clause "New" or "Revised" License
from BerkeleyLearnVerify
def initial_bearing(start_lat, start_lon, end_lat, end_lon):
lat1, lat2 = np.radians(start_lat), np.radians(end_lat)
lon1, lon2 = np.radians(start_lon), np.radians(end_lon)
y = np.sin(lon2 - lon1) * np.cos(lat2)
x = np.cos(lat1) * np.sin(lat2) - np.sin(lat1) * \
np.cos(lat2) * np.cos(lon2 - lon1)
return np.degrees(np.arctan2(y, x)) % 360
3
Source : plot.py
with MIT License
from brightwind-dev
with MIT License
from brightwind-dev
def plot_TI_by_sector(turbulence, wdir, ti):
radians = np.radians(utils._get_dir_sector_mid_pts(ti.index))
fig = plt.figure(figsize=(10, 10))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
ax.set_thetagrids(utils._get_dir_sector_mid_pts(ti.index))
ax.plot(np.append(radians, radians[0]), ti.append(ti.iloc[0])['Mean_TI'], color=COLOR_PALETTE.primary, linewidth=4,
figure=fig)
maxlevel = ti['Mean_TI'].max() + 0.1
ax.set_ylim(0, maxlevel)
ax.scatter(np.radians(wdir), turbulence, color=COLOR_PALETTE.secondary, alpha=0.3, s=1)
ax.legend(loc=8, framealpha=1)
plt.close()
return ax.get_figure()
def plot_shear_by_sector(scale_variable, wind_rose_data, calc_method='power_law'):
3
Source : colors.py
with MIT License
from buds-lab
with MIT License
from buds-lab
def direction(self):
"""The unit vector direction towards the light source."""
# Azimuth is in degrees clockwise from North. Convert to radians
# counterclockwise from East (mathematical notation).
az = np.radians(90 - self.azdeg)
alt = np.radians(self.altdeg)
return np.array([
np.cos(az) * np.cos(alt),
np.sin(az) * np.cos(alt),
np.sin(alt)
])
def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
3
Source : Utilities.py
with MIT License
from bullbo
with MIT License
from bullbo
def rot_v(v1, theta):
""" Rotates a vector v1 theta degrees, returns the new rotated vector. """
theta = np.radians(theta)
c, s = np.cos(theta), np.sin(theta)
R = np.array([[c, s], [-s, c]])
return (R.dot(v1))
def angle2(v1, v2):
3
Source : PILasOPENCV.py
with MIT License
from bunkahle
with MIT License
from bunkahle
def _get_ellipse_bb(x, y, major, minor, angle_deg=0):
"Compute tight ellipse bounding box."
t = np.arctan(-minor / 2 * np.tan(np.radians(angle_deg)) / (major / 2))
[max_x, min_x] = [x + major / 2 * np.cos(t) * np.cos(np.radians(angle_deg)) -
minor / 2 * np.sin(t) * np.sin(np.radians(angle_deg)) for t in (t, t + np.pi)]
t = np.arctan(minor / 2 * 1. / np.tan(np.radians(angle_deg)) / (major / 2))
[max_y, min_y] = [y + minor / 2 * np.sin(t) * np.cos(np.radians(angle_deg)) +
major / 2 * np.cos(t) * np.sin(np.radians(angle_deg)) for t in (t, t + np.pi)]
return min_x, min_y, max_x, max_y
def _getink(self, ink, fill=None):
3
Source : PILasOPENCV.py
with MIT License
from bunkahle
with MIT License
from bunkahle
def _get_pointFromEllipseAngle(self, centerx, centery, radiush, radiusv, ang):
"""calculate point (x,y) for a given angle ang on an ellipse with its center at centerx, centery and
its horizontal radiush and its vertical radiusv"""
th = np.radians(ang)
ratio = (radiush/2.0)/float(radiusv/2.0)
x = centerx + radiush/2.0 * np.cos(th)
y = centery + radiusv/2.0 * np.sin(th)
return int(x), int(y)
def _multiline_check(self, text):
3
Source : utils.py
with BSD 2-Clause "Simplified" License
from centreborelli
with BSD 2-Clause "Simplified" License
from centreborelli
def viewing_direction(zenith, azimut):
"""
Compute the unit 3D vector defined by zenith and azimut angles.
Args:
zenith (float): angle wrt the vertical direction, in degrees
azimut (float): angle wrt the north direction, in degrees
Return:
3-tuple: 3D unit vector giving the corresponding direction
"""
z = np.radians(zenith)
a = np.radians(azimut)
return np.sin(a)*np.sin(z), np.cos(a)*np.sin(z), np.cos(z)
def bounding_box2D(pts):
3
Source : mode_browse.py
with MIT License
from chaosparrot
with MIT License
from chaosparrot
def rotateMouse( self, radians, radius ):
theta = np.radians( radians )
c, s = np.cos(theta), np.sin(theta)
R = np.matrix('{} {}; {} {}'.format(c, -s, s, c))
mousePos = np.array([radius, radius])
relPos = np.dot( mousePos, R )
moveTo( self.centerXPos + relPos.flat[0], self.centerYPos + relPos.flat[1] )
def exit( self ):
3
Source : solar_position.py
with Apache License 2.0
from chrisroadmap
with Apache License 2.0
from chrisroadmap
def _apparent_sidereal_time(julian_date):
julian_century = (julian_date - 2451545) / 36525
mean_sidereal_time = (
_third_order(
julian_century,
[280.46061837, 360.98564736629 * 36525, 0.000387933, 1 / 38710000],
)
% 360
)
delta_psi, _ = _nutation(julian_date)
epsilon = _true_obliquity_of_ecliptic(julian_date)
return mean_sidereal_time + delta_psi + np.cos(np.radians(epsilon))
def _sun_right_ascension(julian_date):
3
Source : solar_position.py
with Apache License 2.0
from chrisroadmap
with Apache License 2.0
from chrisroadmap
def _sun_right_ascension(julian_date):
lambd = np.radians(_apparent_sun_longitude(julian_date))
epsilon = np.radians(_true_obliquity_of_ecliptic(julian_date))
beta = np.radians(_geocentric_latitude(julian_date))
return (
np.degrees(
np.arctan2(
np.sin(lambd) * np.cos(epsilon) - np.tan(beta) * np.sin(epsilon),
np.cos(lambd),
)
)
% 360
)
def _geocentric_sun_declination(julian_date):
3
Source : solar_position.py
with Apache License 2.0
from chrisroadmap
with Apache License 2.0
from chrisroadmap
def _geocentric_sun_declination(julian_date):
beta = np.radians(_geocentric_latitude(julian_date))
epsilon = np.radians(_true_obliquity_of_ecliptic(julian_date))
lambd = np.radians(_apparent_sun_longitude(julian_date))
return np.degrees(
np.arcsin(
np.sin(beta) * np.cos(epsilon)
+ np.cos(beta) * np.sin(epsilon) * np.sin(lambd)
)
)
def _observer_local_hour_angle(julian_date, longitude):
3
Source : columns.py
with MIT License
from corriporai
with MIT License
from corriporai
def radians(self):
"""Returns the coordinates from degrees to radians"""
return np.radians(self)
class Longitude(LonLat):
3
Source : sar.py
with Apache License 2.0
from CosmiQ
with Apache License 2.0
from CosmiQ
def haversine(self, lat1, lon1, lat2, lon2, rad=False, radius=6.371E6):
"""
Haversine formula for distance between two points given their
latitude and longitude, assuming a spherical earth.
"""
if not rad:
lat1 = np.radians(lat1)
lon1 = np.radians(lon1)
lat2 = np.radians(lat2)
lon2 = np.radians(lon2)
dlat = lat2 - lat1
dlon = lon2 - lon1
a = np.sin(dlat/2)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon/2)**2
return 2 * radius * np.arcsin(np.sqrt(a))
def courseoffset(self, latgrid, longrid, lattarget, lontarget):
3
Source : test_colors.py
with Apache License 2.0
from dashanji
with Apache License 2.0
from dashanji
def _azimuth2math(azimuth, elevation):
"""
Convert from clockwise-from-north and up-from-horizontal to mathematical
conventions.
"""
theta = np.radians((90 - azimuth) % 360)
phi = np.radians(90 - elevation)
return theta, phi
def test_pandas_iterable(pd):
3
Source : box.py
with Apache License 2.0
from dataloop-ai
with Apache License 2.0
from dataloop-ai
def _rotate_points(self, points):
angle = np.radians(self.angle)
rotation_matrix = np.asarray([[np.cos(angle), -np.sin(angle)],
[np.sin(angle), np.cos(angle)]])
pts2 = np.asarray([rotation_matrix.dot(pt)[:2] for pt in points])
return pts2
def _translate(self, points, translate_x, translate_y=None):
3
Source : Multimer.py
with GNU General Public License v3.0
from degiacom
with GNU General Public License v3.0
from degiacom
def _rotation(self):
#angle in numpy need to be given in rad -> rad = deg * pi/180
alpha = np.radians(self.pos[0])
beta = np.radians(self.pos[1])
gamma = np.radians(self.pos[2])
#rotation autour axe x
#|1 0 0 |
#|0 np.cos(alpha) -np.sin(alpha)|
#|0 np.sin(alpha) np.cos(alpha) |
Rx = np.array([[1,0,0], [0, np.cos(alpha), -np.sin(alpha)], [0, np.sin(alpha), np.cos(alpha)]])
Ry = np.array([[np.cos(beta), 0, np.sin(beta)], [0, 1, 0], [-np.sin(beta), 0, np.cos(beta)]])
Rz = np.array([[np.cos(gamma), -np.sin(gamma), 0], [np.sin(gamma), np.cos(gamma), 0], [0,0,1]])
rotation = np.dot(Rx,np.dot(Ry,Rz))
#multiply rotation matrix with each atom of the monomer
self.monomer = np.dot(self.monomer,rotation)
def _circular_symmetry(self):
3
Source : Multimer.py
with GNU General Public License v3.0
from degiacom
with GNU General Public License v3.0
from degiacom
def z_rotation(self,angle):
#rotation of the whole assembly around around z
theta = np.radians(angle)
Rz = np.array([[np.cos(theta), -np.sin(theta), 0], [np.sin(theta), np.cos(theta), 0], [0,0,1]])
for i in xrange(0,self.degree,1):
M=self.multimer[i]
self.multimer[i] = np.dot(M,Rz)
def atomselect(self,unit,chain,resid,atom,get_index=False):
3
Source : Protein.py
with GNU General Public License v3.0
from degiacom
with GNU General Public License v3.0
from degiacom
def rotation(self,x,y,z):
#angle in numpy need to be given in rad -> rad = deg * pi/180
alpha = np.radians(x)
beta = np.radians(y)
gamma = np.radians(z)
#ex.: rotation around axis x
#|1 0 0 |
#|0 np.cos(alpha) -np.sin(alpha)|
#|0 np.sin(alpha) np.cos(alpha) |
Rx = np.array([[1,0,0], [0, np.cos(alpha), -np.sin(alpha)], [0, np.sin(alpha), np.cos(alpha)]])
Ry = np.array([[np.cos(beta), 0, np.sin(beta)], [0, 1, 0], [-np.sin(beta), 0, np.cos(beta)]])
Rz = np.array([[np.cos(gamma), -np.sin(gamma), 0], [np.sin(gamma), np.cos(gamma), 0], [0,0,1]])
rotation = np.dot(Rx,np.dot(Ry,Rz))
#multiply rotation matrix with each atom of the monomer
self.data[:,5:8] = np.dot(self.data[:,5:8],rotation)
def rgyr(self):
3
Source : gis_utils.py
with MIT License
from Deltares
with MIT License
from Deltares
def degree_metres_y(lat):
""" "returns the verical length of a degree in metres at
a given latitude."""
m1 = 111132.92 # latitude calculation term 1
m2 = -559.82 # latitude calculation term 2
m3 = 1.175 # latitude calculation term 3
m4 = -0.0023 # latitude calculation term 4
# # Calculate the length of a degree of latitude and longitude in meters
radlat = np.radians(lat)
latlen = (
m1
+ (m2 * np.cos(2.0 * radlat))
+ (m3 * np.cos(4.0 * radlat))
+ (m4 * np.cos(6.0 * radlat))
)
return latlen
@njit
3
Source : gis_utils.py
with MIT License
from Deltares
with MIT License
from Deltares
def degree_metres_x(lat):
""" "returns the horizontal length of a degree in metres at
a given latitude."""
p1 = 111412.84 # longitude calculation term 1
p2 = -93.5 # longitude calculation term 2
p3 = 0.118 # longitude calculation term 3
# # Calculate the length of a degree of latitude and longitude in meters
radlat = np.radians(lat)
longlen = (
(p1 * np.cos(radlat))
+ (p2 * np.cos(3.0 * radlat))
+ (p3 * np.cos(5.0 * radlat))
)
return longlen
@njit
3
Source : test_polar.py
with GNU General Public License v3.0
from dnn-security
with GNU General Public License v3.0
from dnn-security
def test_thetalim_args():
ax = plt.subplot(projection='polar')
ax.set_thetalim(0, 1)
assert tuple(np.radians((ax.get_thetamin(), ax.get_thetamax()))) == (0, 1)
ax.set_thetalim((2, 3))
assert tuple(np.radians((ax.get_thetamin(), ax.get_thetamax()))) == (2, 3)
3
Source : snippet.py
with Apache License 2.0
from dockerizeme
with Apache License 2.0
from dockerizeme
def _spherical_to_cartesian(ra, dec):
"""
(Private internal function)
Inputs in degrees. Outputs x,y,z
"""
rar = np.radians(ra)
decr = np.radians(dec)
x = np.cos(rar) * np.cos(decr)
y = np.sin(rar) * np.cos(decr)
z = np.sin(decr)
return x, y, z
def _great_circle_distance(ra1, dec1, ra2, dec2):
3
Source : geo.py
with MIT License
from earthobservations
with MIT License
from earthobservations
def get_coordinates_in_radians(self):
"""
Returns: coordinates in radians where the first column is the latitudes
and the second column the longitudes
"""
return np.radians(self.get_coordinates())
def __eq__(self, other):
3
Source : Polar.py
with MIT License
from ebranlard
with MIT License
from ebranlard
def alpha0(self,window=None):
""" Finds alpha0, angle of zero lift """
if window is None:
if self._radians:
window=[np.radians(-20),np.radians(20)]
else:
window=[-20,20]
window = _alpha_window_in_bounds(self.alpha,window)
#print(window)
#print(self.alpha)
#print(self._radians)
#print(self.cl)
#print(window)
return _find_alpha0(self.alpha,self.cl,window)
def linear_region(self):
3
Source : hoa.py
with BSD 3-Clause Clear License
from ebu
with BSD 3-Clause Clear License
from ebu
def ApproxMaxRECoefficients(Nmax):
"""Approximate maxRE coefficients for a given order, from [0].
[0] Zotter, Franz, and Matthias Frank. "All-round ambisonic panning and
decoding." Journal of the audio engineering society 60.10 (2012)
"""
rE = np.cos(np.radians(137.9 / (Nmax + 1.51)))
return eval_legendre(np.arange(Nmax + 1), rE)
3
Source : conversion.py
with BSD 3-Clause Clear License
from ebu
with BSD 3-Clause Clear License
from ebu
def _map_az_to_linear(cls, left_az, right_az, azimuth):
mid_az = (left_az + right_az) / 2.0
az_range = right_az - mid_az
rel_az = azimuth - mid_az
gain_r = 0.5 + 0.5 * np.tan(np.radians(rel_az)) / np.tan(np.radians(az_range))
return np.arctan2(gain_r, 1-gain_r) * (2 / np.pi)
@classmethod
3
Source : conversion.py
with BSD 3-Clause Clear License
from ebu
with BSD 3-Clause Clear License
from ebu
def _whd2xyz(cls, width, height, depth):
x_size_width = np.sin(np.radians(width / 2.0)) if width < 180.0 else 1.0
y_size_width = (1 - np.cos(np.radians(width / 2.0))) / 2.0
z_size_height = np.sin(np.radians(height / 2.0)) if height < 180.0 else 1.0
y_size_height = (1 - np.cos(np.radians(height / 2.0))) / 2.0
y_size_depth = depth
return x_size_width, max(y_size_width, y_size_height, y_size_depth), z_size_height
@classmethod
See More Examples