modify README.md
This commit is contained in:
parent
78ad9071a0
commit
344c68fa0a
2
.gitignore
vendored
2
.gitignore
vendored
@ -160,3 +160,5 @@ cython_debug/
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
.png
|
||||
.gif
|
||||
|
BIN
output.gif
Normal file
BIN
output.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
39
qpsk.py
Normal file
39
qpsk.py
Normal file
@ -0,0 +1,39 @@
|
||||
import time
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from PIL import Image
|
||||
|
||||
symbol_count = 1000
|
||||
|
||||
x_integer = np.random.randint(0, 4, symbol_count) # generates random integers between 0 and 4 to fill out our symbol values. (generates a random number for each symbol in 'symbol_count')
|
||||
x_degrees = x_integer*360/4.0 + 45 # four possible angles (degrees), spaced at 45 (45, 135, 225, 315)
|
||||
x_radians = x_degrees*np.pi/180.0 # sin() and cos() both need radians, this just converts x_degrees to radians for that one use case
|
||||
x_symbols = np.cos(x_radians) + 1j*np.sin(x_radians)
|
||||
|
||||
noise_power = 0.05
|
||||
|
||||
timer = 0
|
||||
while timer < 10:
|
||||
noise = (np.random.randn(symbol_count) + 1j*np.random.randn(symbol_count))/np.sqrt(2)
|
||||
noisy_symbols = x_symbols + noise * np.sqrt(noise_power)
|
||||
plt.plot(np.real(noisy_symbols), np.imag(noisy_symbols), ',b')
|
||||
plt.grid(True)
|
||||
plt.savefig(f"{timer}.png")
|
||||
timer = timer + 1
|
||||
|
||||
def create_gif(image_paths, output_path, duration=500, loop=0):
|
||||
"""
|
||||
Creates a GIF from a list of images.
|
||||
|
||||
Args:
|
||||
image_paths (list): A list of file paths to the images.
|
||||
output_path (str): The path to save the output GIF.
|
||||
duration (int, optional): The duration of each frame in milliseconds. Defaults to 500.
|
||||
loop (int, optional): Number of times the GIF should loop. 0 means infinite loop. Defaults to 0.
|
||||
"""
|
||||
images = [Image.open(image_path) for image_path in image_paths]
|
||||
images[0].save(output_path, save_all=True, append_images=images[1:], duration=duration, loop=loop)
|
||||
|
||||
image_paths = ["0.png", "1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png", "9.png" ]
|
||||
output_path = "output.gif"
|
||||
create_gif(image_paths, output_path)
|
19
whatthefreak.py
Normal file
19
whatthefreak.py
Normal file
@ -0,0 +1,19 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Generate tone plus noise
|
||||
t = np.arange(1024*1000)/sample_rate # time vector
|
||||
f = 50e3 # freq of tone
|
||||
x = np.sin(2*np.pi*f*t)
|
||||
|
||||
# simulate the signal above, or use your own signal
|
||||
|
||||
fft_size = 1024
|
||||
num_rows = len(x) // fft_size # // is an integer division which rounds down
|
||||
spectrogram = np.zeros((num_rows, fft_size))
|
||||
for i in range(num_rows):
|
||||
spectrogram[i,:] = 10*np.log10(np.abs(np.fft.fftshift(np.fft.fft(x[i*fft_size:(i+1)*fft_size])))**2)
|
||||
|
||||
# different thingy
|
||||
|
||||
av_pwr = np.mean(np.abs(x)**2)
|
Loading…
x
Reference in New Issue
Block a user