if __name__ == '__main__': usage = "usage: %prog [options] filename" version = "%prog 1.0" parser = OptionParser(usage=usage, version=version) parser.add_option("-o", "--outlier", type="int", dest="outlier", default=10, help="% fuel change to indicate an outlier (optional, default 10)") parser.add_option("-d", "--dump", action="store_true", dest="dump", default=False, help="dump map to screen (optional, default off)") parser.add_option("-q", "--minrpm", type="choice", choices=[str(rpm) for rpm in mapmod.RPM], dest="minrpm", default='500', help="minimum rpm to check (optional, default 500)") parser.add_option("-r", "--maxrpm", type="choice", choices=[str(rpm) for rpm in mapmod.RPM], dest="maxrpm", default='18000', help="maximum rpm to check (optional, default 18,000)") parser.add_option("-s", "--mintps", type="choice", choices=[str(tps) for tps in mapmod.TPS], dest="mintps", default='0', help="minimum tps to check (optional, default 0)") parser.add_option("-t", "--maxtps", type="choice", choices=[str(tps) for tps in mapmod.TPS], dest="maxtps", default='100', help="maximum tps to check (optional, default 100)") (options, args) = parser.parse_args() if len(args) != 1: parser.error("missing map filename") filename = args[0] original_map = mapmod.read_map_file(filename) if options.dump: mapmod.dump_map(original_map) check_map(original_map, options.outlier, mapmod.rpm_to_pos(int(options.minrpm)), mapmod.rpm_to_pos(int(options.maxrpm)), mapmod.tps_to_pos(int(options.mintps)), mapmod.tps_to_pos(int(options.maxtps)))
parser.add_option("-s", "--mintps", type="choice", choices=[str(tps) for tps in mapmod.TPS], dest="mintps", default='0', help="minimum tps to smooth (optional, default 0)") parser.add_option("-t", "--maxtps", type="choice", choices=[str(tps) for tps in mapmod.TPS], dest="maxtps", default='100', help="maximum tps to smooth (optional, default 100)") (options, args) = parser.parse_args() if len(args) != 1: parser.error("missing map filename") filename = args[0] original_map = mapmod.read_map_file(filename) new_map = smooth_map(original_map, options.weight, options.iterations, mapmod.rpm_to_pos(int(options.minrpm)), mapmod.rpm_to_pos(int(options.maxrpm)), mapmod.tps_to_pos(int(options.mintps)), mapmod.tps_to_pos(int(options.maxtps))) if options.dump: mapmod.dump_map(original_map, "original") mapmod.dump_map(new_map, "new") head,tail = os.path.split(filename) newfilename = os.path.join(head, "smooth_"+tail) mapmod.save_map(filename, newfilename, new_map) print "New map file saved as %s" % newfilename