Skip to content
Snippets Groups Projects
Commit 05574607 authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Remove at from mandatory modules

Import at inside the Optics.load_from_AT method to allow use of mbtrack2 without at installed.
Update load_from_AT
parent a80ea9ab
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ parameters are defined.
@date: 10/04/2020
"""
import at
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
......@@ -100,22 +99,28 @@ class Optics:
Lattice periodicity, if not specified the AT lattice periodicity is
used.
"""
import at
self.n_points = int(kwargs.get("n_points", 1e3))
periodicity = kwargs.get("periodicity")
self.lattice = at.load_lattice(lattice_file)
if self.lattice.radiation:
self.lattice.radiation_off()
lattice = self.lattice.slice(slices=self.n_points)
refpts = np.arange(0, len(lattice))
twiss0, tune, chrom, twiss = at.get_twiss(lattice, refpts=refpts,
twiss0, tune, chrom, twiss = at.linopt(lattice, refpts=refpts,
get_chrom=True)
if periodicity is None:
self.periodicity = lattice.periodicity
else:
self.periodicity = periodicity
for i in range(self.periodicity-1):
pos = np.append(twiss.s_pos, twiss.s_pos + twiss.s_pos[-1]*(i+1))
if self.periodicity > 1:
for i in range(self.periodicity-1):
pos = np.append(twiss.s_pos, twiss.s_pos + twiss.s_pos[-1]*(i+1))
else:
pos = twiss.s_pos
self.position = pos
self.beta_array = np.tile(twiss.beta.T, self.periodicity)
......
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