#!/usr/bin/env python3 # Note: this utility can run under python2.7 or python3 program = 'vdiffold' author = 'Walter Brisken' version = '0.7' verdate = '20211004' from os import system from sys import exit, argv def printVersion(): print('%s ver. %s %s %s' % (program, version, author, verdate)) def usage(): print('') printVersion() print('') 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 known to work on 2-bit real data for now;\n') print('by the nature of the functionality, this cannot work on\n') print('1-bit data\n') if '--version' in argv: printVersion() exit() if len(argv) < 9: usage() exit() infile = argv[1] framesize = int(argv[2]) datarate = int(argv[3]) threadlist = argv[4] nt = len(threadlist.split(',')) nbin = int(argv[5]) nint = int(argv[6]) freq = argv[7] outfile = argv[8] if len(argv) > 9: offset = int(argv[9]) else: offset = 0 if len(argv) > 10: nbit = int(argv[10]) else: nbit = 2 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 | m5fold - VDIF_%d-%d-%d-%d %d %d %s %s' % (infile, framesize, framespersecond, threadlist, offset, outputpayload, outputdatarate, nc, nbit, nbin, nint, freq, outfile) print('Executing: %s' % cmd) system(cmd)