radmc3dPy package¶
Subpackages¶
- radmc3dPy.models package
- Submodules
- radmc3dPy.models.lines_nlte_lvg_1d_1 module
- radmc3dPy.models.ppdisk module
- radmc3dPy.models.ppdisk_acc module
- radmc3dPy.models.simple_1 module
- radmc3dPy.models.spher1d_1 module
- radmc3dPy.models.spher2d_1 module
- radmc3dPy.models.template module
- radmc3dPy.models.test_scattering_1 module
- Module contents
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.
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
-
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
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])Reads the dust density. readDustTemp
([fname, binary, old])Reads the dust temperature. readGasDens
([ispec, binary])Reads the gas density. readGasTemp
([fname, binary])Reads the gas temperature. readGasVel
([fname, binary])Reads the gas velocity. readVTurb
([fname, binary])Reads the turbulent velocity field. writeDustDens
([fname, binary, old])Writes the dust density. writeDustTemp
([fname, binary])Writes the dust density. writeGasDens
([fname, ispec, binary])Writes the gas density. writeGasTemp
([fname, binary])Writes the gas temperature. writeGasVel
([fname, binary])Writes the gas velocity. writeVTK
([vtk_fname, ddens, dtemp, idust, ...])Writes physical variables to a legacy vtk file. writeVTurb
([fname, binary])Writes the microturbulence file. -
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)¶ 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
-
readDustTemp
(fname='', binary=True, old=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
-
readGasDens
(ispec='', binary=True)¶ 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
-
readGasTemp
(fname='', binary=True)¶ 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
-
readGasVel
(fname='', binary=True)¶ 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
-
readVTurb
(fname='', binary=True)¶ 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
-
writeDustDens
(fname='', binary=True, old=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
-
writeDustTemp
(fname='', binary=True)¶ 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
-
writeGasDens
(fname='', ispec='', binary=True)¶ 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
-
writeGasTemp
(fname='', binary=True)¶ 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
-
writeGasVel
(fname='', binary=True)¶ 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
-
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)¶ 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
-
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:
-
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
([fname, old])Reads the spatial (amr_grid.inp) and frequency grid (wavelength_micron.inp). 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
(fname='', old=False)¶ Reads the spatial (amr_grid.inp) and frequency grid (wavelength_micron.inp).
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
-
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.
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, binary=True, old=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
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 radmc3dData class
-
radmc3dPy.analyze.
readGrid
()¶ Reads the spatial and frequency grid. This function is an interface to radmc3dGrid.readGrid().
Returns: Returns an instance of the radmc3dGrid class
-
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', **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)
cmap : matplotlib color map
interpolation : str
interpolation keyword for imshow (e.g. ‘nearest’, ‘bilinear’, ‘bicubic’)
-
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
Options
——-
binary : bool
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
False - the image format is formatted ASCII if True - C-compliant binary (omitted if old=True)
radmc3dPy.makeopac module¶
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, **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
**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, **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()
**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.
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.
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-2016