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
f21f1be6
Commit
f21f1be6
authored
10 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
documentation moved
fix for python 2.6 (SLC6)
parent
464d0fad
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
ess/TraceWin.py
+17
-21
17 additions, 21 deletions
ess/TraceWin.py
with
17 additions
and
21 deletions
ess/TraceWin.py
+
17
−
21
View file @
f21f1be6
class
dst
:
class
dst
:
'''
Simple class to read in a
TraceWin distribution file
Class afterwards hold the following
dictionary items:
- x [cm]
- xp [rad]
- y [cm]
- yp [rad]
- phi [rad]
- E [MeV]
'''
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
'''
Simple class to read in a
TraceWin distribution file
Class afterwards hold the following
dictionary items:
- x [cm]
- xp [rad]
- y [cm]
- yp [rad]
- phi [rad]
- E [MeV]
'''
# easy storage..
# easy storage..
self
.
filename
=
filename
self
.
filename
=
filename
# used to create dict behaviour..
# used to create dict behaviour..
...
@@ -22,9 +22,7 @@ class dst:
...
@@ -22,9 +22,7 @@ class dst:
self
.
_readBinaryFile
()
self
.
_readBinaryFile
()
def
_readBinaryFile
(
self
):
def
_readBinaryFile
(
self
):
'''
# Thanks Emma!
Thanks Emma!
'''
import
numpy
import
numpy
...
@@ -46,14 +44,12 @@ class dst:
...
@@ -46,14 +44,12 @@ class dst:
Table
=
numpy
.
fromfile
(
fin
,
dtype
=
numpy
.
float64
,
count
=
self
.
Np
*
6
)
Table
=
numpy
.
fromfile
(
fin
,
dtype
=
numpy
.
float64
,
count
=
self
.
Np
*
6
)
self
.
_data
=
Table
.
reshape
(
self
.
Np
,
6
)
self
.
_data
=
Table
.
reshape
(
self
.
Np
,
6
)
Footer
=
numpy
.
fromfile
(
fin
,
dtype
=
'
f
64
'
,
count
=
1
)
Footer
=
numpy
.
fromfile
(
fin
,
dtype
=
numpy
.
float
64
,
count
=
1
)
self
.
mass
=
Footer
[
0
]
self
.
mass
=
Footer
[
0
]
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
'''
# makes the class function as a dictionary
makes the class function as a dictionary
# e.g. dst['x'] returns the x array..
e.g. dst[
'
x
'
] returns the x array..
'''
if
key
in
self
.
_columns
:
if
key
in
self
.
_columns
:
i
=
self
.
_columns
.
index
(
key
)
i
=
self
.
_columns
.
index
(
key
)
return
self
.
_data
[:,
i
]
return
self
.
_data
[:,
i
]
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