Example #1
0
  def fromFort(self, order=6, filename='fort.18', nbProc=1):
    ietall = -1

    dct = {}
    fdct = {}

    for line in open(filename):
      sline = split(line)
      l = len(sline)

      if l == 8 or l == 9:
        coef = float(sline[1])
        if l == 8:
          a = [int(sline[3]), int(sline[4]), int(sline[5]), int(sline[6]), int(sline[7])]
        else:
          a = [int(sline[3]), int(sline[4]), int(sline[5]), int(sline[6]), int(sline[7]), int(sline[8])]
        if sum(a) <= order:
          dct[tuple(a)] = coef

      if "etall" in line:
        if ietall >= 0:
          p = pol(order=order)
          p.fromdict(dct, XYZD)
          fdct[XYZD[ietall]] = p
          dct = {}
        ietall += 1

    p = pol()
    p.fromdict(dct, XYZD)
    fdct[XYZD[ietall]] = p
    self.update(fdct)
Example #2
0
    def fromFort(self, order=6, filename='fort.18'):
        ietall = -1

        dct = {}
        fdct = {}

        for line in open(filename):
            sline = split(line)
            l = len(sline)

            if l == 8 or l == 9:
                coef = float(sline[1])
                if l == 8:
                    a = [
                        int(sline[3]),
                        int(sline[4]),
                        int(sline[5]),
                        int(sline[6]),
                        int(sline[7])
                    ]
                else:
                    a = [
                        int(sline[3]),
                        int(sline[4]),
                        int(sline[5]),
                        int(sline[6]),
                        int(sline[7]),
                        int(sline[8])
                    ]
                if sum(a) <= order:
                    dct[tuple(a)] = coef

            if "etall" in line:
                if ietall >= 0:
                    p = pol(order=order)
                    p.fromdict(dct, XYZD)
                    fdct[XYZD[ietall]] = p
                    dct = {}
                ietall += 1

        p = pol()
        p.fromdict(dct, XYZD)
        fdct[XYZD[ietall]] = p
        self.update(fdct)
Example #3
0
 def fromTwissObject2(self, t, terr=None, order=6, nbProc=1, fmultipole=0, strpl=True):
   if terr is None:
     _s = mapbeamline.constructMapFromTwissObject2(t, order, nbProc, fmultipole, strpl)
   else:
     _s = mapbeamline.constructMapFromTwissObjectWithErr2(t, terr, order, nbProc, fmultipole, strpl) 
   s =  _s.split("|")
   fdct = {}
   for i in range(0, len(s) - 1, 2):
     fdct[str(s[i])] = pol(s[i + 1].strip(" \t\n()[]"), order=order)
   self.update(fdct)
   self.reorder(XYZD)
Example #4
0
 def fromTwissObject(self, t, terr=None, order=6, nbProc=1, fmultipole=0, strpl=True):
   if terr is None:
     _d = mapbeamline.constructMapFromTwissObject(t, order, nbProc, fmultipole, strpl)
   else:
     _d = mapbeamline.constructMapFromTwissObjectWithErr(t, terr, order, nbProc, fmultipole, strpl)
   fdct = {}
   for key, value in _d.iteritems():
     p = pol(0, order=order)
     p.fromdict(value, XYZD)
     fdct[key] = p
   self.update(fdct)
   self.reorder(XYZD)
Example #5
0
 def fromTwissObject2(self,
                      t,
                      terr=None,
                      order=6,
                      nbProc=1,
                      fmultipole=0,
                      strpl=True):
     if terr is None:
         _s = mapbeamline.constructMapFromTwissObject2(
             t, order, nbProc, fmultipole, strpl)
     else:
         _s = mapbeamline.constructMapFromTwissObjectWithErr2(
             t, terr, order, nbProc, fmultipole, strpl)
     s = _s.split("|")
     fdct = {}
     for i in range(0, len(s) - 1, 2):
         fdct[str(s[i])] = pol(s[i + 1].strip(" \t\n()[]"), order=order)
     self.update(fdct)
     self.reorder(XYZD)
Example #6
0
 def fromTwissObject(self,
                     t,
                     terr=None,
                     order=6,
                     nbProc=1,
                     fmultipole=0,
                     strpl=True):
     if terr is None:
         _d = mapbeamline.constructMapFromTwissObject(
             t, order, nbProc, fmultipole, strpl)
     else:
         _d = mapbeamline.constructMapFromTwissObjectWithErr(
             t, terr, order, nbProc, fmultipole, strpl)
     fdct = {}
     for key, value in _d.iteritems():
         p = pol(0, order=order)
         p.fromdict(value, XYZD)
         fdct[key] = p
     self.update(fdct)
     self.reorder(XYZD)