def __init__(self, file): self.d = dfile(file) X_set = [] Y_set = [] Z_set = [] Zrel_set = [] Em_set = [] X = [] Y = [] Z = [] Zrel = [] Em = [] old_index = 0 for l in self.d.data: i = l['i'] xval = l['z'] yval = l['r'] zval = l['psi'] zvalr = l['psirel'] Emval = l['Em'] if i == old_index: X_set.append(xval) Y_set.append(yval) Z_set.append(zval) Zrel_set.append(zvalr) Em_set.append(Emval) elif X_set != []: X.append(X_set) Y.append(Y_set) Z.append(Z_set) Zrel.append(Zrel_set) Em.append(Em_set) X_set = [xval] Y_set = [yval] Z_set = [zval] Zrel_set = [zvalr] Em_set = [Emval] old_index = i else: old_index = i X_set.append(xval) Y_set.append(yval) Z_set.append(zval) Zrel_set.append(zvalr) Em_set.append(Emval) # add last data set X.append(X_set) Y.append(Y_set) Z.append(Z_set) Zrel.append(Zrel_set) Em.append(Em_set) self.X = np.array(X) self.Y = np.array(Y) self.Z = np.array(Z) self.Zrel = np.array(Zrel) self.Em = np.array(Em) self.ncont = 21 self.v = np.linspace(self.Z.min(), self.Z.max(), self.ncont) self.vrel = np.linspace(self.Zrel.min(), self.Zrel.max(), self.ncont)
def __init__(self, file, fast=True): # using the fast option does not use the datafile module # it is much faster that way but less general if fast: self.data = open(file).readlines()[1:] else: self.d = dfile(file) self.orbits = [] new_orbit = [] counter = 0 if fast: for l in self.data: f = list(map(float, l.split())) x = f[1] * np.cos(f[2]) y = f[1] * np.sin(f[2]) # this creates an x, y, z, r, phi, z, ... array # f[1:] to skip the step number r = [x, y, f[3]] + f[1:] data = np.array(r) if f[0] == 1: counter += 1 print("add orbit ", counter) if new_orbit != []: self.orbits.append(np.vstack(new_orbit)) new_orbit = [] new_orbit.append(data) else: for l in self.d.data: dt = ([\ l['r'], l['phi'],\ l['z'], l['vr'], l['vphi'], l['vz'],\ l['br'], l['bphi'], l['bz']\ ]) x = l['r'] * np.cos(l['phi']) y = l['r'] * np.sin(l['phi']) # this creates an x, y, z, r, phi, z, ... array r = [x, y, l['z']] data = np.array(r + dt) if l['step'] == 1: counter += 1 print("add orbit ", counter) if new_orbit != []: self.orbits.append(np.vstack(new_orbit)) new_orbit = [] new_orbit.append(data) # add the last orbit counter += 1 print("add last orbit ") self.orbits.append(np.vstack(new_orbit)) # all data have been read self.counter = counter - 1 print("total of : ", self.counter, " orbits loaded !")
# SIMC locations, this should not change SIMCDIR = '/data/boeglin.1/HallC/simc_gfortran.1/' # use new simc simc_command = SIMCDIR + './simc' SIMCINDIR = './infiles/' SIMCOUTDIR = './outfiles/' SIMCRESDIR = './worksim/' # create the correct scipt for the interactive input to simc cc = open('./run_simc', 'w') cc.write('current.data\n') cc.close() # open the kinematics file kin_d = dfile(KINDIR + kin_list) ext1 = 'data' # read the header if radiate: ext2 = 'rad' extra_file = 'extra_hydrogen_rad.data' extra_ext = '.dat' else: ext2 = 'norad' extra_file = 'extra_hydrogen_norad.data' extra_ext = '_norad.dat' for k in kin_d.data: # setup file names from kin_list.data file
def __init__(self, file_name='tilted_tile.data'): self.file = file_name self.td = DF.dfile(self.file) self.r_pos = np.array(self.td.get_data_list('x:y:z')).T self.r = np.sqrt(self.r_pos[0, :]**2 + self.r_pos[1, :]**2) self.rotate(0.)
orbit_dir = output_root + machine + output_dir_ext + input_file orbit_output = open(orbit_dir + '/orbit_output').readlines() # find the EQ file used: eq_file = 'generic' for d in orbit_output: if (d.find('--> EQ File unit, name') >= 0.): eq_file = d.split()[-1:][0] # flux print('reading flux data') fl = gf.flux(orbit_dir + '/' + flux_data_file) print('reading flux limit data') fll_d = DF.dfile(orbit_dir + '/' + flux_limiter_file) r_fll = np.array(fll_d.get_data('xlim')) z_fll = np.array(fll_d.get_data('ylim')) # limiter print('reading limiter data') li = gl.limiter(orbit_dir + '/limiter_drawing.data') #orbits print('reading orbits data') o = go.orbit(orbit_dir + '/orbits.data', fast=True) # draw side view if draw_top_view: f1 = pl.figure(1, figsize=(11, 6)) else: f1 = pl.figure(1, figsize=(5, 8))