API Reference
Image
Line
- class pymcfost.line.Line(dir=None, line_file=None, **kwargs)[source]
Bases:
objectA class to handle MCFOST spectral line data.
This class reads and processes MCFOST line radiative transfer outputs, providing methods to plot channel maps, spectra, and calculate moment maps.
- Variables:
dir (str) – Directory containing MCFOST output files
lines (numpy.ndarray) – The line data cube
P (Params) – MCFOST parameter object
pixelscale (float) – Image pixel scale in arcsec
unit (str) – Unit of the line data
nx (int) – Number of pixels in x direction
ny (int) – Number of pixels in y direction
nv (int) – Number of velocity channels
velocity (numpy.ndarray) – Velocity array in km/s
freq (numpy.ndarray) – Frequency array in Hz
is_casa (bool) – Whether the data is in CASA format
star_positions (numpy.ndarray) – Array of stellar positions
extent (list) – Image extent for plotting [xmin, xmax, ymin, ymax]
Example
>>> line = Line(dir="path/to/mcfost/data") >>> line.plot_map(i=0, iaz=0, iTrans=0, iv=10)
- __init__(dir=None, line_file=None, **kwargs)[source]
Initialize a Line object.
- Parameters:
dir (str) – Path to directory containing MCFOST output
line_file (str, optional) – Name of line data file
**kwargs – Additional arguments passed to _read()
- get_moment_map(i=0, iaz=0, iTrans=0, moment=0, i_convolve=False, beam=None, conv_method=None, subtract_cont=False, M0_threshold=None, iv_support=None, v_minmax=None)[source]
Calculate a moment map from the line cube.
- Parameters:
moment (int) – Moment to compute: - 0: Integrated intensity - 1: Intensity-weighted velocity - 2: Velocity dispersion - 8: Peak intensity - 9: Velocity at peak intensity
iTrans (int) – Transition index
iv_support (array-like, optional) – Velocity channels to include
**kwargs – Additional arguments for convolution
- Returns:
The computed moment map
- Return type:
numpy.ndarray
- plot_line(i=0, iaz=0, iTrans=0, psf_FWHM=None, bmaj=None, bmin=None, bpa=None, plot_beam=False, plot_cont=True, subtract_cont=False)[source]
Plot the line spectrum.
- Parameters:
i (int) – Inclination index
iaz (int) – Azimuth angle index
iTrans (int) – Transition index
plot_cont (bool) – Whether to plot the continuum level
**kwargs – Additional arguments passed to plotting function
- plot_map(i=0, iaz=0, iTrans=0, v=None, iv=None, insert=False, subtract_cont=False, moment=None, psf_FWHM=None, bmaj=None, bmin=None, bpa=None, plot_beam=None, beam_position=(0.125, 0.125), axes_unit='arcsec', conv_method=None, fmax=None, fmin=None, fpeak=None, dynamic_range=1000.0, color_scale=None, colorbar=True, colorbar_size=10, colorbar_label=True, cmap=None, ax=None, no_xlabel=False, no_ylabel=False, no_vlabel=False, no_xticks=False, no_yticks=False, vlabel_position=(0.5, 0.1), vlabel_size=8, title=None, title_size=14, limit=None, limits=None, Tb=False, Jy=False, mJy=False, per_arcsec2=False, per_beam=False, Delta_v=None, shift_dx=0, shift_dy=0, plot_stars=False, sink_particle_size=6, sink_particle_color='cyan', M0_threshold=None, iv_support=None, v_minmax=None, rms=0, interpolation=None, plot_type='imshow', alpha=1.0, linewidths=None, zorder=None, origin='lower', levels=None, colors=None, colorbar_side='right')[source]
Plot a channel map or moment map.
- Parameters:
i (int) – Inclination index
iaz (int) – Azimuth angle index
iTrans (int) – Transition index
v (float, optional) – Velocity in km/s (alternative to iv)
iv (int, optional) – Velocity channel index
moment (int, optional) – Moment to plot (0=integrated intensity, 1=velocity, 2=dispersion)
**kwargs – Additional arguments passed to plotting function
- Returns:
The plotted image
- Return type:
matplotlib.image.AxesImage
SED
- class pymcfost.SED.SED(dir=None, **kwargs)[source]
Bases:
objectA class to handle MCFOST spectral energy distributions and temperature structures.
This class reads and processes MCFOST SED outputs, providing methods to plot SEDs and temperature distributions.
- Variables:
dir (str) – Directory containing MCFOST output files
basedir (str) – Base directory without data_th suffix
P (Params) – MCFOST parameter object
sed (numpy.ndarray) – SED data from ray-tracing
wl (numpy.ndarray) – Wavelength array in microns
T (numpy.ndarray) – Temperature structure
Example
>>> sed = SED(dir="path/to/mcfost/data") >>> sed.plot(i=0) # Plot SED for first inclination
- __init__(dir=None, **kwargs)[source]
Initialize an SED object.
- Parameters:
dir (str) – Path to directory containing MCFOST output
**kwargs – Additional arguments passed to _read()
- convert_to_text(sed_text_path, i=0, iaz=0)[source]
Convert MCFOST SED fits file to text format. The created file can be used as a sample file for chi² calculation.
- Parameters:
sed_text_path (str) – Path where the text file will be saved
i (int, optional) – Inclination index. Defaults to 0.
iaz (int, optional) – Azimuth angle index. Defaults to 0.
- Returns:
Path to the created text file, or None if conversion failed
- Return type:
str or None
- plot(i, iaz=0, MC=False, contrib=False, Av=0, Rv=3.1, color='black', **kwargs)[source]
Plot the spectral energy distribution.
- Parameters:
i (int) – Inclination index
iaz (int) – Azimuth angle index
MC (bool) – Whether to plot Monte Carlo results
contrib (bool) – Whether to plot individual contributions
Av (float) – Extinction in V band
Rv (float) – Total to selective extinction ratio
color (str) – Line color
**kwargs – Additional arguments passed to plotting function
- plot_T(iaz=0, log=False, Tmin=None, Tmax=None)[source]
Plot the temperature structure.
- Parameters:
iaz (int) – Azimuth angle index
log (bool) – Whether to use logarithmic scale
Tmin (float, optional) – Minimum temperature to plot
Tmax (float, optional) – Maximum temperature to plot
- plot_Tr(h_r=0.05, iaz=0, log=True, **kwargs)[source]
Plot radial temperature profile at specified height.
- Parameters:
h_r (float) – Height above midplane in scale heights
iaz (int) – Azimuth angle index
log (bool) – Whether to use logarithmic scale
**kwargs – Additional arguments passed to plotting function
- Returns:
(radius array, temperature array)
- Return type:
tuple
- plot_Tz(r=100.0, dr=5.0, log=False, **kwargs)[source]
Plot vertical temperature profile at specified radius.
- Parameters:
r (float) – Radius in AU
dr (float) – Radial range to average over in AU
log (bool) – Whether to use logarithmic scale
**kwargs – Additional arguments passed to plotting function
Disc Structure
- class pymcfost.disc_structure.Disc(dir=None, **kwargs)[source]
Bases:
objectA class to handle MCFOST disc structure data.
This class reads and processes MCFOST disc structure outputs, providing methods to access the spatial grid, gas density, and add geometric features.
- Variables:
dir (str) – Directory containing MCFOST output files
P (Params) – MCFOST parameter object
grid (numpy.ndarray) – Spatial grid structure
gas_density (numpy.ndarray) – Gas density distribution
volume (numpy.ndarray) – Cell volumes
Example
>>> disc = Disc(dir="path/to/mcfost/data") >>> r = disc.r() # Get radial coordinates
- __init__(dir=None, **kwargs)[source]
Initialize a Disc object.
- Parameters:
dir (str) – Path to directory containing MCFOST output
**kwargs – Additional arguments passed to _read()
- add_banana(r0=None, phi0=None, f=1, delta_r=None, delta_phi=None, n_az=None, sigma=None)[source]
Add a geometrical banana on a 2D (or 3D) mcfost density grid and return a 3D array which can be directly written as a fits file for mcfost to read
surface density is mutiply by (1+f) at the crest of the banana the banana has a Gaussian profile in (r,phi) with sigma given in au, degrees
- Parameters:
r0 (float) – Radial position of enhancement in AU
phi0 (float) – Azimuthal position in degrees
f (float) – Density enhancement factor
delta_r (float) – Radial width in AU
delta_phi (float) – Azimuthal width in degrees
n_az (int, optional) – Number of azimuthal points
sigma (str) – Path to sigma data file
- Returns:
Modified density structure with banana feature
- Return type:
numpy.ndarray
- add_spiral(a=30, sigma=10, f=1, theta0=0, rmin=None, rmax=None, n_az=None)[source]
Add a geometrical spiral on a 2D (or 3D) mcfost density grid and return a 3D array which can be directly written as a fits file for mcfost to read
geometrical spiral r = a (theta - theta0) surface density is mutiply by f at the crest of the spiral the spiral has a Gaussian profil in (x,y) with sigma given in au
- Parameters:
a (float) – Spiral parameter, r = a(θ - θ₀)
sigma (float) – Width of the spiral in AU
f (float) – Density enhancement factor at spiral crest
theta0 (float) – Initial angle in radians
rmin (float, optional) – Inner radius in AU
rmax (float, optional) – Outer radius in AU
n_az (int, optional) – Number of azimuthal points
- Returns:
Modified density structure with spiral
- Return type:
numpy.ndarray
- r()[source]
Get radial coordinates of the grid.
- Returns:
Radial coordinates in AU
- Return type:
numpy.ndarray
Dust Model
- class pymcfost.dust.Dust_model(dir=None, **kwargs)[source]
Bases:
objectA class to handle MCFOST dust opacity models.
This class reads and processes MCFOST dust opacity data, providing methods to plot and analyze various dust properties.
- Variables:
dir (str) – Directory containing MCFOST output files
P (Params) – MCFOST parameter object
wl (numpy.ndarray) – Wavelength grid in microns
kappa (numpy.ndarray) – Total opacity in cm²/g
albedo (numpy.ndarray) – Dust albedo
kappa_abs (numpy.ndarray) – Absorption opacity in cm²/g
kappa_sca (numpy.ndarray) – Scattering opacity in cm²/g
phase_function (numpy.ndarray) – Scattering phase function
polarisability (numpy.ndarray) – Dust polarisability
Example
>>> dust = Dust_model(dir="path/to/mcfost/data") >>> dust.plot_kappa() # Plot opacity
- __init__(dir=None, **kwargs)[source]
Initialize a Dust_model object.
- Parameters:
dir (str) – Path to directory containing MCFOST output
**kwargs – Additional arguments passed to _read()
- plot_albedo(linewidth=1, **kwargs)[source]
Plot dust albedo as function of wavelength.
- Parameters:
linewidth (float) – Line width for plotting
**kwargs – Additional arguments passed to plotting function
- plot_kappa(abs=True, scatt=True, linewidth=1, **kwargs)[source]
Plot dust opacity coefficients.
- Parameters:
abs (bool) – Whether to plot absorption opacity
scatt (bool) – Whether to plot scattering opacity
linewidth (float) – Line width for plotting
**kwargs – Additional arguments passed to plotting function
- plot_phase_function(k=0, linewidth=1, **kwargs)[source]
Plot scattering phase function.
- Parameters:
k (int) – Wavelength index
linewidth (float) – Line width for plotting
**kwargs – Additional arguments passed to plotting function