#!/usr/bin/env python program = 'vdiffold' 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 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 bins per if across 1 period' print ' if negative, the conversion to true power is not performed\n' print ' is the number of 10000 sample chunks to work on\n' print ' [Hz] -- the inverse of the period to be folded\n' print ' is the name of the output file\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) < 9: usage() exit() infile = argv[1] framesize = int(argv[2]) datarate = int(argv[3]) threadlist = argv[4] nt = len(split(threadlist, ',')) nbin = int(argv[5]) nint = int(argv[6]) freq = argv[7] outfile = argv[8] if len(argv) > 9: nbit = int(argv[9]) else: nbit = 2 if len(argv) > 10: offset = int(argv[10]) 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 | m5fold - VDIF_%d-%d-%d-%d %d %d %s %s' % (infile, framesize, framespersecond, threadlist, offset, nbit, outputpayload, outputdatarate, nc, nbit, nbin, nint, freq, outfile) print 'Executing: %s' % cmd system(cmd)