diff --git a/sixdeskdb/deskdb.py b/sixdeskdb/deskdb.py index aac2ffcd..2d0da035 100644 --- a/sixdeskdb/deskdb.py +++ b/sixdeskdb/deskdb.py @@ -778,7 +778,7 @@ def load_extra(self): cur = conn.cursor() # env_var = self.env_var basedir = self.basedir - cur.execute("begin IMMEDIATE transaction") + #cur.execute("begin IMMEDIATE transaction") sql = """SELECT path,content from files""" cur.execute(sql) files = cur.fetchall() @@ -808,6 +808,7 @@ def load_extra(self): else: f.write(decompressBuf(str(file[1]))) f.close() + cur.commit() def load_mad6t_run(self): ''' load mad runs from DB ''' @@ -883,7 +884,7 @@ def load_mad6t_results(self): conn = self.conn cur = conn.cursor() env_var = self.env_var - cur.execute("begin IMMEDIATE transaction") + #cur.execute("begin IMMEDIATE transaction") sql = """SELECT * from mad6t_results""" cur.execute(sql) forts = cur.fetchall() @@ -927,6 +928,7 @@ def load_mad6t_results(self): f.close() else: print('fort.16_%s.gz was not created at %s',(seed,path)) + cur.commit() def load_six_beta(self): '''load general_input,betavalues and sixdesktunes from DB''' @@ -936,7 +938,7 @@ def load_six_beta(self): cur = conn.cursor() env_var = self.env_var path = os.path.join(env_var['sixdesktrack'],self.LHCDescrip) - cur.execute("begin IMMEDIATE transaction") + #cur.execute("begin IMMEDIATE transaction") sql = """SELECT * from six_beta""" cur.execute(sql) beta = cur.fetchall() @@ -985,6 +987,7 @@ def load_six_beta(self): f = open(temp,'w') f.write(stri) f.close() + cur.commit() def load_six_input_results(self): '''load fort.3 and fort.10 files from DB ''' @@ -994,7 +997,7 @@ def load_six_input_results(self): cur = conn.cursor() env_var = self.env_var path = os.path.join(env_var['sixdesktrack'],self.LHCDescrip) - cur.execute("begin IMMEDIATE transaction") + #cur.execute("begin IMMEDIATE transaction") sql = """SELECT * from six_input""" cur.execute(sql) six = cur.fetchall() @@ -1037,6 +1040,7 @@ def load_six_input_results(self): f = gzip.open(temp,'w') f.write(stri) f.close() + cur.commit() def get_missing_fort10(self): '''get input values for which fort.10 is not present ''' @@ -1747,6 +1751,7 @@ def read10b(self): turnse=self.env_var['turnse'] ns1l=self.env_var['ns1l'] ns2l=self.env_var['ns2l'] + nsincl = self.env_var['nsincl'] Elhc,Einj = self.execute('SELECT emitn,gamma from six_beta LIMIT 1')[0] angles=self.get_db_angles() seeds=self.get_db_seeds() @@ -1756,7 +1761,8 @@ def read10b(self): LHCDescrip=self.LHCDescrip for tunex,tuney in self.get_tunes(): anumber=1 - sql1='SELECT %s FROM results WHERE betx>0 AND bety>0 AND emitx>1e-10 AND emity>1e-10 AND turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l) + #sql1='SELECT %s FROM results WHERE betx>0 AND bety>0 AND emitx>1e-10 AND emity>1e-10 AND turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l) + sql1='SELECT %s FROM results WHERE turn_max=%d AND amp1>=%s AND amp1<=%s'%(names,turnsl,ns1l,ns2l) sixdesktunes="%s_%s"%(tunex,tuney) sql1+=' AND tunex=%s AND tuney=%s '%(tunex,tuney) for angle in angles: @@ -1775,12 +1781,17 @@ def read10b(self): achaos = 0. achaos1 = 0. sql=sql1+' AND seed=%s '%seed - #sql+=' AND ROUND(angle,5)=ROUND(%s,5) '%angle sql+=' AND angle=%s '%angle - sql+=' ORDER BY emitx+emity ' + sql+=' ORDER BY amp1+%g*row_num'%(nsincl/pairs/10) #ordering based on file (10 ordering only) if self.debug: print(sql) inp=np.array(self.execute(sql),dtype=rectype) + zerotest=np.where(inp['betx']==0)[0] # remove everything from first zero line + truncated=False + if len(zerotest)>0: + truncated=True + izerotest=zerotest[0] + inp=inp[:izerotest] if self.debug: print(inp.shape) if len(inp)==0: @@ -1804,10 +1815,6 @@ def read10b(self): turn_max=inp['turn_max'].max() amp2=inp['amp2'][-1] row_num=inp['row_num'][-1] - if row_numzero) & (emitx>zero) #yidx=(bety>zero) & (emity>zero) @@ -1876,6 +1883,8 @@ def read10b(self): alost2test=np.where((sturns10: ialost2=alost2test[0] + if ialost2>0: + ialost2-=1 #last stable particle alost2=rad*sigx1[ialost2] icount=1. if iin != -999 and iend == -999 : iend=iel diff --git a/sixdeskdb/sqltable.py b/sixdeskdb/sqltable.py index 7c35d298..1ddaf401 100644 --- a/sixdeskdb/sqltable.py +++ b/sixdeskdb/sqltable.py @@ -93,8 +93,8 @@ def insert(self,data,replace=True): else: sql="INSERT INTO %s(%s) VALUES (%s)" cur=db.cursor() - if dbtype == "sql": - cur.execute("begin IMMEDIATE transaction") + #if dbtype == "sql": + # cur.execute("begin IMMEDIATE transaction") if len(data) == 0: return cols=','.join(data.dtype.names) @@ -111,8 +111,8 @@ def insertl(self,data,artype="?",replace=True): else: sql="INSERT INTO %s VALUES (%s)" cur=db.cursor() - if dbtype == "sql": - cur.execute("begin IMMEDIATE transaction") + #if dbtype == "sql": + # cur.execute("begin IMMEDIATE transaction") if len(data) == 0: return #if not isinstance(data[0], list): diff --git a/test/simple/job_hllhc10_test8.db b/test/simple/job_hllhc10_test8.db index b30dd559..d89c2801 100644 Binary files a/test/simple/job_hllhc10_test8.db and b/test/simple/job_hllhc10_test8.db differ