0
import numpy as np

from random import seed
from random import random
from random import gauss
import matplotlib.pyplot as plt

import time
import sys


#################################################################################################################

k_B = 1.38064852e-23    # Boltzman constant
T = 260         # Ambient temperature in kelvin
R = 50          # Resistance in ohm
B = 2e+7        # Bandwidth of receiver in Hz
n_F = 1.5       # Noise figure of the amplifier (with SNR being considered in dB)
G = 50          # Gain of the amplifier in dB

#################################################################################################################

dt_w = 100e-9       # window interval --> 100 ns
dt = 4e-9           # Sampling interval --> Half of Earlier (2ns) -> 1ns --> Sampling Rate = 1000 MHz
ss = 1      # Sample size --> 1 sec

N_S = int(ss/dt)    # Distribution size 
N_W = int(dt_w/dt) #- 1     # Size of 1 window interval     ## Make sure that "Window size is in EVEN number of datapoints"
print(" N_W : ", N_W)
N_A = 90        # Number of receiving channels

dt_D_1 = 1e-6       # First delay time after trigger ~ 1 us
dt_D_2 = 1e-3       # Second delay time after trigger ~ 1 ms

N_D = int((dt_D_1/dt) + (dt_D_2/dt))


#################################################################################################################

V = (np.sqrt(4*k_B*T*R*B))  # Noise generated at the in-put of amplifier    # Internal noise

V_rms = (V * G * 10**(n_F/10)) * 1e+3       # in mV



################################################################################################################

h = 2.7   ###############   # h value need to be probed
print(" h : ", h)
V_Th = h*V_rms          # Threshold Voltage
print(f"    V_Th : {V_Th} mV")

################################################################################################################

P_Th = (V_Th)**2        # Threshold Power
print(f"    P_Th : {P_Th} mW.ohm")

#################################################################################################################
def my_filter(f, n, dt):    # n=len(f)


    fhat = np.fft.rfft(f, n)
    freq = np.fft.rfftfreq(n,dt)

    for k in range(len(fhat)):

        if( ( freq[k] <  3e+7) or (freq[k] > 8e+7) ):
            #print(np.round(freq[k]//(1e+6)))
            fhat[k] = fhat[k] * 0.0
            #print(fhat[k])

    F = np.fft.irfft(fhat)

    return F

#################################################################################################################
def Trigger(V1, P_T, N1):       # N1 = N_W  # N2 = N_A = single antenna

    Trigger = 0

    if ( ( (np.array(abs(V1))) >= P_T).any() ):
        print(" ")
        print(" V_Th : ", P_T)
        print(" ")
        print(" V1_Triggered : ", np.array(abs(V1)) )

        Trigger = 1

    return Trigger
#################################################################################################################
seconds = int(time.time())
print(" Seed :  ", seconds)
print(" ")
print(" ")
seed(seconds)
#################################################################################################################


fk = 0      # counting number
N_T = 0     # Number of Triggers



i = 0
n_max = 0   # dilemma here ?? # 0 or 1 ??
k = 0
Q = []
V_G = []
N_WW = 0
while(fk < N_S):

    Q = np.float32( gauss(0, V_rms) )   # working

#   Q = [number**2 for number in Q]
    V_G.append(Q)

#   Q.clear()

    n_max = len(V_G)

    if(n_max == N_W):   # Here were some problems   ## Please look here ## condition is revised

        N_WW = N_WW + 1

        V_F = my_filter(V_G, N_W, dt)   # Filtered voltage
#       print(abs(V_F))
        T = Trigger(V_F, V_Th, N_W) # P_Th instead of V_Th
#       break
        if(T == 1):

#           n_max = 0
            V_G.clear()

            fk = fk + N_D

            N_T = N_T + 1


        else:

            fk = fk + 1
#           n_max = n_max - 1

            del V_G[0]



    elif(n_max < N_W):
#       n_max = n_max + 1
        fk = fk + 1

#####################################################################################################
    percentage = np.round(((fk/N_S)*100), 3)


    sys.stdout.write('\r')  

    sys.stdout.write(str(percentage))
    sys.stdout.write(" %    ")
    sys.stdout.write("  Number of Triggers =    ")
    sys.stdout.write(str(N_T))
    sys.stdout.write("  ")
#####################################################################################################

print(" ")
print(" compilation completed ")
print(" ")
print(f"    Total number of Triggers = {N_T} ")
print(" ")
print(" ")

So, I want to generate a discrete time series of band-limited (30-80 MHz) white noise which shall be independent of sampling frequency (provided Nyquist frequency is greater than 100 MHz).

The amplitude (Voltage) distribution is "Gaussian" over the desired frequency band (30-80 MHz). So, I have kept the sigma of the Gaussian distribution as "V_RMS" which is proportional to sqrt(Band-width).

Thereafter, I have been checking "triggering rate" for a time window of 100 ns. I have been sending the data of each 100 ns time window through a filter prior to the trigger checking (with V_TH).

For band-limited noise this "Triggering Rate" shall be independent of the sampling frequency (or, "dt"), Right?

On contrary, I am still observing a stringent dependence of "Trigger Rate" with sampling frequency (or, "dt").

I might be making some logical or conceptual mistake which I may not know about.

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58

0 Answers0