Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESS Beam Physics
ess-python-tools
Commits
32c473f2
Commit
32c473f2
authored
10 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
several changes to the shell script
many more of the options are added
parent
88187254
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tracewin
+51
-18
51 additions, 18 deletions
tracewin
with
51 additions
and
18 deletions
tracewin
+
51
−
18
View file @
32c473f2
...
...
@@ -2,23 +2,51 @@
import
argparse
import
os
import
subprocess
# This script simply runs TraceWin CLI version.
# Provides a better CLI than going through the manual
# Spelling corrections of commands..
parser
=
argparse
.
ArgumentParser
(
description
=
"
Creates a TraceWin batch command
"
)
parser
.
add_argument
(
'
-p
'
,
'
--project
'
,
dest
=
'
project
'
,
help
=
"
Project file
"
,
required
=
True
)
parser
.
add_argument
(
'
-r
'
,
dest
=
'
run
'
,
action
=
'
store_const
'
,
help
=
"
Run TraceWin (default just print command)
"
,
const
=
True
,
default
=
False
)
# path_cal
parser
.
add_argument
(
'
-o
'
,
'
--output
'
,
dest
=
'
outpath
'
,
help
=
"
Path to calculation directory
"
)
# dat_file
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
'
,
# dst_file
parser
.
add_argument
(
'
--dst_file
'
,
dest
=
'
dst_file1
'
,
help
=
"
Input distribution file of main beam
"
)
parser
.
add_argument
(
'
--dst_file2
'
,
dest
=
'
dst_file2
'
,
help
=
"
Input distribution file of secondary beam
"
)
# current
parser
.
add_argument
(
'
-c
'
,
'
--current
'
,
dest
=
'
current1
'
,
help
=
"
Beam Current of beam 1 [mA]
"
)
parser
.
add_argument
(
'
-n
'
,
'
--npart
'
,
dest
=
'
npart
'
,
parser
.
add_argument
(
'
--current2
'
,
dest
=
'
current2
'
,
help
=
"
Beam Current of beam 2 [mA]
"
)
# nbr_part
parser
.
add_argument
(
'
-np
'
,
dest
=
'
nbr_part1
'
,
help
=
"
Number of particles in beam 1
"
)
parser
.
add_argument
(
'
-e
'
,
'
--energy
'
,
dest
=
'
energy
'
,
parser
.
add_argument
(
'
-np2
'
,
dest
=
'
nbr_part2
'
,
help
=
"
Number of particles in beam 2
"
)
# energy
parser
.
add_argument
(
'
-e
'
,
'
--energy
'
,
dest
=
'
energy1
'
,
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
'
,
parser
.
add_argument
(
'
-e2
'
,
dest
=
'
energy2
'
,
help
=
"
Input beam energy for beam 2 [MeV]
"
)
# freq
parser
.
add_argument
(
'
-f
'
,
dest
=
'
freq1
'
,
help
=
"
Bunch Frequency of beam 1 [MHz]
"
)
parser
.
add_argument
(
'
-f2
'
,
dest
=
'
freq2
'
,
help
=
"
Bunch Frequency of beam 2 [MHz]
"
)
parser
.
add_argument
(
'
-s
'
,
'
--seed
'
,
dest
=
'
seed
'
,
help
=
"
Initial random seed
"
,
type
=
int
)
args
=
parser
.
parse_args
()
...
...
@@ -32,14 +60,16 @@ if not os.path.isfile(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
)
for
arg
in
[
'
dst_file1
'
,
'
dst_file2
'
,
'
current1
'
,
'
current2
'
,
'
nbr_part1
'
,
'
nbr_part2
'
,
'
energy1
'
,
'
energy2
'
,
'
freq1
'
,
'
freq2
'
]:
attr
=
getattr
(
args
,
arg
)
if
attr
:
cmd
.
append
(
arg
+
"
=
"
+
attr
)
if
args
.
outpath
:
if
not
os
.
path
.
isdir
(
args
.
outpath
):
print
"
WARNING: output directory does not exist, creating..
"
...
...
@@ -48,5 +78,8 @@ if args.outpath:
if
args
.
seed
:
cmd
.
append
(
"
random_seed=
"
+
str
(
args
.
seed
))
# For now we just print the command:
print
'
'
.
join
(
cmd
)
print
args
.
run
if
args
.
run
:
subprocess
.
call
(
cmd
)
else
:
print
'
'
.
join
(
cmd
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment