Skip to content
Snippets Groups Projects
Commit f21f1be6 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

documentation moved

fix for python 2.6 (SLC6)
parent 464d0fad
No related branches found
No related tags found
No related merge requests found
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='f64', count=1) Footer=numpy.fromfile(fin, dtype=numpy.float64, 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]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment