Initial commit with all clutter
This commit is contained in:
commit
f606aac0d7
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import scipy.io.wavfile
|
||||
from matplotlib import pyplot as plt
|
||||
import numpy as np
|
||||
from scipy.signal import decimate, hilbert
|
||||
|
||||
MIX_FREQ = 1200.0
|
||||
|
||||
def render_waterfall(rate, chuck_period, samples):
|
||||
period = 1/rate
|
||||
print("Period is %s" % (period, ))
|
||||
|
||||
chunk_size = int(chuck_period / period)
|
||||
chunk_count = int(len(samples) / chunk_size)
|
||||
|
||||
print("Chunk size: %d samples" % chunk_size)
|
||||
print("Chunk count: %d" % chunk_count)
|
||||
|
||||
ffts = []
|
||||
for i in range(0, chunk_count):
|
||||
fft = np.fft.rfft(samples[i * chunk_size: (i+1) * chunk_size])
|
||||
fft = np.abs(fft)
|
||||
fft /= len(fft)
|
||||
fft = 20 * np.log10(fft)
|
||||
ffts +=[fft]
|
||||
|
||||
freqs = np.fft.rfftfreq(chunk_size, period)
|
||||
|
||||
plt.viridis()
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
cax = ax.matshow(ffts, aspect='auto', extent=(freqs[0], freqs[-1], chunk_count, 0))
|
||||
fig.colorbar(cax)
|
||||
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
rate, data = scipy.io.wavfile.read("satnogs_29407_2019-01-31T17-11-29_short.wav")
|
||||
|
||||
render_waterfall(rate, 10 * 10**-3, data)
|
||||
|
||||
phase_acc = np.arange(0, len(data))
|
||||
mix_sig = np.cos(phase_acc * 2 * np.pi * MIX_FREQ/rate)
|
||||
data = data * mix_sig
|
||||
|
||||
data = decimate(data, 20)
|
||||
data = data - np.average(data)
|
||||
data = data / np.max(np.abs(data))
|
||||
|
||||
render_waterfall(rate/20, 100 * 10**-3, data)
|
||||
|
||||
cmplx = hilbert(data)
|
||||
|
||||
phase = np.angle(cmplx) / np.pi
|
||||
|
||||
dphase = phase[:-1] - phase[1:]
|
||||
|
||||
plt.plot(dphase)
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import scipy.io.wavfile
|
||||
from matplotlib import pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
rate, data = scipy.io.wavfile.read("demod.wav")
|
||||
|
||||
data = data - np.average(data)
|
||||
data = data / np.max(np.abs(data))
|
||||
|
||||
deriv = np.abs(data[1:] - data[0:-1])
|
||||
|
||||
plt.plot(deriv)
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
File binario non mostrato.
Dopo Larghezza: | Altezza: | Dimensione: 712 KiB |
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import struct
|
||||
|
||||
from PIL import Image
|
||||
|
||||
IMG_WIDTH = 640
|
||||
|
||||
SYNC_LENGTH = 105
|
||||
SYNC_THRESH = 100
|
||||
PORCH_LENGTH = 10
|
||||
|
||||
LINE_LENGTH = SYNC_LENGTH + PORCH_LENGTH + 4 * IMG_WIDTH
|
||||
|
||||
MAX_DEV = 600
|
||||
CENTER = 1750
|
||||
MIN_FREQ = 1200
|
||||
MAX_FREQ = 2300
|
||||
|
||||
COLOR_LOW = 1500
|
||||
COLOR_HIGH = MAX_FREQ
|
||||
|
||||
def to_freq(sample):
|
||||
freq = CENTER + sample * MAX_DEV
|
||||
freq = max(MIN_FREQ, freq)
|
||||
freq = min(MAX_FREQ, freq)
|
||||
return freq
|
||||
|
||||
def to_color(sample):
|
||||
sample = (sample - 1500) / (COLOR_HIGH - COLOR_LOW)
|
||||
sample = int(sample * 255)
|
||||
sample = max(sample, 0)
|
||||
sample = min(sample, 255)
|
||||
return sample
|
||||
|
||||
def ycbcr_to_rgb(y, cb, cr):
|
||||
r = int(y + 1.402 * (cr - 128))
|
||||
g = int(y - 3.44136 * (cb - 128) - 0.714136 * (cr - 128))
|
||||
b = int(y + 1.772 * (cb - 128))
|
||||
return (r,g,b)
|
||||
|
||||
last_sync = False
|
||||
def is_sync(backlog):
|
||||
global last_sync
|
||||
count = 0
|
||||
for sample in backlog:
|
||||
if sample < COLOR_LOW:
|
||||
count += 1
|
||||
|
||||
res = False
|
||||
if count > SYNC_THRESH and not last_sync:
|
||||
res = True
|
||||
|
||||
last_sync = count > SYNC_THRESH
|
||||
return res
|
||||
|
||||
|
||||
def render_lines(line):
|
||||
pixels = [[(0,0,0)] * IMG_WIDTH, [(0,0,0)] * IMG_WIDTH]
|
||||
|
||||
# Strip porch
|
||||
porch = len(line) - SYNC_LENGTH - 4 * IMG_WIDTH
|
||||
if porch < 0:
|
||||
return pixels
|
||||
line = line[PORCH_LENGTH:]
|
||||
|
||||
for i in range(0, IMG_WIDTH):
|
||||
y0 = to_color(line[i])
|
||||
cr = to_color(line[IMG_WIDTH + i])
|
||||
cb = to_color(line[2 * IMG_WIDTH + i])
|
||||
y1 = to_color(line[3 * IMG_WIDTH + i])
|
||||
|
||||
pixels[0][i] = y0, cb, cr
|
||||
pixels[1][i] = y1, cb, cr
|
||||
|
||||
return pixels
|
||||
|
||||
def main():
|
||||
data_file = open("demod.dat", 'rb')
|
||||
|
||||
samples = []
|
||||
syncs = []
|
||||
|
||||
pixels = []
|
||||
|
||||
backlog = [0.0] * SYNC_LENGTH
|
||||
line = []
|
||||
|
||||
bytes = data_file.read(4)
|
||||
while len(bytes) == 4:
|
||||
sample = struct.unpack('f', bytes)[0]
|
||||
sample = to_freq(sample)
|
||||
samples += [sample]
|
||||
|
||||
backlog = backlog[1:] + [sample]
|
||||
|
||||
line += [sample]
|
||||
|
||||
if is_sync(backlog) or len(line) > LINE_LENGTH:
|
||||
if len(line) > SYNC_LENGTH + 4 * IMG_WIDTH:
|
||||
syncs += [1000]
|
||||
print("%d \t %d" % (len(line), len(line) - LINE_LENGTH))
|
||||
pixels += render_lines(line)
|
||||
else:
|
||||
print("Short line dropped")
|
||||
line = []
|
||||
else:
|
||||
syncs += [0]
|
||||
|
||||
bytes = data_file.read(4)
|
||||
|
||||
|
||||
plt.plot(samples)
|
||||
plt.plot(syncs)
|
||||
plt.show()
|
||||
|
||||
img = Image.new('YCbCr', (IMG_WIDTH, len(pixels)))
|
||||
img_pix = img.load()
|
||||
for x in range(0, IMG_WIDTH):
|
||||
for y in range(0, len(pixels)):
|
||||
img_pix[x,y] = pixels[y][x]
|
||||
|
||||
img = img.convert('RGB')
|
||||
|
||||
img.save('output.png')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
|
@ -0,0 +1,2 @@
|
|||
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/python2.7/site-packages/satnogs:/usr/local/lib/"
|
File diff soppresso perché troppo grande
Carica Diff
File diff soppresso perché troppo grande
Carica Diff
|
@ -0,0 +1,260 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
##################################################
|
||||
# GNU Radio Python Flow Graph
|
||||
# Title: Top Block
|
||||
# Generated: Sat Feb 16 20:51:50 2019
|
||||
##################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
import ctypes
|
||||
import sys
|
||||
if sys.platform.startswith('linux'):
|
||||
try:
|
||||
x11 = ctypes.cdll.LoadLibrary('libX11.so')
|
||||
x11.XInitThreads()
|
||||
except:
|
||||
print "Warning: failed to XInitThreads()"
|
||||
|
||||
from PyQt4 import Qt
|
||||
from gnuradio import analog
|
||||
from gnuradio import blocks
|
||||
from gnuradio import eng_notation
|
||||
from gnuradio import filter
|
||||
from gnuradio import gr
|
||||
from gnuradio import qtgui
|
||||
from gnuradio.eng_option import eng_option
|
||||
from gnuradio.filter import firdes
|
||||
from optparse import OptionParser
|
||||
import sip
|
||||
import sys
|
||||
from gnuradio import qtgui
|
||||
|
||||
|
||||
class top_block(gr.top_block, Qt.QWidget):
|
||||
|
||||
def __init__(self):
|
||||
gr.top_block.__init__(self, "Top Block")
|
||||
Qt.QWidget.__init__(self)
|
||||
self.setWindowTitle("Top Block")
|
||||
qtgui.util.check_set_qss()
|
||||
try:
|
||||
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
|
||||
except:
|
||||
pass
|
||||
self.top_scroll_layout = Qt.QVBoxLayout()
|
||||
self.setLayout(self.top_scroll_layout)
|
||||
self.top_scroll = Qt.QScrollArea()
|
||||
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
|
||||
self.top_scroll_layout.addWidget(self.top_scroll)
|
||||
self.top_scroll.setWidgetResizable(True)
|
||||
self.top_widget = Qt.QWidget()
|
||||
self.top_scroll.setWidget(self.top_widget)
|
||||
self.top_layout = Qt.QVBoxLayout(self.top_widget)
|
||||
self.top_grid_layout = Qt.QGridLayout()
|
||||
self.top_layout.addLayout(self.top_grid_layout)
|
||||
|
||||
self.settings = Qt.QSettings("GNU Radio", "top_block")
|
||||
self.restoreGeometry(self.settings.value("geometry").toByteArray())
|
||||
|
||||
|
||||
##################################################
|
||||
# Variables
|
||||
##################################################
|
||||
self.samp_rate = samp_rate = 48000
|
||||
|
||||
##################################################
|
||||
# Blocks
|
||||
##################################################
|
||||
self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
|
||||
interpolation=5263,
|
||||
decimation=12000,
|
||||
taps=None,
|
||||
fractional_bw=None,
|
||||
)
|
||||
self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_f(
|
||||
4096, #size
|
||||
firdes.WIN_BLACKMAN_hARRIS, #wintype
|
||||
0, #fc
|
||||
5263, #bw
|
||||
"", #name
|
||||
1 #number of inputs
|
||||
)
|
||||
self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
|
||||
self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
|
||||
self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)
|
||||
|
||||
if not True:
|
||||
self.qtgui_waterfall_sink_x_0_0.disable_legend()
|
||||
|
||||
if "float" == "float" or "float" == "msg_float":
|
||||
self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
|
||||
|
||||
labels = ['', '', '', '', '',
|
||||
'', '', '', '', '']
|
||||
colors = [0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0]
|
||||
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.0, 1.0, 1.0]
|
||||
for i in xrange(1):
|
||||
if len(labels[i]) == 0:
|
||||
self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
|
||||
else:
|
||||
self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
|
||||
self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
|
||||
self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
|
||||
|
||||
self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)
|
||||
|
||||
self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
|
||||
self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
|
||||
self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
|
||||
4096, #size
|
||||
firdes.WIN_BLACKMAN_hARRIS, #wintype
|
||||
0, #fc
|
||||
samp_rate, #bw
|
||||
"", #name
|
||||
1 #number of inputs
|
||||
)
|
||||
self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
|
||||
self.qtgui_waterfall_sink_x_0.enable_grid(False)
|
||||
self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)
|
||||
|
||||
if not True:
|
||||
self.qtgui_waterfall_sink_x_0.disable_legend()
|
||||
|
||||
if "complex" == "float" or "complex" == "msg_float":
|
||||
self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
|
||||
|
||||
labels = ['', '', '', '', '',
|
||||
'', '', '', '', '']
|
||||
colors = [0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0]
|
||||
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.0, 1.0, 1.0]
|
||||
for i in xrange(1):
|
||||
if len(labels[i]) == 0:
|
||||
self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
|
||||
else:
|
||||
self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
|
||||
self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
|
||||
self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
|
||||
|
||||
self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)
|
||||
|
||||
self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
|
||||
self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
|
||||
self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
|
||||
1024, #size
|
||||
5263, #samp_rate
|
||||
"", #name
|
||||
1 #number of inputs
|
||||
)
|
||||
self.qtgui_time_sink_x_0.set_update_time(0.10)
|
||||
self.qtgui_time_sink_x_0.set_y_axis(-3.2, 3.2)
|
||||
|
||||
self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
|
||||
|
||||
self.qtgui_time_sink_x_0.enable_tags(-1, True)
|
||||
self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
|
||||
self.qtgui_time_sink_x_0.enable_autoscale(False)
|
||||
self.qtgui_time_sink_x_0.enable_grid(False)
|
||||
self.qtgui_time_sink_x_0.enable_axis_labels(True)
|
||||
self.qtgui_time_sink_x_0.enable_control_panel(False)
|
||||
self.qtgui_time_sink_x_0.enable_stem_plot(False)
|
||||
|
||||
if not True:
|
||||
self.qtgui_time_sink_x_0.disable_legend()
|
||||
|
||||
labels = ['', '', '', '', '',
|
||||
'', '', '', '', '']
|
||||
widths = [1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1]
|
||||
colors = ["blue", "red", "green", "black", "cyan",
|
||||
"magenta", "yellow", "dark red", "dark green", "blue"]
|
||||
styles = [1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1]
|
||||
markers = [-1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1]
|
||||
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.0, 1.0, 1.0]
|
||||
|
||||
for i in xrange(1):
|
||||
if len(labels[i]) == 0:
|
||||
self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
|
||||
else:
|
||||
self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
|
||||
self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
|
||||
self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
|
||||
self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
|
||||
self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
|
||||
self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
|
||||
|
||||
self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
|
||||
self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
|
||||
self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
|
||||
1, 12000, 1000, 1000, firdes.WIN_HAMMING, 6.76))
|
||||
self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
|
||||
self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (127, ), 1750, samp_rate)
|
||||
self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/sebastian/projects/satnogs/sstv/satnogs_29412_2019-02-01T16-20-03_short.wav', False)
|
||||
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
|
||||
self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, 'demod.dat', False)
|
||||
self.blocks_file_sink_0.set_unbuffered(False)
|
||||
self.analog_nbfm_rx_0 = analog.nbfm_rx(
|
||||
audio_rate=samp_rate/4,
|
||||
quad_rate=samp_rate/4,
|
||||
tau=75e-6,
|
||||
max_dev=600,
|
||||
)
|
||||
|
||||
|
||||
|
||||
##################################################
|
||||
# Connections
|
||||
##################################################
|
||||
self.connect((self.analog_nbfm_rx_0, 0), (self.low_pass_filter_0, 0))
|
||||
self.connect((self.blocks_throttle_0, 0), (self.hilbert_fc_0, 0))
|
||||
self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0))
|
||||
self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
|
||||
self.connect((self.hilbert_fc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
|
||||
self.connect((self.hilbert_fc_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
|
||||
self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
|
||||
self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_file_sink_0, 0))
|
||||
self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
|
||||
self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.settings = Qt.QSettings("GNU Radio", "top_block")
|
||||
self.settings.setValue("geometry", self.saveGeometry())
|
||||
event.accept()
|
||||
|
||||
def get_samp_rate(self):
|
||||
return self.samp_rate
|
||||
|
||||
def set_samp_rate(self, samp_rate):
|
||||
self.samp_rate = samp_rate
|
||||
self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate)
|
||||
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
|
||||
|
||||
|
||||
def main(top_block_cls=top_block, options=None):
|
||||
|
||||
from distutils.version import StrictVersion
|
||||
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
|
||||
style = gr.prefs().get_string('qtgui', 'style', 'raster')
|
||||
Qt.QApplication.setGraphicsSystem(style)
|
||||
qapp = Qt.QApplication(sys.argv)
|
||||
|
||||
tb = top_block_cls()
|
||||
tb.start()
|
||||
tb.show()
|
||||
|
||||
def quitting():
|
||||
tb.stop()
|
||||
tb.wait()
|
||||
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
|
||||
qapp.exec_()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Caricamento…
Fai riferimento in un nuovo problema