radmc3dPy package

Submodules

radmc3dPy.analyze module

This module contains classes and functions to read and write input/output data for RADMC-3D and to do some simple analysis/diagnostics of the model.

radmc3dPy.analyze.findContainerLeafID(cellCRD=None, cellHW=None, xi=None, yi=None, zi=None, childID=None, isLeaf=None, nChild=None, crd=None)

Function to find the tree index of a leaf cell containing a given point in space, i.e. if the following is true : xcell - dxcell <= xpoint < xcell + dxcell for each dimension. This function is to be used in multiprocessing.

Parameters:

cellCRD : ndarray

Array with dimensions [ncell, 3] containing the cell centre coordiantes of the tree

cellHW : ndarray

Array with dimensions [ncell, 3] containing the half width of cells in the tree

xi : ndarray

Array of cell interface indices in the base grid in the first dimension

yi : ndarray

Array of cell interface indices in the base grid in the second dimension

zi : ndarray

Array of cell interface indices in the base grid in the third dimension

childID : ndarray

Child index array

isLeaf : ndarray

Boolean array containing the node type for each cell (True - leaf, False - branch)

nChild : int

Number of children (8,4,2 for 3,2,1 active dimensions)

crd : ndarray

Array of length 3 containing the coordinates of the point whose container leaf is to be found

radmc3dPy.analyze.findContainerLeafIDRec(x=None, y=None, z=None, dx=None, dy=None, dz=None, childID=None, isLeaf=None, nChild=None, crd=(), cellID=None)

Recursive function to find the leaf cell in the tree that contains a given point in space

Parameters:

x : ndarray

Tree cell center array in the first dimension

y : ndarray

Tree cell center array in the second dimension

z : ndarray

Tree cell center array in the tird dimension

dx : ndarray

Tree cell halfwidth array in the first dimension

dy : ndarray

Tree cell halfwidth array in the second dimension

dz : ndarray

Tree cell halfwidth array in the third dimension

childID : list

List of children indices. Each list element is an ndarray with nChild elements containing the child indices

isLeaf : ndarray

Boolean array for the cell type (True - leaf, False - branch)

nChild : int

Nr of children (i.e. 8, 4, or 2 for 3, 2, 1 active dimensions, respectively)

crd : ndarray

Three element list/tuple/array containing the point coordinates

cellID : int

Index of cell to be tested

radmc3dPy.analyze.gdensMinMax(x=None, y=None, z=None, dx=None, dy=None, dz=None, model=None, ppar=None, **kwargs)

Example function to be used as decision function for resolving cells in tree building. It calculates the gas density at a random sample of coordinates within a given cell than take the ratio of the max/min density. If it is larger than a certain threshold value it will return True (i.e. the cell should be resolved) if the density variation is less than the threshold it returns False (i.e. the cell should not be resolved)

Parameters:

x : ndarray

Cell centre coordinates of the cells in the first dimension

y : ndarray

Cell centre coordinates of the cells in the second dimension

z : ndarray

Cell centre coordinates of the cells in the third dimension

dx : ndarray

Half size of the cells in the first dimension

dy : ndarray

Half size of the cells in the second dimension

dz : ndarray

Half size of the cells in the third dimension

model : object

A radmc3dPy model (must contain a getGasDensity() function)

ppar : dictionary

All parameters of the problem (from the problem_params.inp file). It is not used here, but must be present for compatibility reasons.

nsample : int

Number of coordinate points at which the gas density in the cell should be sampled

**kwargs: dictionary

Parameters used to decide whether the cell should be resolved. It should the following keywords; ‘nsample’, which sets the number of random points the gas desity is sampled at within the cell and ‘threshold’ that sets the threshold value for max(gasdens)/min(gasdens) above which the cell should be resolved.

radmc3dPy.analyze.getDensVstruct(data=None, vmean_temp=False, ispec_tgas=0, gsize=None, idust=None, mstar=0.0)

Calculates the vertical hydrostatic equilibrium

Parameters:

data : radmc3dData

An instance of the radmc3DData class containing the density structure of the model

vmean_temp : bool

If True (T(z) = T(-z) = 0.5*(T(z) + T(-z))) if False (T(z)!=T(-z))

idust : list

List of dust indices whose structure must be calculated

mstar : float

Stellar mass

ispec_tgas : int

Index of dust species whose temperature is taken to be the gas temperature

gsize : ndarray

Dust grain sizes - If specified, the gas temperature is calculated as the average temperature of all dust grains in the grid cell weighted by the total surface area of dust grains with given size - NOTE: this approach assumes that all dust grains of a given size have the same bulk density

Returns:

Returns an ndarray with the dust density

radmc3dPy.analyze.gmass(x=None, y=None, z=None, dx=None, dy=None, dz=None, model=None, ppar=None, **kwargs)

Example function to be used as decision function for resolving cells in tree building. It calculates the gas density at a random sample of coordinates within a given cell than take the ratio of the max/min density. If it is larger than a certain threshold value it will return True (i.e. the cell should be resolved) if the density variation is less than the threshold it returns False (i.e. the cell should not be resolved)

Parameters:

x : ndarray

Cell centre coordinates of the cells in the first dimension

y : ndarray

Cell centre coordinates of the cells in the second dimension

z : ndarray

Cell centre coordinates of the cells in the third dimension

dx : ndarray

Half size of the cells in the first dimension

dy : ndarray

Half size of the cells in the second dimension

dz : ndarray

Half size of the cells in the third dimension

model : object

A radmc3dPy model (must contain a getGasDensity() function)

ppar : dictionary

All parameters of the problem (from the problem_params.inp file). It is not used here, but must be present for compatibility reasons.

nsample : int

Number of coordinate points at which the gas density in the cell should be sampled

**kwargs: dictionary

Parameters used to decide whether the cell should be resolved. It should the following keywords; ‘nsample’, which sets the number of random points the gas desity is sampled at within the cell and ‘threshold’ that sets the threshold value for max(gasdens)/min(gasdens) above which the cell should be resolved.

radmc3dPy.analyze.interpolateOctree(data=None, x=None, y=None, z=None, var=['ddens'], nproc=1)

Nearest neighbour inteprolation on an octree

data
: radmc3dData
Data container
x
: ndarray
Coordiantes of the point to be interpolated on in the first dimension
y
: ndarray
Coordiantes of the point to be interpolated on in the second dimension
z
: ndarray
Coordiantes of the point to be interpolated on in the third dimension
var
: list
Name of the variables to be interpolated, supported names are: ddens, dtemp, gdens, ndens, gtemp, gvel, vturb
nproc
: int
Number of processes to be used (for parallel computing)
radmc3dPy.analyze.plotSlice2D(data=None, var='ddens', plane='xy', crd3=0.0, icrd3=None, ispec=-1, xlim=(), ylim=(), log=False, linunit='cm', angunit='rad', nx=100, ny=100, showgrid=False, gridcolor='k', gridalpha=1.0, nproc=1, contours=False, clev=None, clmin=None, clmax=None, ncl=None, cllog=False, clcol='k', clcmap=None, clalpha=1.0, ax=None, lattitude=True, **kwargs)

Function to plot an axis-aligned 2D slice of the variables in the model. Any additional keyword argument above the listed ones will be passed on to matplotlib.pylab.pcolormesh(). For an octree grid the variables are interpolated onto a regular grid using nearest neighbour interpolation before plotting. The size and resolution of the regular image grid can be set at input.

Parameters:

data : radmc3dData

Instance of radmc3dData containing the field variable to be displayed

var : {‘ddens’, ‘dtemp’, ‘gdens’, ‘ndens’, ‘gtemp’, ‘vturb’, ‘vx’, ‘vy’, ‘vz’, ‘taux’, ‘tauy’}

Variable to be displayed

plane : {‘xy’, ‘xz’, ‘yz’, ‘yx, ‘zx’, ‘yz’}

Plane to be displayed

crd3 : float

Coordinate of the third dimension (i.e. when plotting a slice in the x-y plane, crd3 is the z-coordinate)

icrd3 : int

Index of the third coordinate in the grid (only for regular grid!)

ispec : int

Dust species index. If negative dust densities will be summed up and the total cumulative density will be displayed

xlim : tuple

Coordinate boundaries in the first dimension of the plot (also the coordinate boundary of the regular grid data on AMR grids are interpolated to)

ylim : tuple

Coordinate boundaries in the second dimension of the plot (also the coordinate boundary of the regular grid data on AMR grids are interpolated to)

log : bool

If True the contour/image will be displayed on a logarithmic stretch

linunit : {‘cm’, ‘au’, ‘pc’, ‘rs’}

Unit selection for linear image coordinate axes.

angunit : {‘rad’, ‘deg’}

Unit selection for angular image coordinate axes (only if spherical coordinate system is used).

nproc : int

Number of parallel processes to be used for interpolation.

contours : bool

If True contour lines are plotted, if False a colorscale plot will be created

clev : ndarray

A numpy ndarray containing the levels to be displayed with contour lines. If clev is set then clmin, clmax and ncl are omitted

clmin : float

Min. contour level (for setting auto-contours between clmin and clmax at ncl values)

clmax : float

Max. contour level (for setting auto-contours between clmin and clmax at ncl values)

ncl : float

Number of contour levels (for setting auto-contours between clmin and clmax at ncl values)

cllog : bool

If clmin, clmax and ncl are used to generate the contour levels, then if cllog is True the contours will be log-scaled

clcol : str

Color-code for the contour lines for single color contours

clcmap : matplotlib colormap

Colormap used for the contour lines

clalpha : float

Transparency of the contour lines (1.0 fully opaque, 0.0 fully transparent)

lattitude : bool

If the coordinate sytem used in RADMC-3D is spherical, then the 2nd coordiante is the co-lattitude. If lattitude is set to True then the 2nd coordinate in the RADMC-3D grid will be transformet to true lattitude (i.e. pi/2.-colattitude). If set to false the original co-lattitude will be used.

radmc3dPy.analyze.plotSpectrum(a, ev=False, kev=False, hz=False, micron=False, jy=False, lsun=False, lnu=False, nulnu=False, fnu=False, nufnu=False, dpc=1.0, oplot=False, xlg=False, ylg=False, obs=False, mol=None, ilin=None)

Plot the spectrum / SED

Parameters:

a : ndarray

A 2D array of size [Nfreq,2] returned by readSpectrum(). [:,0] - wavelength in micrometer, or for line data the velocity in km/s [:,1] - flux density in erg/s/cm/cm/Hz

ev : bool

True –> frequency in electronvolt (default=Hz)

kev : bool

True –> frequency in kiloelectronvolt (default=Hz)

micron : bool

True –> wavelength in micron (default=Hz)

jy : bool

True –> Flux in Jansky

lnu : bool

True –> L_nu (default L_nu)

nulnu : bool

True –> nu*L_nu (default F_nu)

lsun : bool

True –> nu*L_nu in units of solar luminosity

dpc : bool

Distance of observer in units of parsec (Default: 1 pc)

oplot : bool

True –> Plot without refreshing subplot

xlg : bool

True –> logarithmic x-axis

ylg : bool

True –> logarithmic y-axis

obs : bool

True –> Treat the spectrum as an observation

(i.e. do not scale with dpc^(-2))

mol : bool

(optional) Molecule data (see radmc3dMolecule class)

This is required if you want to plot a line spectrum with on the x-axis the radial velocity in km/s

ilin : bool

(if set) the index of the line (of mol; starting,

as in RADMC-3D, with the index 1) which shall act as the 0 km/s wavelength reference. If ilin is set the x axis will be in km/s (overriding other settings)

class radmc3dPy.analyze.radmc3dData(grid=None)

Bases: object

RADMC-3D data class.
Reading and writing dust density/temperature, gas density/temperature/velocity, generating a legacy vtk file for visualization.

Attributes

grid (radmc3dGrid) Instance of the radmc3dGrid class, contains the spatial and frequency grids
rhodust (ndarray) Dust density in g/cm^3
dusttemp (ndarray) Dust temperature in K
rhogas (ndarray) Gas density in g/cm^3
ndens_mol (ndarray) Number density of the molecule [molecule/cm^3]
ndens_cp (ndarray) Number density of the collisional partner [molecule/cm^3]
gasvel (ndarray) Gas velocity in cm/s
gastemp (ndarray) Gas temperature in K
vturb (ndarray) Mictroturbulence in cm/s
taux (ndarray) Optical depth along the x (cartesian) / r (cylindrical) / r (spherical) dimension
tauy (ndarray) Optical depth along the y (cartesian) / theta (cylindrical) / theta (spherical) dimension
tauz (ndarray) Optical depth along the z (cartesian) / z (cylindrical) / phi (spherical) dimension
sigmadust (ndarray) Dust surface density in g/cm^2
sigmagas (ndarray) Gas surface density in molecule/cm^2 (or g/cm^2 depending on the dimension of rhogas)

Methods

getDustMass([idust]) Calculates the dust mass in radmc3dData.rhodust
getGasMass([mweight, rhogas]) Calculates the gas mass in radmc3dData.ndens_mol or radmc3dData.rhogas
getSigmaDust([idust]) Calculates the dust surface density.
getSigmaGas() Calculates the gas surface density.
getTau([idust, axis, wav, kappa, old]) Calculates the optical depth along any given combination of the axes.
getTauOneDust([idust, axis, kappa]) Calculates the optical depth of a single dust species along any given combination of the axes.
readDustDens([fname, binary, old, octree]) Reads the dust density.
readDustTemp([fname, binary, old, octree]) Reads the dust temperature.
readGasDens([ispec, binary, octree]) Reads the gas density.
readGasTemp([fname, binary, octree]) Reads the gas temperature.
readGasVel([fname, binary, octree]) Reads the gas velocity.
readVTurb([fname, binary, octree]) Reads the turbulent velocity field.
writeDustDens([fname, binary, old, octree]) Writes the dust density.
writeDustTemp([fname, binary, octree]) Writes the dust density.
writeGasDens([fname, ispec, binary, octree]) Writes the gas density.
writeGasTemp([fname, binary, octree]) Writes the gas temperature.
writeGasVel([fname, binary, octree]) Writes the gas velocity.
writeVTK([vtk_fname, ddens, dtemp, idust, ...]) Writes physical variables to a legacy vtk file.
writeVTurb([fname, binary, octree]) Writes the microturbulence file.
getDustMass(idust=-1)

Calculates the dust mass in radmc3dData.rhodust

Parameters:

idust : int

Dust index whose dust should be calculated. If it is set to -1 (default) the total dust mass is calculated summing up all dust species

Returns:

A single float being the dust mass in gramm

getGasMass(mweight=2.3, rhogas=False)

Calculates the gas mass in radmc3dData.ndens_mol or radmc3dData.rhogas

Parameters:

mweight : float

Molecular weight [atomic mass unit / molecule, i.e. same unit as mean molecular weight]

rhogas
: bool, optional

If True the gas mass will be calculated from radmc3dData.rhogas, while if set to False the gas mass will be calculated from radmc3dData.ndens_mol. The mweight parameter is only required for the latter.

Returns:

A single float being the gas mass in gramm

getSigmaDust(idust=-1)

Calculates the dust surface density.

Parameters:

idust : int, optional

Index of the dust species for which the surface density should be calculated if omitted the calculated surface density will be the sum over all dust species

getSigmaGas()

Calculates the gas surface density. This method uses radmc3dData.rhogas to calculate the surface density, thus the unit of surface density depends on the unit of radmc3dData.rhogas (g/cm^2 or molecule/cm^2)

getTau(idust=[], axis='xy', wav=0.0, kappa=None, old=False)

Calculates the optical depth along any given combination of the axes.

Parameters:

idust : list

List of dust component indices whose optical depth should be calculated If multiple indices are set the total optical depth is calculated summing over all dust species in idust

axis : str

Name of the axis/axes along which the optical depth should be calculated (e.g. ‘x’ for the first dimension or ‘xyz’ for all three dimensions)

wav : float

Wavelength at which the optical depth should be calculated

kappa : bool

If set it should be a list of mass extinction coefficients at the desired wavelength The number of elements in the list should be equal to that in the idust keyword

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

getTauOneDust(idust=0, axis='', kappa=0.0)

Calculates the optical depth of a single dust species along any given combination of the axes.

Parameters:

idust : int

Index of the dust species whose optical depth should be calculated

axis : str

Name of the axis/axes along which the optical depth should be calculated (e.g. ‘x’ for the first dimension or ‘xyz’ for all three dimensions)

kappa : float

Mass extinction coefficients of the dust species at the desired wavelength

Returns:

Returns a dictionary with the following keys

taux
: ndarray

optical depth along the first dimension

tauy
: ndarray

optical depth along the second dimension

(tauz is not yet implemented)

readDustDens(fname='', binary=True, old=False, octree=False)

Reads the dust density.

Parameters:

fname : str, optional

Name of the file that contains the dust density. If omitted ‘dust_density.inp’ is used (or if binary=True the ‘dust_density.binp’ is used).

binary : bool, optional

If true the data will be read in binary format, otherwise the file format is ascii

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

octree : bool, optional

If the data is defined on an octree-like AMR

readDustTemp(fname='', binary=True, old=False, octree=False)

Reads the dust temperature.

Parameters:

fname : str, optional

Name of the file that contains the dust temperature.

binary : bool, optional

If true the data will be read in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

readGasDens(ispec='', binary=True, octree=False)

Reads the gas density.

Parameters:

ispec : str

File name extension of the ‘numberdens_ispec.inp’ (or if binary=True ‘numberdens_ispec.binp’) file.

binary : bool

If true the data will be read in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

readGasTemp(fname='', binary=True, octree=False)

Reads the gas temperature.

Parameters:

fname : str,optional

Name of the file that contains the gas temperature. If omitted ‘gas_temperature.inp’ (or if binary=True ‘gas_tempearture.binp’) is used.

binary : bool

If true the data will be read in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

readGasVel(fname='', binary=True, octree=False)

Reads the gas velocity.

Parameters:

fname : str, optional

Name of the file that contains the gas velocity If omitted ‘gas_velocity.inp’ (if binary=True ‘gas_velocity.binp’)is used.

binary : bool

If true the data will be read in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

readVTurb(fname='', binary=True, octree=False)

Reads the turbulent velocity field.

Parameters:

fname : str, optional

Name of the file that contains the turbulent velocity field If omitted ‘microturbulence.inp’ (if binary=True ‘microturbulence.binp’) is used.

binary : bool

If true the data will be read in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

writeDustDens(fname='', binary=True, old=False, octree=False)

Writes the dust density.

Parameters:

fname : str, optional

Name of the file into which the dust density should be written. If omitted ‘dust_density.inp’ is used.

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

octree : bool, optional

If the data is defined on an octree-like AMR

writeDustTemp(fname='', binary=True, octree=False)

Writes the dust density.

Parameters:

fname : str, optional

Name of the file into which the dust density should be written. If omitted ‘dust_density.inp’ is used.

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

writeGasDens(fname='', ispec='', binary=True, octree=False)

Writes the gas density.

Parameters:

fname : str, optional

Name of the file into which the data will be written. If omitted “numberdens_xxx.inp” and “numberdens_xxx.binp” will be used for ascii and binary format, respectively (xxx is the name of the molecule).

ispec : str

File name extension of the ‘numberdens_ispec.inp’ (if binary=True ‘numberdens_ispec.binp’) file into which the gas density should be written

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

writeGasTemp(fname='', binary=True, octree=False)

Writes the gas temperature.

Parameters:

fname : str, optional

Name of the file into which the gas temperature should be written. If omitted ‘gas_temperature.inp’ (if binary=True ‘gas_tempearture.binp’) is used.

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

writeGasVel(fname='', binary=True, octree=False)

Writes the gas velocity.

Parameters:

fname : str, optional

Name of the file into which the gas temperature should be written. If omitted ‘gas_velocity.inp’ (if binary=True ‘gas_velocity.binp’) is used.

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

writeVTK(vtk_fname='', ddens=False, dtemp=False, idust=[0], gdens=False, gvel=False, gtemp=False)

Writes physical variables to a legacy vtk file.

Parameters:

vtk_fname : str

Name of the file to be written, if not specified ‘radmc3d_data.vtk’ will be used

ddens : bool

If set to True the dust density will be written to the vtk file

dtemp : bool

If set to True the dust temperature will be written to the vtk file

idust : list

List of indices that specifies which dust component should be written if not set then the first dust species (zero index) will be used

gdens : bool

If set to True the gas density will be written to the vtk file

gtemp : bool

If set to True the gas temperature will be written to the vtk file

gvel : bool

If set to True the gas velocity will be written to the vtk file

writeVTurb(fname='', binary=True, octree=False)

Writes the microturbulence file.

Parameters:

fname : str, optional

Name of the file into which the turubulent velocity field should be written. If omitted ‘microturbulence.inp’ (if binary=True ‘microturbuulence.binp’) is used.

binary : bool

If true the data will be written in binary format, otherwise the file format is ascii

octree : bool, optional

If the data is defined on an octree-like AMR

class radmc3dPy.analyze.radmc3dDustOpac

Bases: object

Class to handle dust opacities.

Attributes

wav (list) Each element of the list contains an ndarray with the wavelength grid
freq (list) Each element of the list contains an ndarray with the frequency grid
nwav (list) Each element of the list contains an integer with the number of wavelengths
kabs (list) Each element of the list contains an ndarray with the absorption coefficient per unit mass
ksca (list) Each element of the list contains an ndarray with the scattering coefficient per unit mass
phase_g (list) Each element of the list contains an ndarray with the hase function
ext (list) Each element of the list contains a string wht the file name extension of the duskappa_ext.Kappa file
therm (list) Each element of the list contains a bool, if it is set to False the dust grains are quantum-heated (default: True)
idust (lisintt) Each element of the list contains an integer with the index of the dust species in the dust density distribution array
scatmat (list) Each element is a boolean indicating whether the dust opacity table includes (True) the full scattering matrix or not (False)
nang (list) Each element is a string, containing the number of scattering angles in the scattering matrix if its given
scatang (list) Each element is a numpy ndarray containing the scattering angles in the scattering matrix if its given
z11 (list) Each element is a numpy ndarray containing the (1,1) element of the scattering angles in the scattering matrix if its given
z12 (list) Each element is a numpy ndarray containing the (1,2) element of the scattering angles in the scattering matrix if its given
z22 (list) Each element is a numpy ndarray containing the (2,2) element of the scattering angles in the scattering matrix if its given
z33 (list) Each element is a numpy ndarray containing the (3,3) element of the scattering angles in the scattering matrix if its given
z34 (list) Each element is a numpy ndarray containing the (3,4) element of the scattering angles in the scattering matrix if its given
z44 (list) Each element is a numpy ndarray containing the (4,4) element of the scattering angles in the scattering matrix if its given

Methods

makeOpac([ppar, wav, old]) Createst the dust opacities using a Mie code distributed with RADMC-3D.
makeopacRadmc2D([ext]) Creates dust opacities (dustopac_*.inp files) for the previous 2D version of radmc
mixOpac([ppar, mixnames, mixspecs, mixabun, ...]) Mixes dust opacities.
readMasterOpac() Reads the master opacity file ‘dustopac.inp’.
readOpac([ext, idust, scatmat, old]) Reads the dust opacity files.
runMakedust([freq, gmin, gmax, ngs, ...]) Interface function to the F77 code makedust to calculate mass absorption coefficients.
writeMasterOpac([ext, therm, ...]) Writes the master opacity file ‘dustopac.inp’.
makeOpac(ppar=None, wav=None, old=False)

Createst the dust opacities using a Mie code distributed with RADMC-3D.

Parameters:

ppar : dictionary

Parameters of the simulations

wav : ndarray, optional

Wavelength grid on which the mass absorption coefficients should be calculated

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

makeopacRadmc2D(ext=None)

Creates dust opacities (dustopac_*.inp files) for the previous 2D version of radmc It takes the input dust opacity files and interpolates them onto the used frequency grid

Parameters:

ext : list

List of dustkappa file name extensions, i.e. the input file name has to be named as dustkappa_ext[i].inp

mixOpac(ppar=None, mixnames=[], mixspecs=[], mixabun=[], writefile=True)

Mixes dust opacities.

Parameters:

ppar : dictionary, optional

All parameters of the actual model setup.

mixnames : list, optional

Names of the files into which the mixed dust opacities will be written (not needed if writefile=False)

mixspecs : list, optional

Names of the files from which the dust opacities are read (not needed if readfile=False)

mixabun : list, optional

Abundances of different dust species

writefile : bool

If False the mixed opacities will not be written out to files given in mixnames.

NOTE, either ppar or mixname, mixspecs, and mixabun should be set.

readMasterOpac()

Reads the master opacity file ‘dustopac.inp’. It reads the dustkappa filename extensions (dustkappa_ext.inp) corresponding to dust species indices

Returns:

Returns a dictionary with the following keys:

*ext : list of dustkappa file name extensions

*therm : a list of integers specifying whether the dust grain is thermal or quantum heated (0 - thermal, 1 - quantum heated)

readOpac(ext=[''], idust=None, scatmat=None, old=False)

Reads the dust opacity files.

Parameters:

ext : list

File name extension (file names should look like ‘dustkappa_ext.inp’)

idust: list

Indices of the dust species in the master opacity file (dustopac.inp’) - starts at 0

scatmat: list

If specified, its elements should be booleans indicating whether the opacity file contains also the full scattering matrix (True) or only dust opacities (False)

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

runMakedust(freq=None, gmin=None, gmax=None, ngs=None, lnk_fname=None, gdens=None)

Interface function to the F77 code makedust to calculate mass absorption coefficients.

Parameters:

freq : ndarray

Contains the frequency grid on which the opacities should be calculated

gmin : float

Minimum grain size

gmax : float

Maximum grain size

ngs : int

Number of grain sizes

gdens : float

Density of the dust grain in g/cm^3

lnk_faname : str

Name of the file in which the optical constants are stored

Returns:

Returns an ndarray with [nfreq,ngs] dimensions containing the resulting opacities

writeMasterOpac(ext=None, therm=None, scattering_mode_max=1, old=False)

Writes the master opacity file ‘dustopac.inp’.

Parameters:

ext : list

List of dustkappa file name extensions

therm : list

List of integers specifying whether the dust grain is thermal or quantum heated (0-thermal, 1-quantum)

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

class radmc3dPy.analyze.radmc3dGrid

Bases: object

Class for spatial and frequency grid used by RADMC-3D.

Attributes

act_dim (ndarray) A three element vector the i-th element is 1 if the i-th dimension is active, otherwize the i-th element is zero
crd_sys ({‘sph’, ‘cyl’, ‘car’}) coordinate system of the spatial grid
nx (int) Number of grid points in the x (cartesian) / r (cylindrical) / r (spherical) dimension
ny (int) Number of grid points in the y (cartesian) / theta (cylindrical) / theta (spherical) dimension
nz (int) Number of grid points in the z (cartesian) / z (cylindrical) / phi (spherical) dimension
nxi (int) Number of cell interfaces in the x (cartesian) / r (cylindrical) / r (spherical) dimension
nyi (int) Number of cell interfaces in the y (cartesian) / theta (cylindrical) / theta (spherical) dimension
nzi (int) Number of cell interfaces in the z (cartesian) / z (cylindrical) / phi (spherical) dimension
nwav (int) Number of wavelengths in the wavelength grid
nfreq (int) Number of frequencies in the grid (equal to nwav)
x (ndarray) Cell centered x (cartesian) / r (cylindrical) / r (spherical) grid points
y (ndarray) Cell centered y (cartesian) / theta (cylindrical) / theta (spherical) grid points
z (ndarray) Cell centered z (cartesian) / z (cylindrical) / phi (spherical) grid points
xi (ndarray) Cell interfaces in the x (cartesian) / r (cylindrical) / r (spherical) dimension
yi (ndarray) Cell interfaces in the y (cartesian) / theta (cylindrical) / theta (spherical) dimension
zi (ndarray) Cell interfaces in the z (cartesian) / z (cylindrical) / phi (spherical) dimension
wav (ndarray) Wavelengh grid
freq (ndarray) Frequency grid

Methods

getCellVolume() Calculates the volume of grid cells.
makeSpatialGrid([crd_sys, xbound, ybound, ...]) Calculates the spatial grid.
makeWavelengthGrid([wbound, nw, ppar]) Creates the wavelength/frequency grid.
readGrid([old]) Reads the spatial (amr_grid.inp) and frequency grid (wavelength_micron.inp).
readSpatialGrid([fname, old]) Reads the spatial grid
readWavelengthGrid([fname, old]) Reads the wavelength grid
writeSpatialGrid([fname, old]) Writes the wavelength grid to a file (e.g.
writeWavelengthGrid([fname, old]) Wriites the wavelength grid to a file (e.g.
getCellVolume()

Calculates the volume of grid cells.

makeSpatialGrid(crd_sys=None, xbound=None, ybound=None, zbound=None, nxi=None, nyi=None, nzi=None, ppar=None)

Calculates the spatial grid.

Parameters:

crd_sys : {‘sph’,’car’}

Coordinate system of the spatial grid

xbound : list

(with at least two elements) of boundaries for the grid along the first dimension

ybound : list

(with at least two elements) of boundaries for the grid along the second dimension

zbound : list

(with at least two elements) of boundaries for the grid along the third dimension

nxi : int

Number of grid points along the first dimension. List with len(xbound)-1 elements with nxi[i] being the number of grid points between xbound[i] and xbound[i+1]

nyi : int

Same as nxi but for the second dimension

nzi : int

Same as nxi but for the third dimension

ppar : Dictionary containing all input parameters of the model (from the problem_params.inp file)

if ppar is set all keyword arguments that are not set will be taken from this dictionary

makeWavelengthGrid(wbound=None, nw=None, ppar=None)

Creates the wavelength/frequency grid.

Parameters:

wbound : list

Contains the wavelength boundaries of the wavelength grid (should contain at least two elements)

nw : list

Contains len(wbound)-1 elements containing the number of wavelengths between the bounds set by wbound

ppar : dictionary, optional

Contains all input parameters with the parameter names as keys

readGrid(old=False)

Reads the spatial (amr_grid.inp) and frequency grid (wavelength_micron.inp).

Parameters:

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

readSpatialGrid(fname='', old=False)

Reads the spatial grid

Parameters:

fname : str, optional

File name from which the spatial grid should be read. If omitted ‘amr_grid.inp’ will be used.

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

readWavelengthGrid(fname='', old=False)

Reads the wavelength grid

Parameters:

fname : str, optional

File name from which the spatial grid should be read. If omitted ‘wavelength_micron.inp’ will be used.

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

writeSpatialGrid(fname='', old=False)

Writes the wavelength grid to a file (e.g. amr_grid.inp).

Parameters:

fname : str, optional

File name into which the spatial grid should be written. If omitted ‘amr_grid.inp’ will be used.

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

writeWavelengthGrid(fname='', old=False)

Wriites the wavelength grid to a file (e.g. wavelength_micron.inp).

Parameters:

fname : str, optional

File name into which the wavelength grid should be written. If omitted ‘wavelength_micron.inp’ will be used

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

class radmc3dPy.analyze.radmc3dMolecule

Bases: object

RADMC-3D molecule class Based on the Leiden LAMDA database, but is in principle generic

NOTE: For now only the levels and lines are included, not the
collision rates.

Attributes

name (str) The name as listed in the molecule file
molweight (float) Molecular weight in units of proton mass
nlev (int) Nr of energy levels
nlin (int) Nr of lines
energycminv (float) Energy[ilev] of level ilev in 1/cm
energy (float) Energy[ilev] of level ilev in erg
wgt (float) Statistical weight[ilev] of level ilev
jrot (float) Quantum rotational J[ilev] of level ilev
iup (int) ilev of upper level of line ilin (starting with 0)
ilow (int) ilev of lower level of line ilin (starting with 0)
aud (float) Einstein A up low of line ilin in 1/second
freq (float) Frequency of line ilin in Hz
lam (float) Wavelength of line ilin in micron

Methods

read([mol, fname]) Read the molecule_<mol>.inp file
read(mol='', fname='')

Read the molecule_<mol>.inp file

The file format is the format of the Leiden LAMDA molecular database

Parameters:

mol : str

molecule name (e.g. ‘co’) if the file name is in the form of ‘molecule_<mol>.inp’

fname : str

full file name

class radmc3dPy.analyze.radmc3dOctree

Bases: object

Octree-like object with switchable resolution in each dimension

Attributes

xi (ndarray) Base grid cell interface grid in the first dimension
yi (ndarray) Base grid cell interface grid in the second dimension
zi (ndarray) Base grid cell interface grid in the third dimension
xc (ndarray) Base grid cell center grid in the first dimension
yc (ndarray) Base grid cell center grid in the second dimension
zc (ndarray) Base grid cell center grid in the third dimension
x (ndarray) Tree cell center array in the first dimension
y (ndarray) Tree cell center array in the second dimension
z (ndarray) Tree cell center array in the tird dimension
dx (ndarray) Tree cell halfwidth array in the first dimension
dy (ndarray) Tree cell halfwidth array in the second dimension
dz (ndarray) Tree cell halfwidth array in the third dimension
leafID (ndarray) Leaf index array, mapping between a full tree and an array containing only the leaves
isLeaf (ndarray) Boolean array for the cell type (True - leaf, False - branch)
level (ndarray) Level array (base grid is level 0)
parentID (ndarray) Array containing the index of the parent cell (currently unused, only needed if we go up in the tree)
childID (list) List of children indices. Each list element is an ndarray with nChild elements containing the child indices
act_dim (list) A three element array to indicate which dimension is active, i.e. which dimensions are the cells resolved (0 - inactive, 1 - active)
nCell (int) Nr of cells (both branch and leaf) in the tree
nxRoot (int) Nr of cells in the base grid in the first dimension
nyRoot (int) Nr of cells in the base grid in the second dimension
nzRoot (int) Nr of cells in the base grid in the third dimension
nLeaf (int) Nr of leaf cells (i.e. true, unresolved grid cells)
nBranch (int) Nr of branches (i.e. resolved cells)
nChild (int) Nr of children (i.e. 8, 4, or 2 for 3, 2, 1 active dimensions, respectively)
levelMax (int) Highest actual level in the tree (Base grid has a level of 0 and the level increases)
levelMaxLimit (int) Highest allowed level in the tree (only used in tree building)
crd_sys ({‘car’, ‘sph’}) Coordinate system type cartesian or spherical

Methods

convArrLeaf2Tree([var]) Converts a leaf array to full tree size.
convArrTree2Leaf([var]) Converts a data array to leaf size.
generateLeafID() Function to generate the cell index mapping from arrays containing the full tree and those containing only the leaves
getCellVolume([fullTree]) Calculates the grid cell volume
getContainerLeafID([crd]) Finds the tree index of a leaf that contains a given coordinate
makeSpatialGrid([ppar, levelMaxLimit, ...]) Function to create an octree-like AMR grid
makeWavelengthGrid([wbound, nw, ppar]) Creates the wavelength/frequency grid.
putNode([crd, cellsize, level, parentID, cellID]) Function to put the data of a single node into the tree.
readGrid() Reads the spatial and wavelength grids from files
readSpatialGrid([fname]) Reads the spatial grid from amr_grid.inp
readWavelengthGrid([fname]) Function to read the wavelength/frequency grid
resolveNodes([rsIDs]) Resolve multiple nodes simultaneously and add the children of the resolved node to the tree arrays extending
selfCheck() Performs a self-check of the tree allocation and report it to the screen
setModel([model]) Sets the model to be used for tree building
writeSpatialGrid([fname]) Writes the wavelength grid to a file (e.g.
writeWavelengthGrid([fname, old]) Wriites the wavelength grid to a file (e.g.
convArrLeaf2Tree(var=None)

Converts a leaf array to full tree size.

Parameters:

var : ndarray

A one or two dimensional ndarray with the first dimension is the size of the full tree

convArrTree2Leaf(var=None)

Converts a data array to leaf size. The input is a scalar or vector variable defined at all nodes and the returned variable will only represent values at leaf nodes thereby reduced in length compared to the input.

Parameters:

var : ndarray

A one or two dimensional ndarray with the first dimension is the size of the full tree

generateLeafID()

Function to generate the cell index mapping from arrays containing the full tree and those containing only the leaves

getCellVolume(fullTree=False)

Calculates the grid cell volume

Parameters:

fullTree : bool, optional

If True the cell volumes of the full tree (including both branches and leaves) will be calculated, while if set to False (default) the volume of only the leaf cells will be calculated

getContainerLeafID(crd=())

Finds the tree index of a leaf that contains a given coordinate

Parameters:

crd : tuple

List/tuple/ndarray containing the tree dimensional coordinates of the point

makeSpatialGrid(ppar=None, levelMaxLimit=None, dfunc=None, model='', **kwargs)

Function to create an octree-like AMR grid

Parameters:

ppar : dictionary

Dictionary containing all input parameters of the model (from the problem_params.inp file)

model : str

Name of the model to be used in the tree building

dfunc : function

A user defined function that decides whether an AMR grid cell should be refined

levelMaxLimit : int, optional

Highest allowable level of the tree. This keyword is optional. If not specified at input as a separate keyword, levelMaxLimit should be present in the problem_params.inp file.

makeWavelengthGrid(wbound=None, nw=None, ppar=None)

Creates the wavelength/frequency grid.

Parameters:

wbound : list

Contains the wavelength boundaries of the wavelength grid (should contain at least two elements)

nw : list

Contains len(wbound)-1 elements containing the number of wavelengths between the bounds set by wbound

ppar : dictionary, optional

Contains all input parameters with the parameter names as keys

putNode(crd=(), cellsize=(), level=None, parentID=-1, cellID=None)

Function to put the data of a single node into the tree. This funcion assumes that all the arrays have already been allocated for the tree so input cell indices must refer to already existing array elements.

Parameters:

crd : tuple

Cell center coordinates of the node

cellsize : tuple

Full size of the cell in each dimension

level : int

Level of the cell in the tree

parentID : int

Tree index of the parent cell

cellID : int

Tree index of the cell to be added

readGrid()

Reads the spatial and wavelength grids from files

readSpatialGrid(fname='')

Reads the spatial grid from amr_grid.inp

Parameters:

fname : str, optional

File name from which the spatial grid should be read. If omitted ‘amr_grid.inp’ will be used.

readWavelengthGrid(fname='')

Function to read the wavelength/frequency grid

Parameters:

fname : str, optional

Name of the file to read the wavelength grid from (if not specified wavelenth_micron.inp will be used)

resolveNodes(rsIDs=None)

Resolve multiple nodes simultaneously and add the children of the resolved node to the tree arrays extending the tree array

Parameters:

rsIDs : list

List/tuple/array of indices of the resolvable cell in the tree array

selfCheck()

Performs a self-check of the tree allocation and report it to the screen

setModel(model='')

Sets the model to be used for tree building

Parameters:

model : str

Name of the model

writeSpatialGrid(fname='')

Writes the wavelength grid to a file (e.g. amr_grid.inp).

Parameters:

fname : str, optional

File name into which the spatial grid should be written. If omitted ‘amr_grid.inp’ will be used.

writeWavelengthGrid(fname='', old=False)

Wriites the wavelength grid to a file (e.g. wavelength_micron.inp).

Parameters:

fname : str, optional

File name into which the wavelength grid should be written. If omitted ‘wavelength_micron.inp’ will be used

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

class radmc3dPy.analyze.radmc3dPar

Bases: object

Parameter class for a RADMC-3D model.

Attributes

ppar (dictionary) Contains parameter values with parameter names as keys
pdesc (dictionary) Contains parameter description (comments in the parameter file) with parameter names as keys
pblock (dictionary) Contains the block names in the parameter file and parameter names as values
pvalstr: dictionary Contains parameter values as strings with parameter names as keys

Methods

loadDefaults([model, ppar, reset]) Sets all parameters to default values.
printPar() Prints the parameters of the current model.
readPar([fname]) Reads a parameter file.
setPar([parlist]) Sets a parameter in the radmc3DPar class.
writeParfile([fname]) Writes a parameter file.
loadDefaults(model='', ppar={}, reset=True)

Sets all parameters to default values.

Parameters:

model : str

Model name whose paraemters should also be loaded

ppar : dictionary

Contains parameter values as string and parameter names as keys Default values will be re-set to the values in this dictionary

reset : bool

If True the all class attributes will be re-initialized before the default values would be loaded. I.e. it will remove all entries from the dictionary that does not conain default values either in this function or in the optional ppar keyword argument

printPar()

Prints the parameters of the current model.

readPar(fname='')

Reads a parameter file. The parameters in the files should follow python syntax

Parameters:

fname : str, optional

File name to be read (if omitted problem_params.inp is used)

Returns:

Returns a dictionary with the parameter names as keys

setPar(parlist=[])

Sets a parameter in the radmc3DPar class. If the paramter is already defined its value will be modified

Parameters:

parlist : list

If the parameter is already defined parlist should be a two element list 1) parameter name, 2) parameter expression/value as a string

If the parameter is not yet defined parlist should be a four element list 1) parameter name, 2) parameter expression/value as a string 3) Parameter description (= comment field in the parameter file)

writeParfile(fname='')

Writes a parameter file.

Parameters:

fname : str, optional

File name to be read (if omitted problem_params.inp is used)

class radmc3dPy.analyze.radmc3dRadSources(ppar=None, grid=None)

Bases: object

Class of the radiation sources. Currently discrete stars and continuous starlike source, the latter only in spherical coordinates.

Attributes

wav (ndarray) Wavelength for the stellar spectrum
freq (ndarray) Frequency for the stellar spectrum
nwav (int) Number of wavelenghts in the stellar spectrum
nfreq (int) Number of frequencies in the stellar spectrum
mstar (list) List of stellar masses
tstar (list) List of stellar effective temperatures
rstar (list) List of stellar radii
lstar (list) List of stellar luminosities
nstar (int) Number of stars
pstar (list) Each element of the list contains a three element list, the cartesian coordinates of the stars
fnustar (ndarray) Stellar spectrum (flux@1pc in erg/s/cm/cm/Hz)
csdens (ndarray) Stellar density for continuous starlike source
csntemplate (int) Number of stellar templates
cstemp (ndarray) Stellar template
cstemptype (int) Stellar template type 1 - Blackbody given by the effective temperature 2 - Frequency dependent spectrum
cststar (ndarray) Stellar effective temperature
csmstar (ndarray) Stellar mass
csrstar (ndarray) Stellar radius
tacc (ndarray) Effective temperature of a viscous accretion disk as a function of cylindrical radius
accrate (float) Accretion rate of the viscous accretion disk [g/s]
fnuaccdisk (ndarray) Spatially integrated frequency-dependent flux density of the accretion disk @ 1pc distance
tspot (float) Temperature of the hot spot / boundary layer on the stellar surface
starsurffrac (float) Fraction of the stellar surface covered by the hot spot / boundary layer
fnustpot (ndarray) Frequency-dependent flux density of the hot spot / boundary layer @ 1pc distance

Methods

findPeakStarspec() Calculates the peak wavelength of the stellar spectrum.
getAccdiskSpectra([ppar, grid, incl]) Calculates the emergent spectra of an optically thick accretion disk at face-on orientation (incl=0deg).
getAccdiskStellarDensity([ppar, grid]) Calculates the stellar density for continuous starlike sources for modeling a viscous accretion disk.
getAccdiskStellarTemplates([ppar, grid]) Calculates the stellar template for continuous starlike sources for modeling a viscous accretion disk.
getAccdiskTemperature([ppar, grid]) Calculates the effective temperature of a viscous accretion disk.
getSpotSpectrum([ppar, grid]) Calculates the spectrum of a hot spot / boundary layer on the stellar surface
getStarSpectrum([tstar, rstar, lstar, ...]) Calculates a blackbody stellar spectrum.
getTotalLuminosities([readInput]) Calcultes the frequency integrated luminosities of all radiation sources.
readStarsinp([fname]) Reads the data of discrete stellar sources from the stars.inp file.
readStellarsrcDensity([fname, binary]) Reads the stellar density of a continuous starlike source.
readStellarsrcTemplates([fname]) Reads the stellar template of a continuous starlike source.
writeStarsinp([ppar, wav, freq, old]) Writes the input file for discrete stellar sources (stars.inp).
writeStellarsrcDensity([fname, binary]) Writes the stellar density of a continuous starlike source.
writeStellarsrcTemplates([fname]) Writes the stellar template of a continuous starlike source.
findPeakStarspec()

Calculates the peak wavelength of the stellar spectrum.

Returns:

The peak wavelength of the stellar spectrum in nu*Fnu for all

stars as a list

getAccdiskSpectra(ppar=None, grid=None, incl=0.0)

Calculates the emergent spectra of an optically thick accretion disk at face-on orientation (incl=0deg).

Parameters:

ppar : dictionary

Dictionary containing all input parameters keys should include * mstar : stellar mass * rstar : stellar radius * accrate : accretion rate

NOTE, that for the calculation of the effective disk temperature only the first star is used if more than one values are given in mstar and rstar.

incl : float, optional

Inclination angle in degrees at which the spectrum be calculated (default - 0deg)

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getAccdiskStellarDensity(ppar=None, grid=None)

Calculates the stellar density for continuous starlike sources for modeling a viscous accretion disk.

Parameters:

ppar : dictionary

Dictionary containing all input parameters keys should include: * mstar : stellar mass * rstar : stellar radius * accrate : accretion rate

NOTE, that for the calculation of the effective disk temperature only the first star is used if more than one values are given in mstar and rstar.

incl : float, optional

Inclination angle in degrees at which the spectrum be calculated (default - 0deg)

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getAccdiskStellarTemplates(ppar=None, grid=None)

Calculates the stellar template for continuous starlike sources for modeling a viscous accretion disk.

Parameters:

ppar : dictionary

Dictionary containing all input parameters keys should include: * mstar : stellar mass * rstar : stellar radius * accrate : accretion rate

NOTE, that for the calculation of the effective disk temperature only the first star is used if more than one values are given in mstar and rstar.

incl : float, optional

Inclination angle in degrees at which the spectrum be calculated (default - 0deg)

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getAccdiskTemperature(ppar=None, grid=None)

Calculates the effective temperature of a viscous accretion disk.

Parameters:

ppar : dictionary

Dictionary containing all input parameters keys should include * mstar : stellar mass * rstar : stellar radius * accrate : accretion rate

NOTE, that for the calculation of the effective disk temperature only the first star is used if more than one values are given in mstar and rstar.

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getSpotSpectrum(ppar=None, grid=None)

Calculates the spectrum of a hot spot / boundary layer on the stellar surface

Parameters:

ppar : dictionary

Dictionary containing all input parameters keys should include * mstar : stellar mass * rstar : stellar radius * accrate : accretion rate

NOTE, that for the calculation of the effective disk temperature only the first star is used if more than one values are given in mstar and rstar.

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getStarSpectrum(tstar=None, rstar=None, lstar=None, mstar=None, ppar=None, grid=None)

Calculates a blackbody stellar spectrum.

Parameters:

tstar : list

Effective temperature of the stars in [K]

rstar : list

Radius of the stars in [cm]

lstar : list

Bolometric luminosity of the star [erg/s] (either rstar or lstar should be given)

mstar : list

Stellar mass in [g] (only required if an atmosphere model is used to calculate logg)

ppar : dictionary

Dictionary containing all input parameters

grid : radmc3dGrid, optional

An instance of a radmc3dGrid class containing the spatial and wavelength grid

getTotalLuminosities(readInput=True)

Calcultes the frequency integrated luminosities of all radiation sources.

Parameters:

readInput : bool, optional

If true the input files of the radiation sources are read and the the total luminosities are calculated from them. If readInput is set to False, the luminosities are calculated by semi-analytic spectra.

Returns:

Returns a dictionary with the following keys

  • lnu_star : Luminosity of the discrete stars
  • lnu_accdisk : Luminosity of the accretion disk
  • lnu_spot : Luminosity of the hot spot / boundary layer on the stellar surface
readStarsinp(fname='')

Reads the data of discrete stellar sources from the stars.inp file.

Parameters:

fname : str, optional

File name of the file that should be read (if omitted stars.inp will be used)

readStellarsrcDensity(fname='', binary=False)

Reads the stellar density of a continuous starlike source.

Parameters:

fname : str, optional

Name of the file from which the stellar templates will be read. If omitted the default ‘stellarsrc_templates.inp’ will be used.

binary : bool, optional

If True the file should contain a C-style binary stream, if False the file should be written as formatted ASCII

readStellarsrcTemplates(fname='stellarsrc_templates.inp')

Reads the stellar template of a continuous starlike source.

Parameters:

fname : str, optional

Name of the file from which the stellar templates will be read. If omitted the default ‘stellarsrc_templates.inp’ will be used.

writeStarsinp(ppar=None, wav=None, freq=None, old=False)

Writes the input file for discrete stellar sources (stars.inp).

Parameters:

ppar : dictionary

Dictionary containing all parameters of the model (only mandatory if accretion is switched on)

wav : ndarray, optional

Wavelength grid for the stellar spectrum

freq : ndarray, optional

Frequency grid for the stellar spectrum (either freq or wav should be set)

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

writeStellarsrcDensity(fname='', binary=False)

Writes the stellar density of a continuous starlike source.

Parameters:

fname : str, optional

Name of the file into which the stellar templates will be written. If omitted the default ‘stellarsrc_templates.inp’ will be used.

binary : bool, optional

If True the output will be written in a C-style binary stream, if False the output will be formatted ASCII

writeStellarsrcTemplates(fname='stellarsrc_templates.inp')

Writes the stellar template of a continuous starlike source.

Parameters:

fname : str, optional

Name of the file into which the stellar templates will be written. If omitted the default ‘stellarsrc_templates.inp’ will be used.

radmc3dPy.analyze.readData(ddens=False, dtemp=False, gdens=False, gtemp=False, gvel=False, ispec=None, vturb=False, grid=None, binary=True, old=False, octree=False)

Reads the physical variables of the model (e.g. density, velocity, temperature).

Parameters:

ddens : bool

If True dust density will be read (all dust species and grain sizes)

dtemp : bool

If True dust temperature will be read (all dust species and grain sizes)

gdens : bool

If True gas density will be read (NOTE: the gas density will be number density in 1/cm^3)

gtemp : bool

If True gas temperature will be read (all dust species and grain sizes)

gvel : bool

If True the velocity field will be read

ispec : str

Name of the molecule in the ‘molecule_ispec.inp’ filename

grid : radmc3dGrid

An instance of radmc3dGrid containing the spatial and frequency grid of the model. If the grid is passed to the function it will not be read again from file. This can be useful for octree models to save time.

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

binary: bool

Set it to True for C-style binary and False for formatted ASCII files

octree: bool

True for models with octree AMR and False for models with regular grid

Returns:

Returns an instance of the radmc3dData class

radmc3dPy.analyze.readGrid(sgrid=True, wgrid=True)

Reads the spatial and frequency grid. This function is an interface to radmc3dGrid.readGrid().

Parameters:

sgrid : bool

If True the spatial grid will be read

wgrid : bool

If True the wavelength grid will be read

Returns:

Returns an instance of the radmc3dGrid (for regular grid) or radmc3dOctree (for octree AMR) class

radmc3dPy.analyze.readMol(mol='', fname='')

Wrapper around the radmc3dMolecule.read() method

Parameters:

mol : str

molecule name (e.g. ‘co’) if the file name is in the form of ‘molecule_<mol>.inp’

fname : str

full file name

radmc3dPy.analyze.readOpac(ext=[''], idust=None, scatmat=None, old=False)

Reads the dust opacity files. This function is an interface to radmc3dDustOpac.readOpac()

Parameters:

ext : list

Each element of the list is be a string, the file name extension (file names should look like ‘dustkappa_ext.inp’)

idust : list

Each element of the list is an integer, the index of the dust species in the master opacity file (dustopac.inp’)

scatmat: list

If specified, its elements should be booleans indicating whether the opacity file contains also the full scattering matrix (True) or only dust opacities (False)

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

Returns:

Returns an instance of the radmc3dDustOpac class

radmc3dPy.analyze.readParams()

Reads the problem_params.inp file. This function is an interface to radmc3dPar.readPar().

Returns:Returns an instance of the radmc3dPar class
radmc3dPy.analyze.readSpectrum(fname='', old=False)

Reads the spectrum / SED

Parameters:

fname : str, optional

Name of the file to be read

old : bool, optional

If set to True the file format of the previous, 2D version of radmc will be used

Returns:

Returns an ndarray with [Nwavelength, 2] dimensions

[Nwavelength,0] is the wavelength / velocity and [Nwavelength,1] is the flux density

radmc3dPy.analyze.writeDefaultParfile(model='', fname='')

Writes a parameter file (problem_params.inp) with default parameters for a given model.

Parameters:

model : str

Name of the model whose parameter should be written to the file

fname : str, optional

Name of the parameter file to be written (if omitted problem_params.inp will be used)

radmc3dPy.conf module

radmc3dPy.crd_trans module

This module contains functions for coordinate transformations (e.g. rotation).

radmc3dPy.crd_trans.csrot(crd=None, ang=None, xang=0.0, yang=0.0, zang=0.0, deg=False)

Performs coordinate system rotation.

Parameters:

crd : numpy ndarray

three element vector containing the coordinates of a given point in a cartesian system

ang : list, numpy ndarray

three element array, angles of rotation around the x,y,z axes

deg : float, optional

If True angles should be given in degree instead of radians (as by default)

Returns:

list

Returns a three element list with the rotated coordinates

Notes

Rotation matrices

Around the x-axis:

\[\begin{split}\left(\begin{matrix} 1 & 0 & 0 \\ 0 & cos(\alpha) & -sin(\alpha)\\ 0 & sin(\alpha) & cos(\alpha) \end{matrix}\right)\end{split}\]

Around the y-axis:

\[\begin{split}\left(\begin{matrix} cos(\beta) & 0 & -sin(\beta) \\ 0 & 1 & 0\\ sin(\beta)& 0 & cos(\beta) \end{matrix}\right)\end{split}\]

Around the z-axis

\[\begin{split}\left(\begin{matrix} cos(\gamma) & -sin\gamma) & 0 \\ sin(\gamma) & cos(\gamma) & 0 \\ 0 & 0 & 1 \end{matrix}\right)\end{split}\]
radmc3dPy.crd_trans.ctrans_sph2cart(crd=[0, 0, 0], reverse=False)

Transform coordinates between spherical to cartesian systems

Parameters:

crd : ndarray

Three element array containing the input coordinates [x,y,z] or [r,theta,phi] by default the coordinates assumed to be in the cartesian system

reverse : bool

If True calculates the inverse trasnformation (cartesian -> spherical). In this case crd should be [r,theta,phi]

Returns:

Returns a three element array containg the output coordinates [r,theta,phi] or [x,y,z]

radmc3dPy.crd_trans.ctrans_sph2cyl(crd=None, reverse=False)

Transform coordinates between spherical to cylindrical systems

Parameters:

crd : ndarray

Three element array containing the input coordinates [r,phi,theta] or [r, phi, z] if reverse is True

reverse : bool

If True it calculates the inverse trasnformation (cylindrical -> spherical). In this case crd should be [r,phi,z]

Returns:

Returns a numpy array of [Nr,Nphi,Ntheta,3] dimensions containing the cylindrical

coordinates [rcyl, z, phi]

radmc3dPy.crd_trans.vrot(crd=None, v=None, ang=None)

Rotates a vector in spherical coordinate system. First transforms the vector to cartesian coordinate system, then does the rotation then makes the inverse transformation

Parameters:

crd : ndarray

Three element array containing the coordinates of a given point in the cartesian system

v : ndarray

Three element array, angles of rotation around the x,y,z axes

ang : ndarray

Three element arrray containing the angles to rotate around the x, y, z, axes, respectively

radmc3dPy.crd_trans.vtrans_sph2cart(crd=[0, 0, 0], v=[0, 0, 0], reverse=False)

Transform velocities between spherical to cartesian systems

Parameters:

crd : ndarray

Three element array containing the input coordinates [x,y,z] or [r,theta,phi] by default the coordinates assumed to be in the cartesian system

v : ndarray

Three element array containing the input velocities in the same coordinate system as crd

reverse : bool

If True it calculates the inverse trasnformation (cartesian -> spherical)

Returns:

Returns a three element array containg the output velocities [vr,vphi,vtheta] or [vx,vy,vz]

radmc3dPy.image module

This module contains classes/functions to create and read images with RADMC-3D and to calculate interferometric visibilities and write fits files For help on the syntax or functionality of each function see the help of the individual functions

radmc3dPy.image.cmask(im=None, rad=0.0, au=False, arcsec=False, dpc=None)
Simulates a coronographic mask.
Sets the image values to zero within circle of a given radius around the image center.
Parameters:

im : radmc3dImage

A radmc3dImage class containing the image

rad : float

The raadius of the mask

au : bool

If true the radius is taken to have a unit of AU

arcsec : bool

If true the radius is taken to have a unit of arcsec (dpc should also be set)

dpc : float

Distance of the source (required if arcsec = True)

NOTE: if arcsec=False and au=False rad is taken to have a unit of pixel

Returns:

Returns a radmc3dImage class containing the masked image

radmc3dPy.image.getPSF(nx=None, ny=None, psfType='gauss', pscale=None, fwhm=None, pa=None, tdiam_prim=8.2, tdiam_sec=0.94, wav=None)

Calculates a two dimensional Gaussian PSF.

Parameters:

nx : int

Image size in the first dimension

ny : int

Image size in the second dimension

psfType : {‘gauss’, ‘airy’}

Shape of the PSF. If psfType=’gauss’, fwhm and pa should also be given. If psfType=’airy’, the tdiam_prim, tdiam_sec and wav parameters should also be specified.

pscale : float

Pixelscale of the image, if set fwhm should be in the same unit, if not set unit of fwhm is pixels

fwhm : list, optional

Full width at half maximum of the psf along the two axis (should be set only if psfType=’gauss’)

pa : float, optional

Position angle of the gaussian if the gaussian is not symmetric (should be set only if psfType=’gauss’)

tdiam_prim : float, optional

Diameter of the primary aperture of the telescope in meter. (should be set only if psfType=’airy’)

tdiam_sec : float, optional

Diameter of the secondary mirror (central obscuration), if there is any, in meter. If no secondary mirror/obscuration is present, this parameter should be set to zero. (should be set only if psfType=’airy’)

wav : float, optional

Wavelength of observation in micrometer (should be set only if psfType=’airy’)

Returns:

Returns a dictionary with the following keys:

  • psf
    : ndarray

    The two dimensional psf

  • x
    : ndarray

    The x-axis of the psf

  • y
    : ndarray

    The y-axis of the psf

radmc3dPy.image.makeImage(npix=None, incl=None, wav=None, sizeau=None, phi=None, posang=None, pointau=None, fluxcons=True, nostar=False, noscat=False, widthkms=None, linenlam=None, vkms=None, iline=None, lambdarange=None, nlam=None, stokes=False, binary=False)

Calculates a rectangular image with RADMC-3D

Parameters:

npix : int

Number of pixels on the rectangular images

sizeau : float

Diameter of the image in au

incl : float

Inclination angle of the source

wav : float

Wavelength of the image in micron

phi : float, optional

Azimuthal rotation angle of the source in the model space

posang : float, optional

Position angle of the source in the image plane

pointau : Float, optional

Three elements list of the cartesian coordinates of the image center

widthkms : float, optional

Width of the frequency axis of the channel maps

linenlam : int, optional

Number of wavelengths to calculate images at

vkms : float, optional

A single velocity value at which a channel map should be calculated

iline : int, optional

Line transition index

lambdarange : list, optional

Two element list with the wavelenght boundaries between which multiwavelength images should be calculated

nlam : int, optional

Number of wavelengths to be calculated in lambdarange

fluxcons : bool, optional

This should not even be a keyword argument, it ensures flux conservation (adaptive subpixeling) in the rectangular images

nostar : bool, optional

If True the calculated images will not contain stellar emission

noscat : bool, optional

If True, scattered emission will be neglected in the source function, however,

extinction will contain scattering if kappa_scat is not zero.

stokes : bool, optional

If True, images in all four stokes parameters (IQUV) will be calculated, if False only the intensity will be calculated

binary : bool, optional

If True the output image will be written in a C-style binary format, if False the image format will be ASCII

radmc3dPy.image.plotImage(image=None, arcsec=False, au=False, log=False, dpc=None, maxlog=None, saturate=None, bunit='norm', ifreq=0, cmask_rad=None, interpolation='nearest', cmap=<matplotlib.colors.LinearSegmentedColormap object>, stokes='I', poldir=False, pdcolor='w', pdnx=20, pdny=20, **kwargs)

Plots a radmc3d image.

Parameters:

image : radmc3dImage

A radmc3dImage class returned by readimage

arcsec : bool

If True image axis will have the unit arcsec (NOTE: dpc keyword should also be set!)

au : bool

If True image axis will have the unit AU

log : bool

If True image scale will be logarithmic, otherwise linear

dpc : float

Distance to the source in parsec (This keywords should be set if arcsec=True, or bunit!=’norm’)

maxlog : float

Logarithm of the lowest pixel value to be plotted, lower pixel values will be clippde

saturate : float

Highest pixel values to be plotted in terms of the peak value, higher pixel values will be clipped

bunit : {‘norm’, ‘inu’, ‘snu’}

Unit of the image, (‘norm’ - Inu/max(Inu), ‘inu’ - Inu, ‘snu’ - Jy/pixel), default is ‘norm’

ifreq : int

If the image file/array consists of multiple frequencies/wavelengths ifreq denotes the index of the frequency/wavelength in the image array to be plotted

cmask_rad : float

Simulates coronographyic mask : sets the image values to zero within this radius of the image center The unit is the same as the image axis (au, arcsec, cm) NOTE: this works only on the plot, the image array is not changed (for that used the cmask() function)

interpolation : str

interpolation keyword for imshow (e.g. ‘nearest’, ‘bilinear’, ‘bicubic’)

cmap : matplotlib color map

stokes : {‘I’, ‘Q’, ‘U’, ‘V’, ‘PI’}

What to plot for full stokes images, Stokes I/Q/U/V or PI - polarised intensity

radmc3dPy.image.plotPolDir(image=None, arcsec=False, au=False, dpc=None, ifreq=0, cmask_rad=None, color='w', nx=20, ny=20)

Function to plot the polarisation direction for full stokes images

Parameters:

image : radmc3dImage

A radmc3dImage class returned by readimage

arcsec : bool

If True image axis will have the unit arcsec (NOTE: dpc keyword should also be set!)

au : bool

If True image axis will have the unit AU

dpc : float

Distance to the source in parsec (This keywords should be set if arcsec=True, or bunit!=’norm’)

ifreq : int

If the image file/array consists of multiple frequencies/wavelengths ifreq denotes the index of the frequency/wavelength in the image array to be plotted

cmask_rad : float

Simulates coronographyic mask : sets the image values to zero within this radius of the image center The unit is the same as the image axis (au, arcsec, cm) NOTE: this works only on the plot, the image array is not changed (for that used the cmask() function)

color : str

Color for the polarisation direction plot

nx : int

Number of grid points along the horizontal axis at which the direction should be displayed

ny : int

Number of grid points along the vertical axis at which the direction should be displayed

class radmc3dPy.image.radmc3dImage

Bases: object

RADMC-3D image class

Attributes

image (ndarray) The image as calculated by radmc3d (the values are intensities in erg/s/cm^2/Hz/ster)
imageJyppix (ndarray) The image with pixel units of Jy/pixel
x (ndarray) x coordinate of the image [cm]
y (ndarray) y coordinate of the image [cm]
nx (int) Number of pixels in the horizontal direction
ny (int) Number of pixels in the vertical direction
sizepix_x (float) Pixel size in the horizontal direction [cm]
sizepix_y (float) Pixel size in the vertical direction [cm]
nfreq (int) Number of frequencies in the image cube
freq (ndarray) Frequency grid in the image cube
nwav (int) Number of wavelengths in the image cube (same as nfreq)
wav (ndarray) Wavelength grid in the image cube

Methods

getClosurePhase([bl, pa, dpc]) Calculates clusure phases for a given model image for any arbitrary baseline triplet.
getMomentMap([moment, nu0, wav0]) Calculates moment maps.
getVisibility([bl, pa, dpc]) Calculates visibilities for a given set of projected baselines and position angles with Discrete Fourier Transform.
imConv([dpc, psfType, fwhm, pa, tdiam_prim, ...]) Convolves a RADMC-3D image with a two dimensional Gaussian psf.
plotMomentMap([moment, nu0, wav0, dpc, au, ...]) Plots moment maps
readImage([fname, binary, old]) Reads an image calculated by RADMC-3D
writeFits([fname, dpc, coord, bandwidthmhz, ...]) Writes out a RADMC-3D image data in fits format.
getClosurePhase(bl=None, pa=None, dpc=None)

Calculates clusure phases for a given model image for any arbitrary baseline triplet.

Parameters:

bl : list/ndarray

A list or ndrray containing the length of projected baselines in meter.

pa : list/ndarray

A list or Numpy array containing the position angles of projected baselines in degree.

dpc : distance of the source in parsec

Returns:

Returns a dictionary with the following keys:

  • bl : projected baseline in meter
  • pa : position angle of the projected baseline in degree
  • nbl : number of baselines
  • u : spatial frequency along the x axis of the image
  • v : spatial frequency along the v axis of the image
  • vis : complex visibility at points (u,v)
  • amp : correlation amplitude
  • phase : Fourier phase
  • cp : closure phase
  • wav : wavelength
  • nwav : number of wavelengths

Notes

bl and pa should either be an array with dimension [N,3] or if they are lists each element of the list should be a list of length 3, since closure phases are calculated only for closed triangles

getMomentMap(moment=0, nu0=0, wav0=0)

Calculates moment maps.

Parameters:

moment : int

Moment of the channel maps to be calculated

nu0 : float

Rest frequency of the line in Hz

wav0 : float

Rest wavelength of the line in micron

Returns:

Ndarray with the same dimension as the individual channel maps

getVisibility(bl=None, pa=None, dpc=None)

Calculates visibilities for a given set of projected baselines and position angles with Discrete Fourier Transform.

Parameters:

bl : list/ndarray

A list or ndrray containing the length of projected baselines in meter.

pa : list/ndarray

A list or Numpy array containing the position angles of projected baselines in degree.

dpc : distance of the source in parsec

Returns:

Returns a dictionary with the following keys:

  • bl : projected baseline in meter
  • pa : position angle of the projected baseline in degree
  • nbl : number of baselines
  • u : spatial frequency along the x axis of the image
  • v : spatial frequency along the v axis of the image
  • vis : complex visibility at points (u,v)
  • amp : correlation amplitude
  • phase : Fourier phase
  • wav : wavelength
  • nwav : number of wavelengths
imConv(dpc=1.0, psfType='gauss', fwhm=None, pa=None, tdiam_prim=8.2, tdiam_sec=0.94)

Convolves a RADMC-3D image with a two dimensional Gaussian psf.

Parameters:

dpc : float

Distance of the source in pc.

psfType : {‘gauss’, ‘airy’}

Shape of the PSF. If psfType=’gauss’, fwhm and pa should also be given. If psfType=’airy’, the tdiam_prim, tdiam_sec and wav parameters should also be specified.

fwhm : list, optional

A list of two numbers; the FWHM of the two dimensional psf along the two principal axes. The unit is assumed to be arcsec. (should be set only if psfType=’gauss’)

pa : float, optional

Position angle of the psf ellipse (counts from North counterclockwise, should be set only if psfType=’gauss’)

tdiam_prim : float, optional

Diameter of the primary aperture of the telescope in meter. (should be set only if psfType=’airy’)

tdiam_sec : float, optional

Diameter of the secondary mirror (central obscuration), if there is any, in meter. If no secondary mirror/obscuration is present, this parameter should be set to zero. (should be set only if psfType=’airy’)

Returns:

Returns a radmc3dImage

plotMomentMap(moment=0, nu0=0, wav0=0, dpc=1.0, au=False, arcsec=False, cmap=None, vclip=None)

Plots moment maps

Parameters:

moment : int

Moment of the channel maps to be calculated

nu0 : float

Rest frequency of the line in Hz

wav0 : float

Rest wavelength of the line in micron

dpc : float

Distance of the source in pc

au : bool

If True displays the image with AU as the spatial axis unit

arcsec : bool

If True displays the image with arcsec as the spatial axis unit (dpc should also be set!)

cmap : matplotlib colormap

Color map to be used to display the moment map

vclip : list/ndarray

Two element list / Numpy array containin the lower and upper limits for the values in the moment

map to be displayed

readImage(fname=None, binary=False, old=False)

Reads an image calculated by RADMC-3D

Parameters:

fname : str, optional

File name of the radmc3d output image (if omitted ‘image.out’ is used)

old : bool

If set to True it reads old radmc-2d style image

binary : bool, optional

False - the image format is formatted ASCII if True - C-compliant binary (omitted if old=True)

writeFits(fname='', dpc=1.0, coord='03h10m05s -10d05m30s', bandwidthmhz=2000.0, casa=False, nu0=0.0, wav0=0.0, stokes='I', fitsheadkeys=[])

Writes out a RADMC-3D image data in fits format.

Parameters:

fname : str

File name of the radmc3d output image (if omitted ‘image.fits’ is used)

coord : str

Image center coordinates

bandwidthmhz : float

Bandwidth of the image in MHz (equivalent of the CDELT keyword in the fits header)

casa : bool

If set to True a CASA compatible four dimensional image cube will be written

nu0 : float

Rest frequency of the line (for channel maps)

wav0 : float

Rest wavelength of the line (for channel maps)

stokes : {‘I’, ‘Q’, ‘U’, ‘V’, ‘PI’}

Stokes parameter to be written if the image contains Stokes IQUV (possible choices: ‘I’, ‘Q’, ‘U’, ‘V’, ‘PI’ -Latter being the polarized intensity)

fitsheadkeys : dictionary

Dictionary containing all (extra) keywords to be added to the fits header. If the keyword is already in the fits header (e.g. CDELT1) it will be updated/changed to the value in fitsheadkeys, if the keyword is not present the keyword is added to the fits header.

radmc3dPy.image.readImage(fname=None, binary=False, old=False)
Reads an image calculated by RADMC-3D.
This function is an interface to radmc3dImage.readImage().
Parameters:

fname : str, optional

File name of the radmc3d output image (if omitted ‘image.out’ is used)

old
: bool

If set to True it reads old radmc-2d style image

binary
: bool, optional

False - the image format is formatted ASCII if True - C-compliant binary (omitted if old=True)

radmc3dPy.natconst module

This module contains natural constants in CGS units

Translated from RADMC’s IDL function problem_natconst.pro

List of natural constants:

Name Description
gg Gravitational constant
mp Mass of proton [g]
me Mass of electron [g]
kk Bolzmann’s constant [erg/K]
hh Planck’s constant [erg.s]
ee Unit charge
cc Light speed [cm/s]
st Thmpson cross-section [cm^2]
ss Stefan-Boltzmann const [erg/cm^2/K^4/s]
aa 4 * ss / cc
muh2 Mean molecular weight (H2 + He + metals)
ev Electronvolt [erg]
kev Kilo electronvolt [erg]
micr Micron [cm]
km Kilometer [cm]
angs Angstrom [cm]
ls Solar luminosity [erg/s]
rs Solar radius [cm]
ms Solar mass [g]
ts Solar effective temperature [K]
au Astronomical unit [cm]
pc Parsec [cm]
mea Mass of Earth [g]
rea Equatorila radius of Earth [cm]
mmo Mass of Moon [g]
rmo Radius of Moon [cm]
dmo Distance earth-moon (center-to-center) [cm]
mju Mass of Jupiter
rju Equatorial radius of Jupiter [cm]
dju Distance Jupiter-Sun [cm]
year Year [s]
hour Hour [s]
day Day [s]

radmc3dPy.setup module

This module contains functions to set up a RADMC-3D model for dust and/or line simulations. For help on the syntax or functionality of each function see the help of the individual functions

radmc3dPy.setup.problemSetupDust(model='', binary=True, writeDustTemp=False, old=False, dfunc=None, dfpar=None, **kwargs)

Function to set up a dust model for RADMC-3D

Parameters:

model : str

Name of the model that should be used to create the density structure. The file should be in a directory from where it can directly be imported (i.e. the directory should be in the PYTHON_PATH environment variable or it should be in the current working directory) and the file name should be ‘model_xxx.py’, where xxx stands for the string that should be specified in this variable

binary : bool, optional

If True input files will be written in binary format, if False input files are written as formatted ascii text.

writeDustTemp : bool, optional

If True a separate dust_temperature.inp/dust_tempearture.binp file will be written under the condition that the model contains a function getDustTemperature()

old : bool, optional

If set to True the input files for the old 2D version of radmc will be created

dfunc : function, optional

Decision function for octree-like amr tree building. It should take linear arrays of cell centre coordinates (x,y,z) and cell half-widhts (dx,dy,dz) in all three dimensions, a radmc3d model, a dictionary with all parameters from problem_params.inp and an other keyword argument (**kwargs). It should return a boolean ndarray of the same length as the input coordinates containing True if the cell should be resolved and False if not. An example for the implementation of such decision function can be found in radmc3dPy.analyze module (radmc3dPy.analyze.gdensMinMax()).

dfpar : dictionary

Dicionary of keyword arguments to be passed on to dfunc. These parameters will not be written to problem_params.inp. Parameters can also be passed to dfunc via normal keyword arguments gathered in **kwargs, however all keyword arguments in **kwargs will be written to problem_params.inp

**kwargs : Any varible name in problem_params.inp can be used as a keyword argument.

At first all variables are read from problem_params.in to a dictionary called ppar. Then if there is any keyword argument set in the call of problem_setup_dust the ppar dictionary is searched for this key. If found the value belonging to that key in the ppar dictionary is changed to the value of the keyword argument. If no such key is found then the dictionary is simply extended by the keyword argument. Finally the problem_params.inp file is updated with the new parameter values.

Notes

Files written by problemSetupDust() for RADMC-3D

  • dustopac.inp : Dust opacity master file.
  • wavelength_micron.inp : Wavelength grid.
  • amr_grid.inp : Spatial grid.
  • stars.inp : Input radiation field (discrete stellar sources).
  • stellarsrc_density.inp : Input radiation field (continuous stellar sources).
  • stellarsrc_templates.inp : Input radiation field (continuous stellar sources).
  • dust_density.inp : Dust density distribution.
  • radmc3d.inp : Parameters for RADMC-3D (e.g. Nr of photons to be used, scattering type, etc).
radmc3dPy.setup.problemSetupGas(model='', fullsetup=False, binary=True, writeGasTemp=False, dfunc=None, dfpar=None, **kwargs)

Function to set up a gas model for RADMC-3D

Parameters:

model : str

Name of the model that should be used to create the density structure the file should be in a directory from where it can directly be imported (i.e. the directory should be in the PYTHON_PATH environment variable, or it should be the current working directory) and the file name should be ‘MODELNAME.py’, where MODELNAME stands for the string that should be specified in this variable

fullsetup : bool, optional

If False only the files related to the gas simulation is written out (i.e. no grid, stellar parameter file and radmc3d master command file is written) assuming that these files have already been created for a previous continuum simulation. If True the spatial and wavelength grid as well as the input radiation field and the radmc3d master command file will be (over)written.

binary : bool, optional

If True input files will be written in binary format, if False input files are written as formatted ascii text.

writeGasTemp : bool, optional

If True a separate gas_temperature.inp/gas_tempearture.binp file will be written under the condition that the model contains a function get_gas_temperature()

dfunc : function, optional

Decision function for octree-like amr tree building. It should take linear arrays of cell centre coordinates (x,y,z) and cell half-widhts (dx,dy,dz) in all three dimensions, a radmc3d model, a dictionary with all parameters from problem_params.inp and an other keyword argument (**kwargs). It should return a boolean ndarray of the same length as the input coordinates containing True if the cell should be resolved and False if not. An example for the implementation of such decision function can be found in radmc3dPy.analyze module (radmc3dPy.analyze.gdensMinMax()).

dfpar : dictionary

Dicionary of keyword arguments to be passed on to dfunc. These parameters will not be written to problem_params.inp. Parameters can also be passed to dfunc via normal keyword arguments gathered in **kwargs, however all keyword arguments in **kwargs will be written to problem_params.inp

**kwargs : Any varible name in problem_params.inp can be used as a keyword argument.

At first all variables are read from problem_params.in to a dictionary called ppar. Then if there is any keyword argument set in the call of problem_setup_gas the ppar dictionary is searched for such key. If found the value belonging to that key in the ppar dictionary is changed to the value of the keyword argument. If no such key is found then the dictionary is simply extended by the keyword argument. Finally the problem_params.inp file is updated with the new parameter values. Any additional keyword argument for the octree AMR mesh generation should also be passed here.

Notes

Files written by problemSetupGas()

  • lines.inp : Line mode master command file.

  • numberdens_xxx.inp : Number density of molecule/atomic species ‘xxx’

  • gas_velocity.inp : Gas velocity

  • microturbulence.inp
    : The standard deviation of the Gaussian line profile caused by turbulent

    broadening.

  • gas_temperature.inp
    : Gas temperature (which may be different from the dust temperature). If

    tgas_eq_tdust is set to zero in radmc3d.inp the gas temperature in this file will be used instead of the dust temperature.

If fullsetup is set to True the following additional files will be created

  • amr_grid.inp : Spatial grid.
  • wavelength_micron.inp : Wavelength grid.
  • stars.inp : Input radiation field.
  • radmc3d.inp : Parameters for RADMC-3D (e.g. Nr of photons to be used, scattering type, etc).
radmc3dPy.setup.validateModel(model='', dustModel=False, gasModel=False, writeDustTemp=False, octree=False)

Function to validate a model. It checks three things: 1) whether or not the model can be imported, 2) whether the model has all the function to be used as dust and/or gas model, 3) if it has the right number of arguments. The function names tested are getDefaultParams, getDustDensity, getGasDensity, getGasAbundance, getVTurb, getVelocity, getDustTempearture (optional).

Parameters:

model : str

Name of the model to be tested

dustModel : bool

If True the existence of functions getDustDensity() and getDustTemperature() will be checked. The latter is only checked if writeDustTemp is set to True.

gasModel : bool

If True the existence of functions getGasDensity(), getGasAbundance(), getVTurb(), getVelocity() will be checked.

writeDustTemp: bool

If True the existence of the function getDustTemperature() will be checked.

octree : bool

If True the number of argument of the model functions will be checked. For regular grids only two arguments should be present for the grid instance and for the parameter dictionary (grid, ppar). For a model to be used with octree AMR three additional arguments for the three spatial coordiantes (x,y,z) should be present. The argument sequence should then be x, y, z, grid, ppar.

Returns:

A boolean True if the model is valid and False if it is not.

radmc3dPy.setup.writeLinesInp(ppar=None)

Writes the lines.inp master command file for line simulation in RADMC-3D

Parameters:

ppar : dictionary,

Contains all parameters of a RADMC-3D run

radmc3dPy.setup.writeRadmc3dInp(modpar=None)

Writes the radmc3d.inp master command file for RADMC-3D

Parameters:

ppar : dictionary

Contains all parameters of a RADMC-3D run.

radmc3dPy.setup.writeRadmcInp(modpar=None, nphot=None)

Writes the radmc.inp master command file for the 2D version of radmc

Parameters:

ppar : dictionary

Contains all parameters of a radmc run.

nphot : int

Number of photons used for the MC simulation

radmc3dPy.staratm module

class radmc3dPy.staratm.StellarAtm

Class for stellar atmosphere models

Attributes

kuruczDir (str) Full path to the Kurucz model atmospheres I.e. the path to the files (*.pck)
nextgenDir (str) Full path to the NextGen model atmospheres The model spectra has to be gzipped, i.e. the nextgenDir is the full path to the files like nlte98-4.5-2.5.NextGen.spec.gz. The NextGen spectra can be downloaded in this gzipped format from France Allard’s website (http://perso.ens-lyon.fr/france.allard/)

Methods

getAtmModel([teff, logg, mstar, lstar, ...]) Interpolates the stellar model atmosphere on a pre-defined wavelength grid
getSpectrumKurucz([teff, logg, lstar, ...]) Interpolates the Kurucz model atmospheres in logg and Teff
getSpectrumNextGen([teff, logg, lstar, ...]) Interpolates the NextGen model atmospheres in logg and Teff
readKuruczGrid([fname]) Reads the Kurucz model atmosphere grid.
readNextGenSpectrum([fname]) Reads the NextGen model atmosphere.
rebinSpectrum([wav, fnu, iwav]) Rebins the spectrum to a coarser wavelength grid
getAtmModel(teff=0.0, logg=None, mstar=None, lstar=None, rstar=None, iwav=None, model='kurucz', wmax=7.0)

Interpolates the stellar model atmosphere on a pre-defined wavelength grid The model atmospheres are interpolated in logg and Teff and rebinned in wavelength to the input wavelength grid and scaled to have the same luminosity as specified

Parameters:

teff : float

Effective temperature of the star

logg : float

Logarithm of the surface gravity of the star

mstar : float

Mass of the star in gramm

lstar : float, optional

Luminosity of the star (either lstar or rstar should be specified)

rstar : float, optional

Radius of the star (either lstar or rstar should be specified)

iwav : ndarray

Wavelength grid for which the stellar atmosphere model should be calculated

model : {‘kurucz’, ‘nextgen’}

Name of the model atmosphere family

wmax : float

Maximum wavelength until the model atmosphere is used on the interpolated grid Longwards of this wavelength the Rayleigh-Jeans approximation (lambda^(-2)) is used.

Returns:

Returns a dictionary with the following keys:

  • wav
    : ndarray

    Wavelength in micron (same as the input iwav keyword)

  • lnu
    : ndarray

    Monochromatic luminosity of the stellar atmosphere in erg/s/Hz

getSpectrumKurucz(teff=0.0, logg=0.0, lstar=None, rstar=None, wav=None)

Interpolates the Kurucz model atmospheres in logg and Teff

Parameters:

teff : float

Effective temperature of the star

logg : float

Logarithm of the surface gravity of the star

lstar : float, optional

Luminosity of the star (either lstar or rstar should be specified)

rstar : float, optional

Radius of the star (either lstar or rstar should be specified)

wav : ndarray

Wavelength grid for which the stellar atmosphere model should be calculated

Returns:

Returns a dictionary with the following keys:

  • wav
    : ndarray

    Wavelength in micron (same as the input wav keyword)

  • lnu
    : ndarray

    Monochromatic luminosity of the stellar atmosphere in erg/s/Hz

  • lnucont
    : ndarray

    Monochromatic luminosity of the continuum stellar atmosphere in erg/s/Hz

getSpectrumNextGen(teff=0.0, logg=0.0, lstar=None, rstar=None, wav=None)

Interpolates the NextGen model atmospheres in logg and Teff

Parameters:

teff : float

Effective temperature of the star

logg : float

Logarithm of the surface gravity of the star

lstar : float, optional

Luminosity of the star (either lstar or rstar should be specified)

rstar : float, optional

Radius of the star (either lstar or rstar should be specified)

wav : ndarray

Wavelength grid for which the stellar atmosphere model should be calculated

Returns:

Returns a dictionary with the following keys:

  • wav
    : ndarray

    Wavelength in micron (same as the input wav keyword)

  • lnu
    : ndarray

    Monochromatic luminosity of the stellar atmosphere in erg/s/Hz

  • bnu
    : ndarray

    Monochromatic luminosity of a blackbody stellar atmosphere with the same luminosity and effective temperature as the stellar model in erg/s/Hz

readKuruczGrid(fname='')

Reads the Kurucz model atmosphere grid. It reads a whole file from the Kurucz grid that contains a 2D grid of atmosphere models for Teff and logg.

Parameters:

fname : str

File name containing the Kurucz model atmosphere (e.g. fp00k2.pck)

Returns:

Returns a dictionary with the following keys:

  • wav
    : ndarray

    Wavelength in micron

  • nwav
    : int

    Number of wavelength points

  • inu
    : list

    Each element of the list contains an ndarray with the specific intensity of the stellar model atmosphere in erg/s/cm/cm/Hz/ster

  • inucont
    : list

    Each element of the list contains an ndarray with the specific intensity of the stellar model atmosphere continuum in erg/s/cm/cm/Hz/ster

  • teff
    : list

    Contains the Teff grid of the model grid

  • logg
    : list

    Contains the logg grid of the model grid

readNextGenSpectrum(fname='')

Reads the NextGen model atmosphere.

Parameters:

fname : str

File name containing the NextGen model atmosphere (e.g. nlte98-4.5-2.5.NextGen.spec)

Returns:

Returns a dictionary with the following keys:

  • wav
    : ndarray

    Wavelength in micron

  • nwav
    : int

    Number of wavelength points

  • inu
    : ndarray

    Specific intensity of the stellar model atmosphere in erg/s/cm/cm/Hz/ster

  • bnu
    : list

    Specific intensity of a blackbody stellar model atmosphere with the same luminosity and the same effective temperature in erg/s/cm/cm/Hz/ster

  • teff
    : float

    Effective temperature of the model

  • logg
    : float

    Logarithm of the surface gravity of the model

  • mph
    : float

    Metallicity of the atmosphere model

rebinSpectrum(wav=None, fnu=None, iwav=None)

Rebins the spectrum to a coarser wavelength grid

Parameters:

wav : ndarray

Wavelength grid of the spectrum to be rebinned

fnu : ndarray

Wavelength dependent spectrum (e.g. specific intensity, monochromatic luminosity etc) to be rebbinned

iwav : ndarray

Wavelength grid onto which the spectrum should be rebinned (it is assumed to be logarithmically spaced)

Returns:

Returns an ndarray containing the spectrum rebinned to the input wavelength grid

Module contents

RADMC-3D Python module (c) Attila Juhasz, 2011-2017