) #---------------------------------------- #3D PLOTTING (weighting with temperature) #---------------------------------------- tag = 'Burger_Tapering' dens_plot = density.total / 1e6 weight = 5000. #Kelvin norm = colors.LogNorm() Plot_model.scatter3D(GRID, temperature.total, weight, NRand=4000, colordim=density.total / 1e6, axisunit=u.au, cmap='ocean_r', norm=norm, power=0.8, colorlabel=r'$\rho [cm^{-3}]$', output='3Dpoints%s.png' % tag, show=False) #---------------------------------------- #2D PLOTTING (Density and Temperature) #---------------------------------------- vmin, vmax = np.array([9e15, 5e19]) / 1e6 norm = colors.LogNorm(vmin=vmin, vmax=vmax) Plot_model.plane2D(GRID, dens_plot,
f1.cylinder([0.1 * pc, 0.3 * pc], 1e-4 * pc, abund_pars=[1e-6, 0.05 * pc, -0.15], temp_pars=[200, 0.02 * pc, -0.15, -0.17 * pc], dummy_frac=0.5) lims = np.array([-0.3, 0.3]) * pc pm.scatter3D(f1.GRID, f1.density, np.mean(f1.density), axisunit=pc, colordim=f1.temperature, colorlabel='T [K]', NRand=10000, cmap='nipy_spectral_r', xlim=lims, ylim=lims, zlim=lims, azim=45, elev=15, output='fig_filament_temp.png', show=True) pm.scatter3D(f1.GRID, f1.density, np.min(f1.density), axisunit=pc, colordim=f1.abundance, colorlabel='Molec. abund.', NRand=10000,
f1 = sf.FilamentModel([0,0,0], [1,0,0], -0.2*pc, 0.2*pc, 4e-3*pc) def new_temp(R,theta,z, *temp_pars): TR, R0, pR, zh = temp_pars cR = TR*R0**-pR return cR*R**pR * np.exp(np.abs(z)/zh) f1.func_temp = new_temp f1.cylinder(0.1*pc, 1e-4*pc, dens_pars = [7e10, 0.03*pc, 2.0], temp_pars = [200, 0.02*pc, -0.15, -0.17*pc], abund_pars = 1e-4) pm.scatter3D(f1.GRID, f1.density, np.min(f1.density), axisunit = pc, colordim = f1.density, colorlabel = 'T [K]', NRand = 10000, show=True) prop = {'dens_H': f1.density, 'temp_gas': f1.temperature, 'abundance': f1.abundance, 'gtdratio': f1.gtdratio, 'vel_x': f1.vel.x, 'vel_y': f1.vel.y, 'vel_z': f1.vel.z, } lime = rt.Lime(f1.GRID) lime.submodel(prop, output='filament.dat')
#WRITING RADMC-3D FILES #---------------------- prop = {'dens_e': density.total, 'dens_ion': density.total, 'temp_gas': temperature.total} Rad = rt.Radmc3dDefaults(GRID) Rad.freefree(prop) #------------------------------------ #3D PLOTTING (weighting with density) #------------------------------------ tag = 'ctsphere_HII' weight = dens_e """ Plot_model.scatter3D(GRID, density.total, weight, power=0, NRand = 4000, colordim = density.total / 1e6 / 1e5, axisunit = u.au, cmap = 'winter', marker = 'o', colorlabel = r'$n_{\rm e}$ [cm$^{-3}$] x $10^5$', output = '3Ddens_%s.png'%tag, show = True) Plot_model.scatter3D(GRID, density.total, weight, power=0, NRand = 4000, colordim = temperature.total, axisunit = u.au, cmap = 'winter', marker = 'o', colorlabel = r'$T_{\rm e}$ [Kelvin]', output = '3Dtemp_%s.png'%tag, show = True) """ fig = plt.figure(figsize=(6.4,4.8)) #ax = plt.axes(projection='3d') lims = np.array([-sizex,sizex]) / u.au canvas3d = Plot_model.Canvas3d(fig=fig, ax_kw={'xlim': lims, 'ylim': lims, 'zlim': lims, 'azim': -50, 'elev': 30}) ax = canvas3d.ax #generated with fig.add_axes from matplotlib. All the matplotlib functions are therefore available on ax. sp = canvas3d.scatter_random(GRID, density.total/1e6/1e5, weight/1e6/1e5, GRID_unit=u.au, power=0, NRand=4000, prop_min=1.0, #function arguments marker = 'o', cmap = 'winter', s = 3, edgecolors = 'none', vmin = None, vmax = None, norm = None) #Scatter kwargs #ax.scatter(3000,0,0, c=[dens_e*1.2/1e6], norm=colors.Normalize(density.total.min()/1e6, vmax=density.total.max()/1e6), cmap=sp.cmap)
#----------------------------- #PRINTING resultant PROPERTIES #----------------------------- Model.PrintProperties(density, temperature, GRID) #------- #TIMING #------- print('Ellapsed time: %.3fs' % (time.time() - t0)) print( '-------------------------------------------------\n-------------------------------------------------\n' ) #---------------------------------- #3D PLOTTING (weighting by density) #---------------------------------- tag = 'Main' weight = 10 * Rho0 r = GRID.rRTP[0] / u.au #GRID.rRTP hosts [r, R, Theta, Phi] --> Polar GRID Plot_model.scatter3D(GRID, density.total, weight, NRand=4000, colordim=r, axisunit=u.au, cmap='jet', colorscale='log', colorlabel=r'${\rm log}_{10}(r$ $[au])$', output='3Dpoints%s.png' % tag, show=True)
outflows = Overlap(GRID) finalprop = outflows.fromfiles(columns, submodels = files, rt_code = 'radmc3d') radmc = rt.Radmc3dDefaults(GRID) radmc.freefree(finalprop) #******** #TIMING #******** print ('Ellapsed time: %.3fs' % (time.time() - t0)) print ('-------------------------------------------------\n-------------------------------------------------\n') #******** #PLOTTING #******** density = finalprop['dens_e'] / 1e6 #dens. in cm^-3 temperature = finalprop['temp_gas'] weight = 100 * np.mean(density) #----------------- #Plot for DENSITY #----------------- Pm.scatter3D(GRID, density, weight, NRand = 4000, axisunit = u.au, colorscale = 'log', cmap = 'cool', colorlabel = r'${\rm log}_{10}(n [cm^{-3}])$', output = 'global_grid_dens.png', vmin = 5, show=False) #-------------------- #Plot for TEMPERATURE #-------------------- Pm.scatter3D(GRID, density, weight, colordim = temperature, NRand = 4000, axisunit = u.au, colorscale = 'log', cmap = 'brg', colorlabel = r'${\rm log}_{10}(T$ $[K])$', output = 'global_grid_temp.png', vmin = 2, show=False)
from sf3dmodels.utils.units import pc import sf3dmodels.rt as rt f1 = sf.FilamentModel([0, 0, 0], [0, 0, 1], -0.2 * pc, 0.2 * pc, 0.01 * pc) f1.cylinder(0.1 * pc, 1e-3 * pc, temp_pars=[500, 0.02 * pc, -0.3], abund_pars=1e-4) lims = [-0.3 * pc, 0.3 * pc] pm.scatter3D(f1.GRID, f1.density, f1.density.min(), axisunit=pc, colordim=f1.temperature, colorlabel='T [K]', xlim=lims, ylim=lims, zlim=lims, NRand=10000, show=True) prop = { 'dens_H': f1.density, 'temp_gas': f1.temperature, 'abundance': f1.abundance, 'gtdratio': f1.gtdratio, 'vel_x': f1.vel.x, 'vel_y': f1.vel.y, 'vel_z': f1.vel.z, }
'lam': [5e-1, 5e2, 2e4, 4e4] }) #lambda in microns #------------------------------------ #3D PLOTTING (weighting by density) #------------------------------------ tag = 'plsphere_HII' weight = 10 * rho_s Plot_model.scatter3D(GRID, density.total, weight, NRand=4000, colordim=density.total / 1e6, axisunit=u.au, cmap='jet', marker='.', s=15, colorscale='log', colorlabel=r'${\rm log}_{10}$($n_{\rm e}$ [cm$^{-3}$])', output='3Ddens_%s.png' % tag, show=True) Plot_model.scatter3D(GRID, density.total, weight, NRand=4000, colordim=temperature.total, axisunit=u.au, cmap='binary', marker='.',
data2merge = ['Main.dat', 'Burger.dat'] overlap = Overlap(GRID) finalprop = overlap.fromfiles(columns, submodels = data2merge) #********** #WRITING #********** lime = rt.Lime(GRID) lime.finalmodel(finalprop) #-------- #PLOTTING #-------- density = finalprop['dens_H2'] / 1e6 #1e6 to convert from m^-3 to cm^-3 temperature = finalprop['temp_gas'] weight = 400 * np.mean(density) #----------------- #Plot for DENSITY #----------------- Pm.scatter3D(GRID, density, weight, NRand = 7000, axisunit = u.au, colorscale = 'log', cmap = 'hot', colorlabel = r'${\rm log}_{10}(\rho [cm^{-3}])$', output = 'global_grid_dens.png') #-------------------- #Plot for TEMPERATURE #-------------------- Pm.scatter3D(GRID, density, weight, colordim = temperature, NRand = 7000, axisunit = u.au, colorscale = 'log', cmap = 'brg', colorlabel = r'${\rm log}_{10}(T$ $[K])$', output = 'global_grid_temp.png')
if plot_3d: tags = iter(['A', 'B', 'C']) npoints = iter([3000, 2000, 4000]) for density in [ prop_globalA['dens_e'], prop_globalB['dens_e'], prop_globalC['dens_e'] ]: dens2plot = density / 1e6 weight = 10 * np.mean(dens2plot) Pm.scatter3D(GRID, dens2plot, weight, NRand=next(npoints), axisunit=u.au, colorscale='log', cmap='cool', colorlabel=r'${\rm log}_{10}(n_{e^-} [cm^{-3}])$', output='global_grid%s.png' % next(tags), vmin=5.5, azim=10, elev=30, show=False) #********************************** #PLOTTING SEDS + FITS + CONVOLUTION #********************************** runpy.run_path('plot_sed_data.py') runpy.run_path('generate_fits.py') print( '-------------------------------------------------\n-------------------------------------------------' )
#---------------------------------------- #3D PLOTTING (weighting by temperature) #---------------------------------------- tag = 'Burger' dens_plot = density.total / 1e6 vmin, vmax = np.array([5e11, 5e15]) / 1e6 norm = colors.LogNorm(vmin=vmin, vmax=vmax) weight = 10 * T10Env Plot_model.scatter3D(GRID, temperature.total, weight, NRand=4000, colordim=dens_plot, axisunit=u.au, cmap='hot', norm=norm, colorlabel=r'$\rho$ $[cm^{-3}]$', output='3Dpoints%s.png' % tag, show=False) #---------------------------------------- #2D PLOTTING (Density and Temperature) #---------------------------------------- vmin, vmax = np.array([1e12, 1e17]) / 1e6 norm = colors.LogNorm(vmin=vmin, vmax=vmax) Plot_model.plane2D(GRID, dens_plot,
weight = 50 * np.mean(density) #----------------- #Plot for DENSITY #----------------- from matplotlib.colors import LogNorm lims = np.array([-0.3, 0.3]) * u.pc Pm.scatter3D(GRID, density, weight, NRand=7000, axisunit=u.pc, norm=LogNorm(vmin=1e3, vmax=1e7), cmap='nipy_spectral', colorlabel=r'${\rm log}_{10}(\rho [cm^{-3}])$', output='global_grid_dens.png', xlim=lims, ylim=lims, zlim=lims) #-------------------- #Plot for TEMPERATURE #-------------------- Pm.scatter3D(GRID, density, weight, colordim=temperature, NRand=7000, axisunit=u.pc,