def onSimDelete(self, event): print(" ") print("delete DB with "+self.sim) my.sql('delete from halo where sim="'+self.sim+'"'); my.sql('delete from sim where name="'+self.sim+'"'); my.sql('delete from snapshot where sim="'+self.sim+'"'); my.done()
print("read in successful") def count_shared(m1,m2): cc = 0 # print("count") for i in range(len(m1)): if m1[i] in m2: cc += 1 return cc print("find particles shared by halo_in_1, halo_in_2") # create sparse matrix of particles shared by each halo with each other M = zeros([alm1,alm2],int) for i in range(alm1): for j in range(alm2): M[i,j]=count_shared(split1[i],split2[j]) if(M[i,j]>0): print(i,j,M[i,j]) print("search progenitor (most particles shared)") # find progenitor (most particles shared) for i in range(alm1): maxi = 0; maxj = i for j in range(alm2): if(M[i,j]>maxi): maxi = M[i,j] maxj = j my.sql("update halo set proghid="+str(maxj)+" where snap="+str(snap1) +" and hid="+str(i)) print(i, maxj, maxi)
# update MySQL table snapshot after AHF run # (c) 2014 ETHZ, Pascal Steger, [email protected] import sys import lib.initialize as my startsnap = int(sys.argv[1]) stopsnap = int(sys.argv[2]) curhid = 1 for nc in range(stopsnap - startsnap + 1): nsnap = stopsnap - nc print('number of snapshot = ', nsnap) if (len(my.sql("select snap from halo where snap=" + str(nsnap))) == 0): print("missing snapshot") my.sql("update snapshot set " + "xm=-1,ym=-1,zm=-1,rm=-1," + "xms=-1,yms=-1,zms=-1,rms=-1," + "atime=now() " + "where snap=" + str(nsnap)) curhid = 1 continue o = my.sql("select xs,ys,zs,rvir,xs_star,ys_star,zs_star,rs_star,proghid" + " from halo " + "where snap=" + str(nsnap) + " and hid=" + str(curhid)) x = o[0][0] y = o[0][1] z = o[0][2] r = o[0][3] xs = o[0][4]
# update MySQL table snapshot after AHF run # (c) 2014 ETHZ, Pascal Steger, [email protected] import sys import lib.initialize as my startsnap = int(sys.argv[1]) stopsnap = int(sys.argv[2]) curhid=1 for nc in range(stopsnap-startsnap+1): nsnap=stopsnap-nc print('number of snapshot = ',nsnap) if(len(my.sql("select snap from halo where snap="+str(nsnap)))==0): print("missing snapshot") my.sql("update snapshot set "+ "xm=-1,ym=-1,zm=-1,rm=-1,"+ "xms=-1,yms=-1,zms=-1,rms=-1,"+ "atime=now() "+ "where snap="+str(nsnap)) curhid=1 continue o=my.sql("select xs,ys,zs,rvir,xs_star,ys_star,zs_star,rs_star,proghid" +" from halo " +"where snap="+str(nsnap) +" and hid="+str(curhid)) x=o[0][0]; y=o[0][1]; z=o[0][2]; r=o[0][3]; xs=o[0][4];ys=o[0][5];zs=o[0][6];rs=o[0][7];proghid=o[0][8]
def count_shared(m1,m2): cc = 0 for i in range(len(m1)): if m1[i] in m2: cc = cc + 1 return cc ## \fn count_shared(m1,m2) # count common elements in arrays m1 and m2 # @param m1 array1 # @param m2 array2 print("find particles shared by halo_in_1, halo_in_2") # create sparse matrix of particles shared by each halo with each other M = zeros([alm,alm],int) for i in range(alm): for j in range(alm): M[i,j]=count_shared(split[i],split[j]) if(M[i,j]!=0): print(i,j,M[i,j]) print("search host (most particles shared)") for i in range(alm): maxi = 0; maxj = i for j in range(alm): if(M[i,j]>maxi): maxi = M[i,j] maxj = j my.sql("update halo set hosthid="+str(maxj)+" where snap="+str(snap) +" and hid="+str(i)) print(i, maxj, maxi)