From f7d07484f0b0a37b0351d30aa769b887dfe833be Mon Sep 17 00:00:00 2001
From: Yngve Inntjore Levinsen <Yngve.Levinsen@esss.se>
Date: Tue, 28 Oct 2014 11:14:57 +0100
Subject: [PATCH] added tracewin script (to execute batch tracewin)

---
 setup.py |  1 +
 tracewin | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 tracewin

diff --git a/setup.py b/setup.py
index 0a4fb19..925a23c 100644
--- a/setup.py
+++ b/setup.py
@@ -6,4 +6,5 @@ setup(name='Yngve Tools',
       author='Yngve Inntjore Levinsen',
       author_email='yngve.levinsen@esss.se',
       packages=['ess'],
+      scripts=['tracewin'],
      )
diff --git a/tracewin b/tracewin
new file mode 100644
index 0000000..5dd5383
--- /dev/null
+++ b/tracewin
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import argparse
+import os
+parser = argparse.ArgumentParser(description="Creates a TraceWin batch command")
+
+parser.add_argument('-p', '--project', dest='project',
+        help="Project file", required=True)
+parser.add_argument('-l', '--lattice', dest='lattice',
+        help="Lattice/structure file (.dat) to use")
+parser.add_argument('-f', '--freq', dest='frequency',
+        help="Bunch Frequency of beam 1 [MHz]")
+parser.add_argument('-c', '--current', dest='current',
+        help="Beam Current of beam 1 [mA]")
+parser.add_argument('-n', '--npart', dest='npart',
+        help="Number of particles in beam 1")
+parser.add_argument('-e', '--energy', dest='energy',
+        help="Input beam energy for beam 1 [MeV]")
+parser.add_argument('-o', '--output', dest='outpath',
+        help="Path to calculation directory")
+parser.add_argument('-r', '--seed', dest='seed',
+        help="Initial random seed", type=int)
+
+args = parser.parse_args()
+
+# A list to be filled depending on arguments given...
+cmd = ["TraceWin64_noX11", "'"+args.project+"'"]
+
+if args.lattice:
+    cmd.append("dat_file="+args.lattice)
+if args.frequency:
+    cmd.append("freq1="+args.lattice)
+if args.current:
+    cmd.append("current1="+args.current)
+if args.npart:
+    cmd.append("npart1="+args.npart)
+if args.energy:
+    cmd.append("energy1="+args.energy)
+if args.outpath:
+    cmd.append("path_cal='"+os.path.abspath(args.outpath)+"'")
+if args.seed:
+    cmd.append("random_seed="+str(args.seed))
+
+# For now we just print the command:
+print ' '.join(cmd)
-- 
GitLab