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,
#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)
Exemple #3
0
#-----------------------------
#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)
Exemple #4
0
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)
Exemple #5
0
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,
}
)

#----------------------------------------
#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,
Exemple #7
0
)

#------------------------------------
#3D PLOTTING (weighting by density)
#------------------------------------
tag = 'Main'
dens_plot = density.total / 1e6

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=False)

#---------------------
#2D PLOTTING (Density)
#---------------------

vmin, vmax = np.array([2e13, 1e19]) / 1e6
norm = colors.LogNorm(vmin=vmin, vmax=vmax)

Plot_model.plane2D(GRID,
                   dens_plot,
Exemple #8
0
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')
        [-u.TSun]
    ],  #flux --> if negative, radmc assumes the input number as the blackbody temperature of the star 
    lam=wavelength_intervals,
    nxx=wavelength_divisions)
radmc.write_wavelength_micron(
    lam=wavelength_intervals, nxx=wavelength_divisions
)  #lam --> wavelengths in microns, nxx --> number of divisions in between wavelengths

Model.PrintProperties(density, temperature, GRID)

#---------------
#PLOTTING 2D z=0
#---------------
Plot_model.plane2D(GRID,
                   prop['dens_H2'],
                   axisunit=u.au,
                   plane={'z': 0},
                   norm=LogNorm(vmin=1e9, vmax=1e13),
                   output='densH2_2D.png')
Plot_model.plane2D(GRID,
                   prop['temp_gas'],
                   axisunit=u.au,
                   plane={'z': 0},
                   norm=LogNorm(vmin=1e1, vmax=1e3),
                   output='tempgas_2D.png')

#-------
#TIMING
#-------
print('Ellapsed time: %.3fs' % (time.time() - t0))
print(
    '-------------------------------------------------\n-------------------------------------------------\n'
Exemple #10
0
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-------------------------------------------------'
)
Exemple #11
0
print('Output columns', lime.columns)

#******-
#TIMING
#******-
print ('Ellapsed time: %.3fs' % (time.time() - t0))
print ('-------------------------------------------------\n-------------------------------------------------\n')

#*******************************************
#3D PLOTTING
# The scatter points are randomly
# tracing the hydrogen (H) density.
#   The colormap is associated to the
#   molecular hydrogen (H2) density in cgs
#*******************************************
weight = 10*mean_dens

canvas3d = Plot_model.Canvas3d(ax_kw={'azim': -50, 'elev': 50})
ax = canvas3d.ax
sp = canvas3d.scatter_random(GRID, prop['dens_H'], weight, prop_color = prop['dens_H2']/1e6, GRID_unit=sfu.pc, power=0.5, NRand=20000, prop_min=None, #function arguments
                             marker = 'o', s = 3, cmap = 'nipy_spectral_r', edgecolors = 'none', vmin = 1.0, vmax = None, norm = colors.LogNorm()) #Scatter kwargs

cbar = plt.colorbar(sp)
cbar.ax.set_ylabel(r'$\rm n_{H_2} [\rm cm^{-3}]$')

ax.set_xlabel('X (pc)')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.savefig('3Dpoints_snap.png')#, dpi=200)
plt.show()
Exemple #12
0
Model.PrintProperties(density, temperature, GRID)

#-------
#TIMING
#-------
print('Ellapsed time: %.3fs' % (time.time() - t0))
print(
    '-------------------------------------------------\n-------------------------------------------------\n'
)

#--------------------------------------
#3D PLOTTING (weighting by temperature)
#--------------------------------------
tag = 'Burger'
weight = 10 * T10Env

vmin, vmax = np.array([5e11, 5e15]) / 1e6
norm = colors.LogNorm(vmin=vmin, vmax=vmax)

Plot_model.scatter3D(GRID,
                     temperature.total,
                     weight,
                     NRand=4000,
                     colordim=density.total / 1e6,
                     axisunit=u.au,
                     cmap='hot',
                     norm=norm,
                     colorlabel=r'$\rho$ $[cm^{-3}]$',
                     output='3Dpoints%s.png' % tag,
                     show=True)
Exemple #13
0
#********
#TIMING
#********
print('Ellapsed time: %.3fs' % (time.time() - t0))
print(
    '-------------------------------------------------\n-------------------------------------------------\n'
)

#********
#PLOTTING
#********
density = finalprop['dens_H2'] / 1e6  #dens. in cm^-3
temperature = finalprop['temp_gas']

weight = 1.0  #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)

#--------------------
#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)
"""

#******************
#3D plotting
}

Model.PrintProperties(density, temperature, GRID)
print('Ellapsed time: %.3fs' % (time.time() - t0))
print(
    '-------------------------------------------------\n-------------------------------------------------\n'
)

#---------------
#PLOTTING 2D z=0
#---------------
Plot_model.plane2D(GRID,
                   prop['dens_H'],
                   axisunit=u.au,
                   plane={'z': 0},
                   norm=LogNorm(vmin=1e9, vmax=1e14),
                   colorlabel=r'$n_{H}$ $\rm{[m^{-3}]}$',
                   cmap='cubehelix',
                   output='densH_2D.png',
                   show=True)

Plot_model.plane2D(GRID,
                   prop['temp_gas'],
                   axisunit=u.au,
                   plane={'z': 0},
                   norm=LogNorm(vmin=1e1, vmax=1e3),
                   colorlabel=r'T [K]',
                   cmap='hot',
                   output='tempgas_2D.png',
                   show=True)
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')
#-------
#TIMING
#-------
print ('Ellapsed time: %.3fs' % (time.time() - t0))
print ('-------------------------------------------------\n-------------------------------------------------\n')

#----------------------
#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 = 'keto+disc_HII'
weight = rho_s

norm = colors.LogNorm()
Plot_model.scatter3D(GRID, density.total, weight, NRand = 4000, colordim = density.total / 1e6, axisunit = u.au, cmap = 'jet', 
                     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 = 'jet', marker = 'o',
                     colorscale = 'uniform', colorlabel = r'$T_{\rm e}$ [Kelvin]', output = '3Dtemp_%s.png'%tag, show = True)


#******************
#3D plotting
#******************
lims = np.array([-70, 70])
weight = 1e10
ax_kw = {
    'projection': '3d',
    'xlim': lims,
    'ylim': lims,
    'zlim': lims,
    'azim': -50,
    'elev': 30
}
ax3 = fig.add_axes([0.03, 0.53, 0.43, 0.43], **ax_kw)
canvas3d = Plot_model.Canvas3d(fig=fig, ax=ax3)
sp = canvas3d.scatter_random(
    grid,
    density / 1e6,
    weight,
    GRID_unit=u.au,
    power=0,
    NRand=10000,
    prop_min=1.0,  #function arguments
    marker='+',
    cmap='jet',
    s=3,
    edgecolors='none',
    vmin=1e6,
    norm=colors.LogNorm())  #Scatter kwargs
cbar = plt.colorbar(sp)
Exemple #18
0
                 '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='.',
Exemple #19
0
print('Ellapsed time:', time.time() - t0)

#******************
#3D plotting
#******************
lims = np.array([-100, 100])
weight = 1.
ax_kw = {
    'projection': '3d',
    'xlim': lims,
    'ylim': lims,
    'zlim': lims,
    'azim': 30,
    'elev': 13
}
canvas3d = Plot_model.Canvas3d(ax_kw=ax_kw)
ax = canvas3d.ax
sp = canvas3d.scatter_random(
    grid,
    prop['dens_H2'] / 1e6,
    weight,
    GRID_unit=u.au,
    power=0,
    NRand=10000,
    prop_min=1.0,  #function arguments
    marker='+',
    cmap='jet',
    s=3,
    edgecolors='none',
    vmin=1e7,
    norm=colors.LogNorm())  #Scatter kwargs
Exemple #20
0
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,