A quick-and-dirty script to generate data to feed to R. Typical usage: 2000 100000 2000 5

writes a script of commands starting from 2000 ohms incrementing by 2000 ohms up to 100,000 ohms at a tolerance of 5%. It then executes the generated script which writes the raw data to a default file named r_finder.dat.

import argparse
import os
import stat
import subprocess

parser = argparse.ArgumentParser()
parser.add_argument('start', type=int,
                    help='Starting resistance')
parser.add_argument('end', type=int,
                    help='Ending resistance')
parser.add_argument('stride', type=int,
                    help='Stride value e.g. 1, 3, 5, . . . has stride 2')
parser.add_argument('tolerance', type=float,
                    help='Tolerance of solution')
args = parser.parse_args()
start = args.start
end = args.end
stride = args.stride
tolerance = args.tolerance

file_name = "./"
outfile = open(file_name, "w")

for i in range(start, end, stride):
    outfile.write("./ %d %f --record > /dev/null 2>&1\n" % (i, tolerance))

os.chmod(file_name, stat.S_IRWXU|stat.S_IRWXG|stat.S_IRWXO)