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
e419f93b
Commit
e419f93b
authored
6 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
fix for when lattice file is in different subfolder
and a little import cleaning
parent
4481e319
No related branches found
No related tags found
No related merge requests found
Pipeline
#5824
passed
6 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ess/lib_tw.py
+13
-10
13 additions, 10 deletions
ess/lib_tw.py
with
13 additions
and
10 deletions
ess/lib_tw.py
+
13
−
10
View file @
e419f93b
...
...
@@ -18,9 +18,7 @@ from struct import pack
from
itertools
import
chain
from
subprocess
import
check_output
from
os
import
system
from
os.path
import
isdir
,
isfile
from
sys
import
exit
import
os
,
sys
from
.lib_tw_elem
import
*
...
...
@@ -37,7 +35,7 @@ class LATTICE:
'''
:param file_name_lat: name of lattice file
:type file_name_lat: str
:param file_name_fmap: list of fi
l
e map file(-s)
:param file_name_fmap: list of fie
ld
map file(-s)
:type file_name_fmap: list or str
:param freq: RF frequency
:type freq: float
...
...
@@ -46,7 +44,8 @@ class LATTICE:
'''
# In case file_name_fmap is str
if
isinstance
(
file_name_fmap
,
str
):
file_name_fmap
=
[
file_name_fmap
]
if
isinstance
(
file_name_fmap
,
str
):
file_name_fmap
=
[
file_name_fmap
]
# Elem/comm class dict
dic_cls
=
{
'
DRIFT
'
:
DRIFT
,
...
...
@@ -81,8 +80,12 @@ class LATTICE:
# Field map dict
dic_fmap
=
{}
for
file_name_fmap_i
in
file_name_fmap
:
name_fmap
=
'
.
'
.
join
(
file_name_fmap_i
.
split
(
'
/
'
)[
-
1
].
split
(
'
.
'
)[:
-
1
])
# Remove / and exten
t
ion
name_fmap
=
'
.
'
.
join
(
file_name_fmap_i
.
split
(
'
/
'
)[
-
1
].
split
(
'
.
'
)[:
-
1
])
# Remove / and exten
s
ion
dic_fmap
[
name_fmap
]
=
FIELD_MAP_DATA
(
file_name_fmap_i
)
# In case the lattice file is in a different folder:
basefolder
=
os
.
path
.
dirname
(
file_name_lat
)
if
basefolder
:
_update_field_map_dict
(
dic_fmap
,
basefolder
)
# Go through the lat file
with
open
(
file_name_lat
)
as
file
:
...
...
@@ -361,9 +364,9 @@ class PROJECT:
if
self
.
flag_hide
!=
None
:
opt_exe
+=
'
hide
'
## if self.path_cal!=None:
## if isdir(self.path_cal)==False: system('mkdir '+self.path_cal)
## if
os.
isdir(self.path_cal)==False: system('mkdir '+self.path_cal)
system
(
opt_exe
)
os
.
system
(
opt_exe
)
#---- Data related
...
...
@@ -889,7 +892,7 @@ def loss_elem2den(s,loss,file_name_dt='',dlt_dt=5e-6):
return
loss_den
exit
()
sys
.
exit
()
# Define L
l
=
[
s
[
i
+
1
]
-
s
[
i
]
for
i
in
range
(
len
(
s
)
-
1
)];
l
.
insert
(
0
,
0.0
)
...
...
@@ -917,7 +920,7 @@ def loss_elem2den(s,loss,file_name_dt='',dlt_dt=5e-6):
if
l
[
i
]
==
0.0
and
loss
[
i
]
!=
0.0
:
if
i
==
1
:
print
(
'
The 1st elem has 0 length and yet has a loss, exiting...
'
)
exit
()
sys
.
exit
()
else
:
k
=
1
while
l
[
i
-
k
]
==
0.0
:
k
+=
1
...
...
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