-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathonetoneandnoise_test.py
More file actions
74 lines (62 loc) · 3.35 KB
/
onetoneandnoise_test.py
File metadata and controls
74 lines (62 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 29 11:55:39 2019
@author: talon
"""
from pfb_fixed import iterffft_natural_DIT, bitrevfixarray, make_fix_twiddle
import numpy as np
from fixpoint import cfixpoint
import time
N = 2**16 #32k
iters = 2 #100k multiplied by the 10 from running individual processes.
multiple = 92.1 #number of waves per period - purposefully commensurate over 10 x 32k
#we will generate 10 x 32k signals for multiprocessing before abs and summing and saving
resultarray = np.zeros((N,10),dtype = np.float64)
def FFT (ID,DATA,twid,shiftreg,bits,fraction,coeffbits):
resultarray[:,ID] = np.abs(iterffft_natural_DIT(DATA,twid,shiftreg,bits,fraction,coeffbits).to_complex())
#Generate 10 input signals
sig1 = cfixpoint(22,22) #22 bit fixpoint number that will use even-rounding
sig2 = cfixpoint(22,22)
sig3 = cfixpoint(22,22)
sig4 = cfixpoint(22,22)
sig5 = cfixpoint(22,22)
sig6 = cfixpoint(22,22)
sig7 = cfixpoint(22,22)
sig8 = cfixpoint(22,22)
sig9 = cfixpoint(22,22)
sig10 = cfixpoint(22,22)
tn1 = ((np.sin(multiple*(2*np.pi*np.arange(N))/N)).astype(np.float64))/20
tn2 = ((np.sin(multiple*(2*np.pi*np.arange(N,2*N))/N)).astype(np.float64))/20
tn3 = ((np.sin(multiple*(2*np.pi*np.arange(2*N,3*N))/N)).astype(np.float64))/20
tn4 = ((np.sin(multiple*(2*np.pi*np.arange(3*N,4*N))/N)).astype(np.float64))/20
tn5 = ((np.sin(multiple*(2*np.pi*np.arange(4*N,5*N))/N)).astype(np.float64))/20
tn6 = ((np.sin(multiple*(2*np.pi*np.arange(5*N,6*N))/N)).astype(np.float64))/20
tn7 = ((np.sin(multiple*(2*np.pi*np.arange(6*N,7*N))/N)).astype(np.float64))/20
tn8 = ((np.sin(multiple*(2*np.pi*np.arange(7*N,8*N))/N)).astype(np.float64))/20
tn9 = ((np.sin(multiple*(2*np.pi*np.arange(8*N,9*N))/N)).astype(np.float64))/20
tn10 = ((np.sin(multiple*(2*np.pi*np.arange(9*N,10*N))/N)).astype(np.float64))/20
shiftreg = [1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1]
fixtwids = make_fix_twiddle(2**16,18,17) #18 bit twiddle factor that uses even rounding
fixtwids = bitrevfixarray(fixtwids,fixtwids.data.size)
for i in range(iters):
#keeps track of the processes
processes = []
#This is done so that we re-generate new noise vectors every time
sig1.from_complex(tn1 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig2.from_complex(tn2 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig3.from_complex(tn3 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig4.from_complex(tn4 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig5.from_complex(tn5 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig6.from_complex(tn6 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig7.from_complex(tn7 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig8.from_complex(tn8 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig9.from_complex(tn9 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig10.from_complex(tn10 + ((np.random.normal(size=N,scale = 0.3)).astype(np.float64)/5000))
sig = [sig1,sig2,sig3,sig4,sig5,sig6,sig7,sig8,sig9,sig10]
t = time.time()
for j in range(10):
print(j)
FFT(j,sig[j],fixtwids,shiftreg.copy(),22,22,18)
print("Time taken: ", time.time()-t)
np.save("F_ENGINEdump_"+str(i),np.sum(resultarray,axis=1))