Skip to content

Instantly share code, notes, and snippets.

View m3x1m0m's full-sized avatar

Maximilian Stiefel m3x1m0m

  • Uppsala, Sweden
View GitHub Profile
#!/usr/bin/python
import sys, getopt, csv
class iftop_parser:
def __init__(self, fname, edge_ip, radiohead_ip):
self.fname = fname
self.edge_ip = edge_ip
self.radiohead_ip = radiohead_ip
import scipy
def remove_zeroes_in_msg_stream(stream, start_of_msg, end_of_msg):
filtered = []
num_msg = 0
state="ZEROES"
for b in stream:
if state == "ZEROES":
if b != 0:
if b != start_of_msg: # this should not happen
@m3x1m0m
m3x1m0m / taps
Created April 27, 2018 11:11
Some test taps form grc
restype,fir
fs,1920000.0
pbend,100000.0
gain,1.0
sbstart,120000.0
filttype,lpf
ripple,1.0
atten,40.0
wintype,6
ntaps,139
@m3x1m0m
m3x1m0m / numpy_filter_issue.grc
Created April 27, 2018 11:09
Problem with numpy and a deisgned filter
<?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.12'?>
<flow_graph>
<timestamp>Wed Mar 21 15:50:27 2018</timestamp>
<block>
<key>options</key>
<param>
<key>author</key>
<value></value>
</param>
@m3x1m0m
m3x1m0m / qfd.py
Last active March 22, 2018 18:21
Trying out some filter design with scipy.
#!/usr/bin/python
# Inspired by http://mpastell.com/2010/01/18/fir-with-scipy/
import sys, getopt
import numpy as np
from pylab import *
import scipy.signal as signal
from pathlib import Path
import csv
@m3x1m0m
m3x1m0m / carriers_to_chunks_mem_efficiency.cc
Last active March 16, 2018 16:27
carriers_to_chunks_mem_efficiency.cc
std::vector<std::pair<int,int> > d_chunks;
std::vector<std::pair<int,int> >::iterator chunks_it;
d_chunks.push_back(std::make_pair(0, 0));// Group carriers to chunks
chunks_it = d_chunks.end() - 1;
if ( chunks_it->second == carrier - 1) {
chunks_it->second = carrier;
std::cout << "Extending chunk. Carrier: " << carrier << std::endl;
} else {
d_chunks.push_back(std::make_pair(carrier, carrier));
std::cout << "New chunk. Carrier: " << carrier << std::endl;
@m3x1m0m
m3x1m0m / gist:9963fe5fd764e44cae1c0a6b4d1b055d
Created March 15, 2018 13:52
002gnuradio_fft_ifft_scaling
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Top Block
# Generated: Thu Mar 15 14:47:40 2018
##################################################
from gnuradio import blocks
from gnuradio import eng_notation
@m3x1m0m
m3x1m0m / nbiot_ofdm_visualisation.py
Last active December 17, 2022 19:34
Playing arround with plotting OFDM carriers with matplotlib
from matplotlib import pyplot as plt
import numpy as np
from scipy.optimize import fsolve
from matplotlib.ticker import EngFormatter
def get_lobe(carrier, df, x_init, ncarriers=12,):
"Calculating the side lobe signal strength."
# Sinc function is by default scaled with pu cos is not
carrier = carrier - ncarriers/2
func = lambda z : np.sinc(z) - np.cos(z*np.pi)