Skip to content

Instantly share code, notes, and snippets.

View veeresht's full-sized avatar
🤓

Veeresh Taranalli veeresht

🤓
View GitHub Profile
@veeresht
veeresht / read_svhn_mat.py
Created July 21, 2016 23:38
Read SVHN Dataset mat (version 7.3) files using h5py and numpy
import numpy as np
import h5py
def read_process_h5(filename):
""" Reads and processes the mat files provided in the SVHN dataset.
Input: filename
Ouptut: list of python dictionaries
"""
@veeresht
veeresht / test_viterbi.py
Created May 14, 2012 22:05
Example usage of viterbi_decode in CommPy
import numpy as np
import commpy.channelcoding.convcode as cc
memory = np.array([2])
g_matrix = np.array([[05, 07]])
feedback = 00
trellis = cc.Trellis(memory, g_matrix)
msg = np.random.randint(0, 2, 10)
coded_bits = cc.conv_encode(msg, trellis)
@veeresht
veeresht / frequency_offset.py
Created April 2, 2012 03:58
Simulation of Frequency Offset in Single Carrier and OFDM Systems
from numpy import real, imag, arange
from numpy.fft import fft, ifft
from numpy.random import randint
from commpy.modulation import QAMModem
from commpy.impairments import add_frequency_offset
import matplotlib.pyplot as plt
# System Parameters
# Sampling Frequency (Hz)
Fs = 15.36e6
@veeresht
veeresht / trellis_example.py
Created March 21, 2012 00:28
Example of plotting a Trellis Diagram using CommPy
from numpy import array
from commpy.channelcoding import Trellis
# Define the number of memory elements
# per input in the convolutional encoder
memory = array([2])
# Define the generator matrix of
# the convolutional encoder
# Entries are in octal format
@veeresht
veeresht / MAP_Decoder_Simulation.py
Created March 5, 2012 04:32
MAP Decoder simulation
from numpy import array, arange, power, log10, zeros, sqrt
from numpy.random import randint, randn
from commpy.channelcoding import turbo_encode, map_decode, Trellis
from commpy.utilities import hamming_dist
total_bits = 1000000
block_size = 1000
num_blocks = total_bits/block_size
# Noise Variance