Beispiel #1
0
 def open(cls,fn):
   try:
     if fn.endswith('tfs.gz'):
       return cls(tfsdata.load(gzip.open(fn)))
     elif fn.endswith('tfs'):
       if os.path.exists(fn):
         return cls(tfsdata.open(fn))
       elif os.path.exists(fn+'.gz'):
         return cls(tfsdata.load(gzip.open(fn+'.gz')))
     else:
       return cls(tfsdata.open(fn))
     raise IOError
   except IOError:
     raise IOError,"%s does not exists or wrong format" % fn
Beispiel #2
0
 def open(cls, fn):
     try:
         if fn.endswith('tfs.gz'):
             return cls(tfsdata.load(gzip.open(fn)))
         elif fn.endswith('tfs'):
             if os.path.exists(fn):
                 return cls(tfsdata.open(fn))
             elif os.path.exists(fn + '.gz'):
                 return cls(tfsdata.load(gzip.open(fn + '.gz')))
         else:
             return cls(tfsdata.open(fn))
         raise IOError
     except IOError:
         raise IOError, "%s does not exists or wrong format" % fn
Beispiel #3
0
 def open(cls, filename, twissfile=None):
     self = cls(**tfsdata.open(filename))
     self.filename = filename
     if twissfile is not None:
         self.twiss = optics.open(twissfile)
     self.twissfile = twissfile
     return self
Beispiel #4
0
 def reload(self):
   if 'filename' in self._data:
      fdate=os.stat(self.filename).st_ctime
      if fdate>self._fdate:
        self._data=tfsdata.open(self.filename)
        self._fdate=fdate
        return True
   return False
Beispiel #5
0
 def reload(self):
     if 'filename' in self._data:
         fdate = os.stat(self.filename).st_ctime
         if fdate > self._fdate:
             self._data = tfsdata.open(self.filename)
             self._fdate = fdate
             return True
     return False
Beispiel #6
0
 def __init__(self,dynapfn,nangles=7,nsigma=12,label='dynap'):
   self.label=label.replace('_',' ')
   t=tfsdata.open(dynapfn)
   self.tunx=t['tunx']
   self.tuny=t['tuny']
   self.tx=t['x']
   self.ty=t['y']
   self.nangles=nangles
   self.nsigma=nsigma
Beispiel #7
0
 def __init__(self, dynapfn, nangles=7, nsigma=12, label='dynap'):
     self.label = label.replace('_', ' ')
     t = tfsdata.open(dynapfn)
     self.tunx = t['tunx']
     self.tuny = t['tuny']
     self.tx = t['x']
     self.ty = t['y']
     self.nangles = nangles
     self.nsigma = nsigma
Beispiel #8
0
 def __init__(self, base, nangles=7, nsigma=12):
     self.base = base
     self.label = base.replace('_', ' ')
     dynapfn = os.path.join(base, 'dynaptune.tfs')
     t = tfsdata.open(dynapfn)
     self.tunx = t['tunx']
     self.tuny = t['tuny']
     self.tx = t['x']
     self.ty = t['y']
     self.nangles = nangles
     self.nsigma = nsigma
Beispiel #9
0
 def __init__(self,base,nangles=7,nsigma=12):
   self.base=base
   self.label=base.replace('_',' ')
   dynapfn=os.path.join(base,'dynaptune.tfs')
   t=tfsdata.open(dynapfn)
   self.tunx=t['tunx']
   self.tuny=t['tuny']
   self.tx=t['x']
   self.ty=t['y']
   self.nangles=nangles
   self.nsigma=nsigma
Beispiel #10
0
 def open(cls,fn):
     data=tfsdata.open(fn)
     data['filename']=fn
     return cls(**data)
Beispiel #11
0
 def open(cls, fn):
     obj = cls(tfsdata.open(fn))
     return obj
Beispiel #12
0
import sys; sys.path.append('../')

import sixtracklib
import numpy as np

from scipy.constants import c as c_light
pmass_eV = 938.272046e6

V_RF = 10e6
lag_deg = 180
h_RF = 35000


import tfsdata

twdict = tfsdata.open('twiss.out')

machine = sixtracklib.CBlock()

p0c_eV = 450e9
gamma0 = np.sqrt(p0c_eV**2+pmass_eV**2)/pmass_eV
beta0 = p0c_eV/np.sqrt(p0c_eV**2+pmass_eV**2)

length = twdict['param']['length'] 
f_RF = h_RF*c_light*beta0/(length)

# I want to start in a place with 0 dispersion
start_at = 'AT_IP5'
i_start = np.where(twdict['name']==start_at)[0][0]

indices = range(i_start, len(twdict['name']))+range(0, i_start)
Beispiel #13
0
 def open(cls,fn):
   obj=cls(tfsdata.open(fn))
   return obj