Beispiel #1
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()
Beispiel #2
0
# (c) 2014 ETHZ, Pascal Steger, [email protected]

import sys, os
import lib.mysql as mys

i = len(sys.argv)
if i! = 6:
    print("usage: gen_prof_stars.py sim xc yc zc r")
    print("example: gen_prof_stars.py 270 0.5 0.5 0.5 0.05")
    sys.exit()

rout = 1 # * rvir from AHF for maximal radial distance to include particles from
show = True
run  = True

ddm = mys.simdir()+"/ana/stars/"
snap = sys.argv[1].zfill(5)
outp = mys.d(snap)

xc = sys.argv[2]; yc = sys.argv[3]; zc = sys.argv[4]
r = str(float(sys.argv[5])*rout)

os.nice(0)

# stars
cmd = "get_sphere_stars -inp "+outp
cmd +=" -xc "+xc+" -yc "+yc+" -zc "+zc+" -rc "+r+"> "+ddm+"stars_"+snap+".dat"
cmd += " && octreef "+ddm+"stars_"+snap+".dat > "+ddm+"rho_"+snap+".dat"
if(show): print(cmd)
if(run): os.system(cmd)
Beispiel #3
0
# (c) 2014 ETHZ, Pascal Steger, [email protected]

import sys, os
import lib.mysql as mys

i = len(sys.argv)
if i != 6:
    print("usage: gen_prof_dm.py sim xc yc zc r")
    print("example: gen_prof_dm.py 270 0.5 0.5 0.5 0.05")
    sys.exit()

rout = 1  # * rvir from AHF for maximal radial distance to include particles from
show = True
run = True

ddm = mys.simdir() + "/ana/dm/"
snap = sys.argv[1].zfill(5)
outp = mys.d(snap)

xc = sys.argv[2]
yc = sys.argv[3]
zc = sys.argv[4]
r = str(float(sys.argv[5]) * rout)

os.nice(0)

# Dark Matter
cmd = "get_sphere_dm -inp " + outp
cmd += " -xc " + xc + " -yc " + yc + " -zc " + zc + " -rc " + r + "> " + ddm + "dm_" + snap + ".dat"
cmd += " && octreef " + ddm + "dm_" + snap + ".dat > " + ddm + "rho_" + snap + ".dat"
if (show): print(cmd)
Beispiel #4
0
# (c) 2014 ETHZ, Pascal Steger, [email protected]

import sys, os
import lib.mysql as mys

i=len(sys.argv)
if i!=7:
    print("usage: gen_prof_gas.py sim xc yc zc r")
    print("example: gen_prof_gas.py 270 0.5 0.5 0.5 0.05")
    sys.exit()

rout = 1 # * rvir from AHF for maximal radial distance to include particles from
show = True
run  = True

dgas = mys.simdir()+"/ana/gas/"
snap = sys.argv[1].zfill(5)
outp = mys.d(snap)

xc = sys.argv[2]; yc = sys.argv[3]; zc = sys.argv[4]
r = str(float(sys.argv[5])*rout)
lma = sys.argv[6]

os.nice(0)

# gas
cmd = "get_sphere_gas -inp "+outp
cmd +=" -xc "+xc+" -yc "+yc+" -zc "+zc+" -rc "+r+" -out "+dgas+"rho_"+snap+".dat -typ 0 -lma "+lma
if(show): print(cmd)
if(run): os.system(cmd)
Beispiel #5
0
# (c) 2014 ETHZ, Pascal Steger, [email protected]

import sys, os
import lib.mysql as mys

i=len(sys.argv)
if i!=6:
    print("usage: gen_prof_dm.py sim xc yc zc r")
    print("example: gen_prof_dm.py 270 0.5 0.5 0.5 0.05")
    sys.exit()

rout = 1 # * rvir from AHF for maximal radial distance to include particles from
show = True
run  = True

ddm = mys.simdir()+"/ana/dm/"
snap = sys.argv[1].zfill(5)
outp = mys.d(snap)

xc = sys.argv[2]; yc = sys.argv[3]; zc = sys.argv[4]
r = str(float(sys.argv[5])*rout)

os.nice(0)

# Dark Matter
cmd = "get_sphere_dm -inp "+outp
cmd +=" -xc "+xc+" -yc "+yc+" -zc "+zc+" -rc "+r+"> "+ddm+"dm_"+snap+".dat"
cmd += " && octreef "+ddm+"dm_"+snap+".dat > "+ddm+"rho_"+snap+".dat"
if(show): print(cmd)
if(run): os.system(cmd)
Beispiel #6
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()