Skip to content

Commit

Permalink
Merge pull request #35 from rdemaria/test_malte
Browse files Browse the repository at this point in the history
Test malte
  • Loading branch information
rdemaria authored Sep 29, 2020
2 parents b0b611b + 28461da commit e334e77
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sixdeskdb/davsturns.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def mk_da_vst(data,seed,tune,turnsl,turnstep,emitx,emity,regemi):
ajsimp_s=np.array([55/24.,-1/6.,11/8.])#Simpson rule
ajsimp_e=np.array([11/8.,-1/6.,55/24.])
warnsimp=True

for it in np.arange(turnstep,tmax+turnstep,turnstep):
mta=get_min_turn_ang(s,t,a,it)
mta_angle=mta['angle']*np.pi/180#convert to rad
Expand Down Expand Up @@ -900,7 +901,7 @@ def RunDaVsTurns(db,force,outfile,outfileold,turnstep,davstfit,fitdat,fitdaterr,


import itertools
#import pdb

from . import tables
# new DA method for unequal emittances - MT
def RunDaVsTurns_ue(db, emittances, turnstep=100, method=1, close=True,
Expand Down
27 changes: 26 additions & 1 deletion sixdeskdb/deskdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,9 @@ def mk_da_vst_ang(self,seed,tune,turnstep):
e.g. for angmax=29+1 for divisors [1, 2, 3, 5, 6, 10]"""
RunDaVsTurnsAng(self,seed,tune,turnstep)

def get_surv(self, seed, tune=None, verbose=True):

def get_surv_tmp(self, seed, tune=None, verbose=True):

'''get survival turns from DB calculated from emitI and emitII'''

if verbose:
Expand Down Expand Up @@ -2609,6 +2611,29 @@ def get_surv(self, seed, tune=None, verbose=True):
return None


def get_surv(self, seed, tune_pair):
'''get survival turns from DB calculated from emitI and emitII'''

(tunex, tuney) = tune_pair
emit = float(self.env_var['emit'])
gamma = float(self.env_var['gamma'])
turnsl = self.env_var['turnsl']
cmd="""SELECT angle, emitx + emity,
CASE WHEN sturns1 < sturns2 THEN sturns1 ELSE sturns2 END
FROM results WHERE seed=%s AND tunex=%s AND tuney=%s AND turn_max=%s
ORDER BY angle, emitx + emity"""
cur = self.conn.cursor().execute(cmd%(seed, tunex, tuney, turnsl))
ftype = [('angle', float), ('sigma', float), ('sturn', float)]
data = np.fromiter(cur, dtype=ftype)
data['sigma'] = np.sqrt(data['sigma']/(emit/gamma))
angles = len(set(data['angle']))
try:
return data.reshape(angles, -1)
except ValueError:
print("Cannot reshape array of size %s into "%(len(data))+
"shape (%s,newaxis). Skip this seed %s!"%(angles, seed))
return None

def plot_da_vst(self,seed,tune,ldat,ldaterr,ampmin,ampmax,tmax,slog,sfit,fitndrop):
"""plot dynamic aperture vs number of turns where ldat,ldaterr is the data and
the associated error to be plotted. The data is plotted in blue and the fit in red.
Expand Down

0 comments on commit e334e77

Please sign in to comment.