#!/usr/bin/env python program = 'vdifspec' 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 spectrometer for multi-thread VDIF data. Uses vmux' print 'and m5spec to do the heavy lifting.\n' print 'Usage : %s [nbit] []\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 spectral channels to make per baseband channel\n' print ' is the number of FFT frames to spectrometize\n' print ' is the name of the output file\n' print ' is number of bits per sample (default is 2)\n' print ' optionally jump into input file by this many bytes\n' print 'Note: Only works on 2-bit real data for now...\n' if len(argv) < 8: usage() exit() infile = argv[1] framesize = int(argv[2]) datarate = int(argv[3]) threadlist = argv[4] nt = len(split(threadlist, ',')) nchan = int(argv[5]) nint = int(argv[6]) outfile = argv[7] if len(argv) > 8: nbit = int(argv[8]) else: nbit = 2 if len(argv) > 9: offset = int(argv[9]) 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 | m5spec - VDIF_%d-%d-%d-%d %d %d %s' % (infile, framesize, framespersecond, threadlist, offset, outputpayload, outputdatarate, nc, nbit, nchan, nint, outfile) print 'Executing: %s' % cmd system(cmd)