Example #1
0
    def spatial_corr(self, cross_len = 2.0, nos = 80):
        """Spatial Correlatoin, cross length (corss_len) is assigned as two lambdas by default.  nos means number of sections."""
        self.spatial_correlation = []
        spatial_max = 0
        step = float(cross_len) / nos
        for each in range(nos + 1):
            temp = 0
            for k, each_AoA in enumerate(self.AoA_all):
                each_step = each*step*sine(each_AoA/180.0*PI)*2*PI
                phase = cosine(each_step) + 1j*sine(each_step)
                temp = temp + self.power_from_BS_to_UE_V[k]*phase
            self.spatial_correlation.append(abs(temp))
        self.spatial_correlation = [each / self.spatial_correlation[0] for each in self.spatial_correlation]

        step_tenth_lambda = 0.1
        step_half_lambda = 0.5
        step_full_lambda = 1.0
        self.power_from_BS_to_UE_tenth_lambda = []
        self.power_from_BS_to_UE_half_lambda = []
        self.power_from_BS_to_UE_full_lambda = []
        for k, each_AoA in enumerate(self.AoA_all):
            step = step_tenth_lambda*sine(each_AoA/180.0*PI)*2*PI
            phase = cosine(step) + 1j*sine(step)            
            self.power_from_BS_to_UE_tenth_lambda.append(self.power_from_BS_to_UE_V[k]*phase)
            
            step = step_half_lambda*sine(each_AoA/180.0*PI)*2*PI
            phase = cosine(step) + 1j*sine(step)
            self.power_from_BS_to_UE_half_lambda.append(self.power_from_BS_to_UE_V[k]*phase)
            
            step = step_full_lambda*sine(each_AoA/180.0*PI)*2*PI
            phase = cosine(step) + 1j*sine(step)
            self.power_from_BS_to_UE_full_lambda.append(self.power_from_BS_to_UE_V[k]*phase)
Example #2
0
def print_math():
    """ Prints some calculated values. """
    x = math.cosine(Pi)
    print(x)

    y = math.sine(Pi)
    print("The sine of PI is", y)
Example #3
0
 def ani(self, cross_len = 2.0, nos = 80):
     """cross length (corss_len) is assigned as two lambdas by default.  nos means number of sections."""
     self.ani_x = {}
     self.ani_y = {}
     spatial_max = 0
     delta = float(cross_len) / nos
     
     for n in range(nos + 1):
         step = n*delta
         data = []
         for k, each_AoA in enumerate(self.AoA_all):
             step2 = step*sine(each_AoA/180.0*PI)*2*PI
             phase = cosine(step2) + 1j*sine(step2)
             data.append(self.power_from_BS_to_UE_V[k]*phase)
             self.ani_x[n] = np.array([each.real for each in data])
             self.ani_y[n] = np.array([each.imag for each in data])
Example #4
0
    def spatial_corr(self, cross_len=2.0, nos=80):
        """Spatial Correlatoin, cross length (corss_len) is assigned as two lambdas by default.  nos means number of sections."""
        self.spatial_correlation = []
        spatial_max = 0
        step = float(cross_len) / nos
        for each in range(nos + 1):
            temp = 0
            for k, each_AoA in enumerate(self.AoA_all):
                each_step = each * step * sine(each_AoA / 180.0 * PI) * 2 * PI
                phase = cosine(each_step) + 1j * sine(each_step)
                temp = temp + self.power_from_BS_to_UE_V[k] * phase
            self.spatial_correlation.append(abs(temp))
        self.spatial_correlation = [
            each / self.spatial_correlation[0]
            for each in self.spatial_correlation
        ]

        step_tenth_lambda = 0.1
        step_half_lambda = 0.5
        step_full_lambda = 1.0
        self.power_from_BS_to_UE_tenth_lambda = []
        self.power_from_BS_to_UE_half_lambda = []
        self.power_from_BS_to_UE_full_lambda = []
        for k, each_AoA in enumerate(self.AoA_all):
            step = step_tenth_lambda * sine(each_AoA / 180.0 * PI) * 2 * PI
            phase = cosine(step) + 1j * sine(step)
            self.power_from_BS_to_UE_tenth_lambda.append(
                self.power_from_BS_to_UE_V[k] * phase)

            step = step_half_lambda * sine(each_AoA / 180.0 * PI) * 2 * PI
            phase = cosine(step) + 1j * sine(step)
            self.power_from_BS_to_UE_half_lambda.append(
                self.power_from_BS_to_UE_V[k] * phase)

            step = step_full_lambda * sine(each_AoA / 180.0 * PI) * 2 * PI
            phase = cosine(step) + 1j * sine(step)
            self.power_from_BS_to_UE_full_lambda.append(
                self.power_from_BS_to_UE_V[k] * phase)
Example #5
0
def terminator(ox, oy, radius, angle, col):
    alpha = 220
    if ox + radius > 0 and ox - radius < xSize:
        if radius < 2:
            angle = 180 - abs(180 - angle)/1
            circle(screen,[col[0]*angle/180,col[1]*angle/180,col[2]*angle/180],(ox,oy),radius)
        else:
            angle = angle*pi/180
            angle = 2*pi-angle
            for y in range(2*int(radius)):
                rowRadius = sqrt(radius**2 - (radius - y)**2)
                darkLength = int(rowRadius - rowRadius*sine(angle - pi/2))
                if angle > pi:
                    darkStart = ox - rowRadius
                else:
                    darkStart = ox + rowRadius - darkLength + 1

                if angle < 0.1 :
                    darkLength -= 1
                    f = angle/0.1
                    bit = pygame.Surface((1, 1), pygame.SRCALPHA)
                    bit.fill((0, 0, 0, alpha*f))
                    screen.blit(bit, (ox + rowRadius,oy - radius + y))
                    
                if angle > 2*pi - 0.1:
                    darkLength -= 1
                    darkStart += 1
                    
                    f = (2*pi - angle)/0.1
                    bit = pygame.Surface((1, 1), pygame.SRCALPHA)
                    bit.fill((0, 0, 0, alpha*f))
                    screen.blit(bit, (ox - rowRadius,oy - radius + y))
                
                horizontal_line = pygame.Surface((abs(darkLength), 1), pygame.SRCALPHA)
                horizontal_line.fill((0, 0, 0, alpha))
                screen.blit(horizontal_line, (darkStart,oy - radius + y))
Example #6
0
 def foo6():
     print(math.sine(3))
Example #7
0
print(math.sin(math.pi / 2))


def sin(x):
    if 2 * x == pi:
        return 0.99999999
    else:
        return None


pi = 3.14
print(sin(pi / 2))  # our variable and function
print(math.sin(math.pi / 2))  # math module's variable and function
from math import sin, pi  # import only what is required

print(sin(pi / 2))

# from module import *
# to import all entities above statement is used

# import module as alias
# aliasing module or giving our own name
import math as m  # math keyword cannot be used now

print(m.sin(m.pi / 2))

from math import pi as PI, sin as sine

print(sine(PI / 2))
Example #8
0
import math
print(math.sin(math.pi / 2))

print('-' * 10, '2')
from math import sin, pi
print(sin(pi / 2))

print('-' * 10, 'aliasing:')
import math as M
print(M.sin(M.pi / 2))
# after successful execution of an aliased import, the original module name becomes inaccessible and must not be used.

print('-' * 10, 'aliasing 2:')
from math import sin as sine, pi as P
print(sine(P / 2))

#-----------------------------------------------
# Some useful modules
#-----------------------------------------------
print('-' * 50)
print(' 4.2')
print('-' * 50)
import os
print(dir(os))  # list os module functions in a sorted list
print('-' * 10, 'math:')
print(M.e)
# ---
from math import ceil, floor, trunc, factorial, hypot
x = 1.4
y = 2.6
# ceil(x) - return smallest integer greater or equal to x
Example #9
0
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 13 09:12:37 2020

@author: David
"""
import math as mt

print(mt.sin(mt.pi / 2))
print(mt.pi)
for i in range(6):
    print(i, mt.sin(i))

from math import pi as numberpi
from math import sin as sine

print(sine(numberpi / 2))

from math import e as numbere, sin as sine, cos as cose

print("**************")
print(numbere)
print(cose(numberpi / 2))
print(sine(numberpi / 2))
Example #10
0
 else: rad = int(pythag(ySize,xSize)*degrees(atan(r/(d*d*d*3/1331)))/150)
 
 #Stars
 for star in stars:
     origx = star[0]
     origy = star[1]
     star[0] += 90
     star[1] -= ySize/2
     col = [star[2],star[2],star[2]]
     odist = sqrt(pow(star[1]*fov/xSize,2) + pow(star[0] - 90 - angle,2))
     if odist < 2*rad*fov/xSize:
         #col = [255,0,0]
         arg = atan2(star[1]*fov/xSize, star[0] - 90 - angle)
         dist = pow(odist,2)/(4*rad*fov/xSize) + rad*fov/xSize
         star[0] = angle + 90 + dist*cosine(arg)
         star[1] = dist*sine(arg)*xSize/fov
         #if star[0] - 90 > angle: star[0] = angle + 90 + pow(star[0] - 90 - angle,2)/(4*rad*fov/xSize) + rad*fov/xSize
         #elif star[0] - 90 < angle: star[0] = angle + 90 - pow(star[0] - 90 - angle,2)/(4*rad*fov/xSize) - rad*fov/xSize
         #print(angle, rad*fov/xSize, arg, odist, dist, origx, origy, star[0], star[1])
         
     for n in range(-1,2):
         screen.set_at((int(xSize/2 + (star[0] + offset + 360*n)/fov*xSize), int(star[1] + ySize/2) + 1), col)
         screen.set_at((int(xSize/2 + (star[0] + offset + 360*n)/fov*xSize), int(star[1] + ySize/2) - 1), col)
         screen.set_at((int(xSize/2 + (star[0] + offset + 360*n)/fov*xSize), int(star[1] + ySize/2)), col)
         screen.set_at((int(xSize/2 + (star[0] + offset + 360*n)/fov*xSize + 1), int(star[1] + ySize/2)), col)
         screen.set_at((int(xSize/2 + (star[0] + offset + 360*n)/fov*xSize - 1), int(star[1] + ySize/2)), col)
     star[0] = origx
     star[1] = origy
 
 for c in collect:
     a = c[1]
def f(x):
    return sine(x)
Example #12
0
#Function import with rename
from math import sin as sine
print(sine(90))
print(sin(90))  #throws an exception sin is not defined
Example #13
0
import datetime as dt

strptime = dt.datetime.strptime
import math





Fs = 10000000     # Sampling frequency                    
T = 1/Fs          # Sampling period       
L = 1200          # Length of signal
t = (0:L-1)*T     # Time vector
freq = 1420000000

signal = 0.7*sine(2*pi*freq*t)

corrupted_signal = signal + 2*rand(size(t))

fig, ((ax1, ax2, ax3, ax4)) = plt.subplots(nrows = 4, ncols=1, sharex=True)







ax1 = plt.gca()


def cal(X, Y):
    C = cosine(X)
    S = sine(Y)
    print('The Cosine is:', C, ', and the Sine is:', S)
    return C, S
Example #15
0
def cosine(x):
    return -math.sine(p*(math.pi *.5)) + 1
Example #16
0
def sin(deg): return sine(radians(deg))
def cos(deg): return cosine(radians(deg))
Example #17
0
def sin(deg):
    return sine(radians(deg))
Example #18
0
import numpy as np
import matplotlib.pyplot as plt
import math

F = 15  # thrust avg
r = 0.033  # radius

theta = 0  # angle between force and moment arm

torque = r * F * math.sine(theta)