From 00e307ff827229c6f86021b846a9ff1ddf0c5e55 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 12 Feb 2013 15:16:44 +0100 Subject: scripts/csv2sto.py: Allow to scale y values as well --- scripts/csv2sto.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/csv2sto.py b/scripts/csv2sto.py index c43a990..d212494 100755 --- a/scripts/csv2sto.py +++ b/scripts/csv2sto.py @@ -14,6 +14,7 @@ import numpy as np DEFAULT_NAME = 'control' DEFAULT_MAXTIME = 100.0 +DEFAULT_MAXY = 50.0 def usage(): print("""usage: {} [OPTION...] CSV-FILE... STO-FILE @@ -22,12 +23,13 @@ def usage(): -m NAMES use names from comma-separated list NAMES to name muscles instead of CSV file name (# of names in list must match # of CSV files) -n name of the activation data in sto file (default: {}) - -T N scale time such that it goes from 0.0 to N + -T N scale time into range 0.0 to N + -Y N scale y values into range 0.0 to N -h show this help and exit""".format(os.path.basename(sys.argv[0]), DEFAULT_NAME)) def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "fm:n:hT:") + opts, args = getopt.getopt(sys.argv[1:], "fm:n:hT:Y:") except getopt.GetoptError as err: print(str(err)) usage() @@ -41,6 +43,7 @@ def main(): muscles = None name = DEFAULT_NAME maxtime = DEFAULT_MAXTIME + maxy = DEFAULT_MAXY for o, a in opts: if o == '-f': overwrite = True @@ -50,6 +53,8 @@ def main(): name = a elif o == '-T': maxtime = float(a) + elif o == '-Y': + maxy = float(a) elif o == '-h': usage() sys.exit(0) @@ -99,7 +104,9 @@ def main(): print("Writing sto file {} with name {} ({} muscles)".format(f_sto, name, len(fs_csv))) if maxtime != DEFAULT_MAXTIME: - print("Scaling to maxtime {}".format(maxtime)) + print("Scaling to max. time {}".format(maxtime)) + if maxy != DEFAULT_MAXY: + print("Scaling to max. y {}".format(maxy)) fd_sto = open(f_sto, 'w') fd_sto.write(name + "\n") @@ -136,6 +143,9 @@ def main(): if maxtime != DEFAULT_MAXTIME: # Assume default 0-100 time in all input files for now t = (t / 100.0) * maxtime + if maxy != DEFAULT_MAXY: + # Assume default 0-50 time in all input files for now + y = (y / 50.0) * maxy times[j,i] = t vals[j,i] = y -- cgit v1.2.3-54-g00ecf