Full API documentation

cgs module

class cgs.cgs[source]

Accessors for values of common astronomical quantities in CGS (centimeters-grams-seconds) units.

configuration module

class configuration.Radmc3dConfiguration[source]

Simple container class for the RADMC3D configuration. Both member assignment and retrieval are supported, but no validation is done on the set values.

write(io)[source]

Writes the encapsulated configuration to the file radmc3d.inp.

Parameters:io (Radmc3dIo) – Global I/O instance

coordsys module

class coordsys.CartesianCoordinates(x, y, z)[source]

Bases: coordsys.Coordinates

Basic container class for Cartesian coordinates.

Parameters:
  • x – The x-coordinate; may be a float type or NumPy array
  • y – The y-coordinate; may be a float type or NumPy array
  • z – The z-coordinate; may be a float type or NumPy array
class coordsys.Coordinates[source]

Bases: object

Base class for coordinate containers. All coordinates are expected to be stored as Cartesian regardless of the coordinate system. This class is then responsible for converting to any supported coordinate system.

transformTo(sys)[source]

Transforms the coordinates stored in this container to the coordinate system specified.

Parameters:sys (Coordinates) – The coordinate system to transform to
class coordsys.CylindricalCoordinates(s, phi, z)[source]

Bases: coordsys.Coordinates

Basic container class for cylindrical coordinates.

Parameters:
  • s – The radial coordinate; may be a float type or NumPy array
  • phi – The azimuthal coordinate; may be a float type or NumPy array
  • z – The vertical coorindate; may be a float type or NumPy array
class coordsys.SphericalCoordinates(r, theta, phi)[source]

Bases: coordsys.Coordinates

Basic container class for spherical polar coordinates.

Parameters:
  • r – The radial coordinate; may be a float type or NumPy array
  • theta – The latitudinal coordinate; may be a float type or NumPy array
  • phi – The azimuthal coordinate; may be a float type or NumPy array

dust module

class dust.Radmc3dDustContainer[source]

Container for a variable number of dust species. To support friendly naming of dust species, this class inherits from dict so that new species can be added like so:

>>> c = Radmc3dDustContainer()
>>> c['some_name'] = SomeDustSpecies()

If a duplicate name is used, the previous species will be overwritten.

write(io, grid)[source]

Writes the current content of this container to input files for RADMC3D. This function uses the I/O context to determine the output format (binary or ASCII) and formats all files appropriately.

Parameters:
class dust.Radmc3dDustSpecies[source]

Base class from which all dust species definitions should inherit. For example, to define a new (and fairly contrived) species with density everywhere equal to the square of the distance from the center:

import radmc3d as r3d

class SomeDustSpecies(r3d.Radmc3dDustSpecies):
    def density(self, coords):
        rr, _, _ = coords.transformTo(r3d.SphericalCoordinates)
        return rr**2
density(coords)[source]

Evaluates the dust density (in \(\textrm{g} / \textrm{cm}^3\)) at each of the input coordinates. Vector operations are highly advised.

Parameters:coords (Coordinates) – The points at which to return the density
Returns:An array of densities
Return type:np.ndarray
Raises:NotImplementedError – if the user does not define a density function

fileio module

class fileio.Radmc3dIo[source]

Class defining common I/O operations needed by the module so that they can be carried out in a consistent way.

binary

True if input files should be binary; False if ASCII should be used instead. Note that this has no effect on the format of output files; for that setting, see rto_style().

clobber

True if existing files should be clobbered if they already exist, False otherwise.

dtype

Read-only; gives the current float data type as a NumPy dtype.

file_check_exists(target)[source]

Checks whether the given file exists.

Parameters:target (str) – A filename relative to the global output directory
Returns:True if the file exists, False otherwise
Return type:bool
file_open_read(target)[source]

Opens a file for reading; there is no need to check whether clobbering is safe in this case, because this is not a destructive operation.

Parameters:target (str) – A filename relative to teh global output directory
Returns:A file pointer to the open file
Return type:file
file_open_write(target)[source]

Opens a file for writing, checking whether it is safe to clobber any existing file by the same name before doing so.

Parameters:target (str) – A filename relative to the global output directory
Returns:A file pointer to the open file
Return type:file
fullpath(fname)[source]

Returns a “full path” (the concatenation of the output directory and given filename) to a file.

Parameters:fname (str) – The filename relative to the output directory
Returns:The filename relative to the initial directory
Return type:str
memmap(f, offset, dtype, shape, mode)[source]

Returns a memory map (in FORTRAN order, since RADMC3D uses this format exclusively) that can be used like an array but is written to a file in binary format.

Parameters:
  • f – A filename or file-like object; if a filename is given, it should be relative to the global output directory
  • offset (int) – Offset in the file (in bytes) at which the map should begin
  • dtype – The data type (np.float64 or np.float32) of the mapped array
  • shape (tuple) – A tuple representing the shape of the mapped array
  • mode (str) – The mode string, generally w+ for writing or r for reading only
Returns:

Memory map to the array

Return type:

numpy.core.memmap.memmap

outdir

The output directory, relative to the initial directory

precis

Read-only; gives the number of bytes of the current float data type.

precision

Set to double if double-precision input is desired; otherwise, set to single. Note that this has no effect on the format of output files; for that setting, see rto_single().

safe_check_clobber(target)[source]

Checks whether it is safe to clobber a file. If the user has specified that file clobbering is allowed or if the file does not exist, this method has no effect; otherwise, the user is prompted for each existing file and must approve clobbering to continue.

Parameters:target (str) – A filename relative to the global output directory
Raises:RuntimeError – if the user aborts clobbering

grid module

class grid.Radmc3dGrid[source]

Represents a RADMC3D grid. Currently, only regular grids are supported, but AMR and oct-tree grids may be added later.

cellcoords

Read-only; gives the cell coordinates of this grid. Currently, these are defined simply to be the midpoints of each dimension of the point coordinates.

coordsys

Set to one of CartesianCoordinates, SphericalCoordinates, or CylindricalCoordinates. Note that cylindrical coordinates, though documented in the RADMC3D manual, do not seem to be supported yet.

nrcells

Read-only; gives the total number of cells in this grid.

nu

Read-only; gives the number of cells in the u dimension.

nv

Read-only; gives the number of cells in the v dimension.

nw

Read-only; gives the number of cells in the w dimension.

ptcoords

Read-only; gives the point coordinates of this grid.

u

The first coordinate of the grid. This is called x in the RADMC3D manual; we use u here to avoid confusion with true Cartesian coordinates. Expects a NumPy array.

update_coords()[source]

Private function. Updates the definitions of the point and cell coordinates after a change to one of the coordinate arrays.

v

The first coordinate of the grid. This is called y in the RADMC3D manual; we use v here to avoid confusion with true Cartesian coordinates. Expects a NumPy array.

w

The first coordinate of the grid. This is called z in the RADMC3D manual; we use w here to avoid confusion with true Cartesian coordinates. Expects a NumPy array.

write(io)[source]

Writes a grid definition to a file.

Parameters:io (Radmc3dIo) – Current I/O context

render module

class render.Radmc3dVtkRender[source]

Renders the current input and output files as VTK output that can be visualized with VisIt and other VTK visualization software.

read_dust_density(io, grid)[source]

Private function. Reads the current dust density input file.

Parameters:
Returns:

A dictionary of name-array pairs for each dust species

Return type:

dict

Raises:

IOError – if a required file is not found

read_dust_temperature(io, grid)[source]

Private function. Reads the current dust temperature output file.

Parameters:
Returns:

A dictionary of name-array pairs for each dust species

Return type:

dict

Raises:

IOError – if a required file is not found

render(io, grid)[source]

Writes the VTK file for all variables that can be found in the output directory.

Parameters:

simulation module

class simulation.Radmc3dSimulation[source]

Primary class for carrying out simulations with RADMC3D.

commit()[source]

Writes the encapsulated data to files in the output directory, to be read by RADMC3D.

config

Accessor to the underlying configuration object.

dust

Accessor to the underlying dust container object.

grid

Accessor to the underlying grid object.

io

Accessor to the underlying I/O context object.

lmbda

Array of wavelengths at which to perform the simulation.

mctherm()[source]

Runs the mctherm command of RADMC3D.

render()[source]

Outputs a VTK file with all defined variables.

star

Accessor to the underlying star container object.

write_wavelengths()[source]

Private function; writes the list of wavelengths to a file.

star module

class star.Radmc3dBlackbodyStar(Teff=0.0, **kwargs)[source]

Bases: star.Radmc3dStar

Defines an ideal blackbody star, which is parametrized by only its effective temperature.

Parameters:Teff (float) – Effective temperature in Kelvin
Teff

Effective temperature of this star

write(f, lmbda)[source]

Writes the effective temperature to the open file handle.

class star.Radmc3dStar(center=<coordsys.CartesianCoordinates object>, mass=0.0, radius=0.0)[source]

Bases: object

Base class for a star definition.

Parameters:
  • center (Coordinates) – The coordinates of the center (can use any coordinate system; defaults to (0,0,0)
  • mass (float) – The mass of the star
  • radius (float) – The radius of the star
center

The coordinates of the center of this star; expects a subclass of Coordinates.

mass

The mass of this star

radius

The radius of this star

write(f, lmbda)[source]

Subclasses must define this method, which writes either the effective temperature or the flux to the given file handle in the format expected by RADMC3D.

Parameters:
  • f (file) – Open file handle
  • lmbda (np.ndarray) – Array of wavelengths
class star.Radmc3dStarContainer[source]

Bases: dict

Container for a variable number of stars. To support friendly naming of stars, this class inherits from dict so that new stars can be added like so:

>>> c = Radmc3dStarContainer()
>>> c[0] = Radmc3dBlackbodyStar()
>>> c[0].Teff = 5700.

String names can also be used instead of numeric indices. If a duplicate name is used, the previous star will be overwritten.

write(io, lmbda, grid)[source]

Writes the current content of this container to input files for RADMC3D. This function uses the I/O context to determine the output format (binary or ASCII) and formats all files appropriately.

Parameters:

vectorsys module