#!/usr/bin/env python program = 'vdifd' author = 'Walter Brisken' version = '0.3' verdate = '20160610' from os import system from string import split from sys import exit, argv def usage(): print '\n%s ver. %s %s %s\n' % (program, version, author, verdate) print 'A VDIF decoder for multi-thread, single channel VDIF data. Uses vmux' print 'and m5d to do the heavy lifting.\n' print 'Usage : %s [ [] ]\n' % program print ' is the name of the VDIF file\n' print ' is the size of each input VDIF frame, inc. header (e.g., 5032)\n' print ' is the stream data rate (Mbps)\n' print ' is the number of samples per channel to decode\n' print ' optionally jump into input file by this many bytes\n' print ' is number of bits per sample (default is 2)\n' print 'Note: Only works on 2-bit real data for now...\n' if len(argv) < 6: usage() exit() infile = argv[1] framesize = int(argv[2]) datarate = int(argv[3]) threadlist = argv[4] nt = len(split(threadlist, ',')) n = int(argv[5]) if len(argv) > 6: nbit = int(argv[6]) else: nbit = 2 if len(argv) > 7: offset = int(argv[7]) else: offset = 0 nc = 1 while(nc < nt): nc *= 2 outputpayload = nc*(framesize-32) framespersecond = (datarate*1000000)/(nt*(framesize-32)*8) outputdatarate = outputpayload*framespersecond*8/1000000 cmd = 'vmux %s %d %d %s - %d %d | m5d - VDIF_%d-%d-%d-%d %d' % (infile, framesize, framespersecond, threadlist, offset, nbit, outputpayload, outputdatarate, nc, nbit, n) print 'Executing: %s' % cmd system(cmd)