Ejemplo n.º 1
0
 def onGenSpheres(self, event):
     nstart, nstop = mys.get_range()
     for nc in range(nstop - nstart + 1):
         nsnap = nc + nstart
         if (not mys.snap_exists(nsnap)):
             continue
         d = mys.d(nsnap)
         my.mkdir(d + "dm")
         if (not mys.is_dmonly()):
             my.mkdir(d + "stars")
         cmd = "cd " + d + " && gen_spheres.py " + str(nsnap) + " 1"
         my.run(cmd)
     my.done()
Ejemplo n.º 2
0
 def onGenSpheres(self, event):
     nstart,nstop=mys.get_range()
     for nc in range(nstop-nstart+1):
         nsnap = nc + nstart
         if(not mys.snap_exists(nsnap)):
             continue
         d  = mys.d(nsnap)
         my.mkdir(d+"dm")
         if(not mys.is_dmonly()):
             my.mkdir(d+"stars");
         cmd = "cd "+d+" && gen_spheres.py "+str(nsnap)+" 1"
         my.run(cmd)
     my.done()
Ejemplo n.º 3
0
 def onRunR2G(self, event):
     nstart, nstop = mys.get_range()
     print('nstart, nstop = ', nstart, nstop)
     for nc in range(nstop - nstart + 1):
         nsnap = nc + nstart
         print('nsnap = ', nsnap)
         if (not mys.snap_exists(nsnap)):
             continue
         d = mys.d(nsnap)
         my.mkdir(d + "/r2g")
         if (mys.is_dmonly()):
             cmd = "mpirun -np 8 r2g -d " + d
         else:
             cmd = "mpirun -np 8 r2g -i " + d
         print(cmd)
         my.thread(cmd)
     self.SetBackgroundColour("darkgreen")
     my.done()
Ejemplo n.º 4
0
 def onRunR2G(self, event):
     nstart,nstop=mys.get_range()
     print('nstart, nstop = ', nstart, nstop)
     for nc in range(nstop-nstart+1):
         nsnap = nc + nstart
         print('nsnap = ', nsnap)
         if(not mys.snap_exists(nsnap)):
             continue
         d = mys.d(nsnap)
         my.mkdir(d+"/r2g")
         if(mys.is_dmonly()):
             cmd = "mpirun -np 8 r2g -d "+d
         else:
             cmd = "mpirun -np 8 r2g -i "+d
         print(cmd)
         my.thread(cmd)
     self.SetBackgroundColour("darkgreen")
     my.done()
Ejemplo n.º 5
0
 def onShrink(self, event):
     nstart,nstop=mys.get_range()
     # have xs,xs_star set in the end
     for nc in range(nstop-nstart+1):
         nsnap = nc + nstart
         if(not mys.snap_exists(nsnap)):
             continue
         print(mys.get_nhalo(nsnap))
         for i in range(3):#range(mys.get_nhalo(nsnap)):
             if(not mys.exists_snap(nsnap)):
                 print("snapshot "+str(nsnap)+" missing")
                 continue
             cmd = "shrink_sphere.py "+str(nsnap)+" "+str(i+1)
             my.run(cmd)
             if(not mys.is_dmonly()):
                 cmd = "shrink_sphere_stars.py "+str(nsnap)+" "+str(i+1)
                 my.run(cmd)
             # TODO: if empty xs (shrinking sphere algorithm did not succeed: use xc)
     my.done()
Ejemplo n.º 6
0
 def onShrink(self, event):
     nstart, nstop = mys.get_range()
     # have xs,xs_star set in the end
     for nc in range(nstop - nstart + 1):
         nsnap = nc + nstart
         if (not mys.snap_exists(nsnap)):
             continue
         print(mys.get_nhalo(nsnap))
         for i in range(3):  #range(mys.get_nhalo(nsnap)):
             if (not mys.exists_snap(nsnap)):
                 print("snapshot " + str(nsnap) + " missing")
                 continue
             cmd = "shrink_sphere.py " + str(nsnap) + " " + str(i + 1)
             my.run(cmd)
             if (not mys.is_dmonly()):
                 cmd = "shrink_sphere_stars.py " + str(nsnap) + " " + str(
                     i + 1)
                 my.run(cmd)
             # TODO: if empty xs (shrinking sphere algorithm did not succeed: use xc)
     my.done()
Ejemplo n.º 7
0
    def OnPlot(self, event):
        print("plot")
        f=1 # scaling of sphere wrt rvir
        vis  = True; show = True; run  = True;
        my.mkdir(mys.simdir()+"/ana")
        ddm  = mys.simdir() + "/ana/dm/";    my.mkdir(ddm)
        dgas = mys.simdir() + "/ana/gas/";   my.mkdir(dgas)
        dstar= mys.simdir() + "/ana/stars/"; my.mkdir(dstar)
        dpd  = mys.simdir() + "/phasediag/"; my.mkdir(dpd)
        nstart,nstop=mys.get_range()
        x,y,z,r,snap=mys.getxyzrsnap(nstop)#TODO: nstart,nstop
        xs,ys,zs,rs,snap=mys.getxyzrsnap_stars(nstart,nstop)
        #x,y,z,r,snap=mys.mt_xyzrsnap(nstart,nstop)
        #xs,ys,zs,rs,snap=mys.mt_xyzrsnap_stars(nstart,nstop)
        for i in range(nstop-nstart+1):
            nc = nstop-i
            if(not mys.snap_exists(nc)):
                continue
            stri=str(nc).zfill(5)
            print("nc = ",nc)
            print(x[i], xs[i])
            print(y[i], ys[i])
            print(z[i], zs[i])
            print(r[i], rs[i])
            d = mys.d(nc)
            # scale
            if self.fix:
                r[i]=0.002; rs[i]=0.002;

            sx = str(x[i])
            sy = str(y[i])
            sz = str(z[i])
            sr = str(r[i])
            ssx= str(sx[i])
            ssy= str(ys[i])
            ssz= str(sz[i])
            ssr= str(rs[i])
            lma = str(mys.get_lma())
            bndry  = " "+sx+" "+sy+" "+sz+" "+sr+" "
            bndryc =" -xc "+sx+" -yc "+sy+" -zc "+sz+" -rc "+sr+" "

            #calc all pix, dep. on which option was clicked
            if self.radio==0:
                print("gas density")
                ofname = dgas+"gas_boxall_"+stri+".png"
                cmd1 = amr2map+" -typ 1 -lma "+lma+" -inp "+d+" -out "+dgas+"gas_boxall_"+stri
                cmd1 = cmd1 +".dat -dir z "+bndryc
                cmd2 = "map2img.py -l --colormap=hot "+dgas+"gas_boxall_"+stri+".dat "
                cmd2 = cmd2+"-o "+ofname+" && xview "+ofname
                print(dgas+"gas_boxall_"+stri+".png")
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==1:
                print("gas pressure")
                if(mys.is_dmonly()):
                    print("not available, dm only simulation!")
                    exit
                cmd1 = amr2map + " -typ 5 -lma "+lma+" -inp "+d
                cmd1 = cmd1+" -out "+dgas+"p_"+stri+".dat "+"-dir z "+bndryc
                cmd2 = "map2img.py -l --colormap=hot "+dgas+"p_"+stri+".dat "
                ofname = dgas+"p_"+stri+".png"
                cmd2 = cmd2+" -o "+ofname+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==2:
                print("gas temperature")
                cmd1 = amr2map+" -typ 18 -lma "+lma+" -inp "+d
                cmd1 = cmd1+" -out "+dgas+"temp_"+stri+".dat "+"-dir z "+bndryc
                cmd2 = "map2img.py -l --colormap=hot "+dgas+"temp_"+stri+".dat "
                ofname = dgas+"temp_"+stri+".png"
                cmd2 = cmd2+" -o "+ofname+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==3:
                print("DM contours")
                # get DM particle positions for each halo
                cmd1 = "get_sphere_dm -inp "+d+bndryc+" > "+ddm+"dm_"+stri+".dat"
                cmd1+= "&& octreef "+ddm+"dm_"+stri+".dat > "+ddm+"rho_"+stri+".dat"
                cmd2 ="vis_part_proj_dm.py "+bndry+" "\
                       +ddm+"dm_"+stri+".dat "+ddm+"dm_part_"+stri+".png"
                ofname=ddm+"rho_"+stri+".dat "+ddm+"contour_"+stri+".png"
                cmd2+="; vis_dm_contour.py "+bndry+" "\
                       +ofname+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==4:
                print("metallicity")
                #cmd = "vis_parts.py stars.part"
                #cmd = "get_sphere_stars -inp "+d\
                #+" -xc "+sx+" -yc "+sy+" -zc "+sz+" -r "+sr+">ana/stars/stars_"+stri
                cmd1 = "metal2map -inp "+d+" -out "+dstar+"stars_"+stri+".dat "
                cmd1 = cmd1+"-nx 512 -ny 512 -dir z "+bndryc
                cmd2 = "map2img.py -l --colormap=jet "+dstar+"stars_"+stri+".dat "
                ofname = dstar+"stars_"+stri+".png"
                cmd2 = cmd2+"-o "+ofname+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==5:
                print("phase diagram")
                fn = dpd+"temp_"+str(nc).zfill(5)
                cmd1 = "get_temp -inp "+d+" -out "+fn
                cmd1+=  " -lma "+lma+" -typ 18"
                ofname=fn+".png"
                cmd2 = "plot_temp_rho.py "+fn+" "+ofname+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==6:
                print("rho_dm(r)")
                cmd1 = "gen_prof_dm.py "+str(nc)+" "+sx+" "+sy+" "+sz+" "+sr;
                ofname = ddm+"prof_"+stri+".png "
                cmd2 = "plot_prof_sph.py "+ddm+"prof_"+stri+".dat "\
                       +ddm+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" "+str(mys.get_z(nc))+"&& xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)


            if self.radio==7:
                print("rho_gas(r)")
                cmd1 = "gen_prof_gas.py "+str(nc)+" "+sx+" "+sy+" "+sz+" "+sr+" "+lma;
                ofname = dgas+"prof_"+stri+".png "
                cmd2 = "plot_prof_sph.py "+dgas+"prof_"+stri+".dat "\
                       +dgas+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)


            if self.radio==8:
                print("rho_star(r)")
                cmd1 = "gen_prof_stars.py "+str(nc)+" "+sx+" "+sy+" "+sz+" "+sr;
                ofname = dstar+"prof_"+stri+".png "
                cmd2 = "plot_prof_sph.py "+dstar+"prof_"+stri+".dat "\
                       +dstar+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" && xview "+ofname
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if self.radio==9:
                print("SFR")
                cmd1 = "count_stars -inp "+d+bndryc+" >> "+dstar+"star_counts.dat"
                #cmd2 = "plot_columns.py star_counts.dat 1 4"
                cmd2 = "calc_sfr.py "+dstar+"star_counts.dat 0 4"
                my.threadif(cmd1,cmd2,self.calc,vis,show,run)

            if(not self.loop):
                break
        my.done()
Ejemplo n.º 8
0
    def OnPlot(self, event):
        print("plot")
        f = 1  # scaling of sphere wrt rvir
        vis = True
        show = True
        run = True
        my.mkdir(mys.simdir() + "/ana")
        ddm = mys.simdir() + "/ana/dm/"
        my.mkdir(ddm)
        dgas = mys.simdir() + "/ana/gas/"
        my.mkdir(dgas)
        dstar = mys.simdir() + "/ana/stars/"
        my.mkdir(dstar)
        dpd = mys.simdir() + "/phasediag/"
        my.mkdir(dpd)
        nstart, nstop = mys.get_range()
        x, y, z, r, snap = mys.getxyzrsnap(nstop)  #TODO: nstart,nstop
        xs, ys, zs, rs, snap = mys.getxyzrsnap_stars(nstart, nstop)
        #x,y,z,r,snap=mys.mt_xyzrsnap(nstart,nstop)
        #xs,ys,zs,rs,snap=mys.mt_xyzrsnap_stars(nstart,nstop)
        for i in range(nstop - nstart + 1):
            nc = nstop - i
            if (not mys.snap_exists(nc)):
                continue
            stri = str(nc).zfill(5)
            print("nc = ", nc)
            print(x[i], xs[i])
            print(y[i], ys[i])
            print(z[i], zs[i])
            print(r[i], rs[i])
            d = mys.d(nc)
            # scale
            if self.fix:
                r[i] = 0.002
                rs[i] = 0.002

            sx = str(x[i])
            sy = str(y[i])
            sz = str(z[i])
            sr = str(r[i])
            ssx = str(sx[i])
            ssy = str(ys[i])
            ssz = str(sz[i])
            ssr = str(rs[i])
            lma = str(mys.get_lma())
            bndry = " " + sx + " " + sy + " " + sz + " " + sr + " "
            bndryc = " -xc " + sx + " -yc " + sy + " -zc " + sz + " -rc " + sr + " "

            #calc all pix, dep. on which option was clicked
            if self.radio == 0:
                print("gas density")
                ofname = dgas + "gas_boxall_" + stri + ".png"
                cmd1 = amr2map + " -typ 1 -lma " + lma + " -inp " + d + " -out " + dgas + "gas_boxall_" + stri
                cmd1 = cmd1 + ".dat -dir z " + bndryc
                cmd2 = "map2img.py -l --colormap=hot " + dgas + "gas_boxall_" + stri + ".dat "
                cmd2 = cmd2 + "-o " + ofname + " && xview " + ofname
                print(dgas + "gas_boxall_" + stri + ".png")
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 1:
                print("gas pressure")
                if (mys.is_dmonly()):
                    print("not available, dm only simulation!")
                    exit
                cmd1 = amr2map + " -typ 5 -lma " + lma + " -inp " + d
                cmd1 = cmd1 + " -out " + dgas + "p_" + stri + ".dat " + "-dir z " + bndryc
                cmd2 = "map2img.py -l --colormap=hot " + dgas + "p_" + stri + ".dat "
                ofname = dgas + "p_" + stri + ".png"
                cmd2 = cmd2 + " -o " + ofname + " && xview " + ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 2:
                print("gas temperature")
                cmd1 = amr2map + " -typ 18 -lma " + lma + " -inp " + d
                cmd1 = cmd1 + " -out " + dgas + "temp_" + stri + ".dat " + "-dir z " + bndryc
                cmd2 = "map2img.py -l --colormap=hot " + dgas + "temp_" + stri + ".dat "
                ofname = dgas + "temp_" + stri + ".png"
                cmd2 = cmd2 + " -o " + ofname + " && xview " + ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 3:
                print("DM contours")
                # get DM particle positions for each halo
                cmd1 = "get_sphere_dm -inp " + d + bndryc + " > " + ddm + "dm_" + stri + ".dat"
                cmd1 += "&& octreef " + ddm + "dm_" + stri + ".dat > " + ddm + "rho_" + stri + ".dat"
                cmd2 ="vis_part_proj_dm.py "+bndry+" "\
                       +ddm+"dm_"+stri+".dat "+ddm+"dm_part_"+stri+".png"
                ofname = ddm + "rho_" + stri + ".dat " + ddm + "contour_" + stri + ".png"
                cmd2+="; vis_dm_contour.py "+bndry+" "\
                       +ofname+" && xview "+ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 4:
                print("metallicity")
                #cmd = "vis_parts.py stars.part"
                #cmd = "get_sphere_stars -inp "+d\
                #+" -xc "+sx+" -yc "+sy+" -zc "+sz+" -r "+sr+">ana/stars/stars_"+stri
                cmd1 = "metal2map -inp " + d + " -out " + dstar + "stars_" + stri + ".dat "
                cmd1 = cmd1 + "-nx 512 -ny 512 -dir z " + bndryc
                cmd2 = "map2img.py -l --colormap=jet " + dstar + "stars_" + stri + ".dat "
                ofname = dstar + "stars_" + stri + ".png"
                cmd2 = cmd2 + "-o " + ofname + " && xview " + ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 5:
                print("phase diagram")
                fn = dpd + "temp_" + str(nc).zfill(5)
                cmd1 = "get_temp -inp " + d + " -out " + fn
                cmd1 += " -lma " + lma + " -typ 18"
                ofname = fn + ".png"
                cmd2 = "plot_temp_rho.py " + fn + " " + ofname + " && xview " + ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 6:
                print("rho_dm(r)")
                cmd1 = "gen_prof_dm.py " + str(
                    nc) + " " + sx + " " + sy + " " + sz + " " + sr
                ofname = ddm + "prof_" + stri + ".png "
                cmd2 = "plot_prof_sph.py "+ddm+"prof_"+stri+".dat "\
                       +ddm+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" "+str(mys.get_z(nc))+"&& xview "+ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 7:
                print("rho_gas(r)")
                cmd1 = "gen_prof_gas.py " + str(
                    nc) + " " + sx + " " + sy + " " + sz + " " + sr + " " + lma
                ofname = dgas + "prof_" + stri + ".png "
                cmd2 = "plot_prof_sph.py "+dgas+"prof_"+stri+".dat "\
                       +dgas+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" && xview "+ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 8:
                print("rho_star(r)")
                cmd1 = "gen_prof_stars.py " + str(
                    nc) + " " + sx + " " + sy + " " + sz + " " + sr
                ofname = dstar + "prof_" + stri + ".png "
                cmd2 = "plot_prof_sph.py "+dstar+"prof_"+stri+".dat "\
                       +dstar+"rho_"+stri+".dat "\
                       +ofname+sx+" "+sy+" "+sz+" && xview "+ofname
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if self.radio == 9:
                print("SFR")
                cmd1 = "count_stars -inp " + d + bndryc + " >> " + dstar + "star_counts.dat"
                #cmd2 = "plot_columns.py star_counts.dat 1 4"
                cmd2 = "calc_sfr.py " + dstar + "star_counts.dat 0 4"
                my.threadif(cmd1, cmd2, self.calc, vis, show, run)

            if (not self.loop):
                break
        my.done()