API
For those interested in the source code, the most important files to start browsing are
model.jl: Contains the specification of the parametric disk model, as well as the tools to write to disk the synthesis files RADMC-3D requires.
image.jl: Contains type definitions to read images produced by RADMC-3D, as well as convert from physical coordinates to sky coordinates.
visibilities.jl: Contains type definitions to hold the dataset and the model visibilities. Additionally contains functions to apply phase shifts to the visibilities corresponding to shifts in the image plane. Also contains functions to FFT images to the visibility plane.
gridding.jl: Contains the prolate-spheroidal wave function definitions from Schwab 1984, used when doing the visibility interpolations.
venus.jl: This implementation uses the Ensemble Sampler (a Julia port of Dan Foreman-Mackey's emcee
python package) to sample the posterior distribution using parallelized walkers.
Constants
DiskJockey.constants.fftspace
— MethodOftentimes it is necessary to get a symmetric coordinate array that spans $N$ elements from -width
to +width
, but makes sure that the middle point lands on $0$. The indices go from $0$ to $N -1.$ linspace
returns the end points inclusive, wheras we want to leave out the right endpoint, because we are sampling the function in a cyclic manner.
model.jl
DiskJockey.model.registered_params
— ConstantA dictionary of parameter lists for conversion.
DiskJockey.model.Grid
— TypeDefine a grid object which stores all of these variables This will not change for the duration of the run.
DiskJockey.model.Grid
— TypeCreate a grid object using a logarithmic then linear then logarithmic radial spacing
DiskJockey.model.Grid
— MethodRead from a dictionary, then choose how to make the grid based upon the arguments.
DiskJockey.model.Grid
— MethodHold the ray-tracing grid.
DiskJockey.model.Grid
— MethodHold the ray-tracing grid.
DiskJockey.model.ParametersNuker
— TypeParameters for the NUKER model.
DiskJockey.model.ParametersStandard
— TypeParameters for the standard model.
DiskJockey.model.ParametersVertical
— TypeParameters for the vertical model.
DiskJockey.model.ParametersVerticalEta
— TypeParameters for the vertical model with variable slope.
DiskJockey.model.Sigma
— MethodSigma(r::Float64, pars::ParametersNuker)
Calculate the gas surface density using the Nuker profile.
DiskJockey.model.Sigma
— MethodCalculate the gas surface density
DiskJockey.model.convert_dict
— MethodUsed to turn a dictionary of parameter values (from config.yaml) directly into a parameter type. Generally used for synthesis and plotting command line scripts.
DiskJockey.model.convert_vector
— MethodUnroll a vector of parameter values into a parameter type.
DiskJockey.model.generate_vel_mask
— MethodGenerate a boolean mask corresponding to the velocities which fall inside the user-specified mask ranges. arr is an array of [start, end] pairs, like arr = [[1.0, 3.0], [4.0, 5.2]] vels are the velocities corresponding to the dataset, like vels = [1.2, 2.4, 3.6], etc.
DiskJockey.model.lnprior_base
— MethodThe common sense priors that apply to all parameter values
DiskJockey.model.write_grid
— MethodThis function only needs to be run once, upon setup.
DiskJockey.model.write_lambda
— MethodWrite the wavelength sampling file. Only run on setup
image.jl
DiskJockey.image
— ModuleThe image module contains various data types for reading and holding images produced by the radiative transfer programs (via RADMC-3D
), as well as routines for processing these images.
DiskJockey.image.RawImage
— TypeRawImage(data, pixsize_x, pixsize_y, lams)
Hold the raw output from RADMC-3D
in a 3D array (npixy, npixx, nlam). RawImage reflects the RADMC convention that both x and y are increasing with array index. This means that to display the image as RADMC intends it, you must set the first array element to the lower left corner.
DiskJockey.image.SkyImage
— TypeSkyImage is a holder that has both RA and DEC increasing with array index This convention is necessary for the FFT step However, to display this image in the traditional sky convention (North up, East to the left), you must set the first array element to the lower left corner and flip the array along the RA axis: fliplr(data)
or flipdim(data, 2)
DiskJockey.image.SkyImage
— MethodSkyImage constructor for just a single frame
DiskJockey.image.TausurfImg
— TypeTausurfImage is designed to hold the results of the RADMC-3D tausurf
operation. This is The distance in cm above or below the plane tangent to the observer, which intersects the origin of the model.
From the RADMC3D manual: The image output file image.out will now contain, for each pixel, the position along the ray in centimeters where τ = τs. The zero point is the surface perpendicular to the direction of observation, going through the pointing position (which is, by default the origin (0, 0, 0)). Positive values mean that the surface is closer to the observer than the plane, while negative values mean that the surface is behind the plane. So for this datastructure, it's the same thing as RawImage, just instead of intensity, we have distance above/below plane.
DiskJockey.image.TausurfPos
— TypeEncapsulates the 3D position of the pixels representing the tau=1 surface, in the same datashape as the image. For each pixel, this is the x, y, or z position.
DiskJockey.image.ZerothMoment
— TypeStorage for zeroth moment map
Base.:-
— MethodSubtraction for SkyImage
s
DiskJockey.image.convert
— Methodconvert(::Type{ZerothMoment}, img::SkyImage)
Convert a SkyImage
to a ZerothMoment
map.
DiskJockey.image.imToSky
— MethodimToSky(img::RawImage, dpc::Float64)
Convert a RawImage
to a SkyImage
. Assumes dpc is parsecs.
DiskJockey.image.imToSpec
— MethodTake an image and integrate all the frames to create a spatially-integrated spectrum
DiskJockey.image.imread
— Functionimread(file="image.out")
Read the image file (default=image.out) and return it as an Image object, which contains the fluxes in Jy/pixel, the sizes and locations of the pixels in arcseconds, and the wavelengths (in microns) corresponding to the images
DiskJockey.image.integrateSpec
— MethodCalculate the integrated line flux
DiskJockey.image.taureadImg
— FunctiontaureadImg(file="image_tausurf.out")
Like imread, but for tausurf. Pixels that have no $\tau$ surface are set to NaN
.
DiskJockey.image.taureadPos
— FunctionRead the (x,y,z) positions of the $\tau=1$ pixels.
visibilities.jl
DiskJockey.visibilities.DataVis
— TypeDataVis(fname::AbstractString, index::Int, flagged::Bool=false)
Read just one channel of visibilities from the HDF5 file.
DiskJockey.visibilities.DataVis
— TypeDataVis(fname::AbstractString, mask::BitArray, flagged::Bool=false)
Read just a subset of channels from the HDF5 file and return an array of DataVis.
DiskJockey.visibilities.DataVis
— TypeDataVis(fname::AbstractString, indices::Vector{Int}, flagged::Bool=false)
Read just a subset of channels from the HDF5 file and return an array of DataVis.
DiskJockey.visibilities.DataVis
— TypeDataVis(fname::AbstractString, flagged::Bool=false)
Read all the visibilities from an HDF5 string and return them as an array of DataVis objects flagged
means whether we should be loading the flagged points or not.
DiskJockey.visibilities.DataVisReal
— MethodDataVisReal(dvis::DataVis)
Convert a DataVis
object, with visibilities stored as Comlpex128
, into an object with visibilities stored with real and complex values stored separately as Float64
.
DiskJockey.visibilities.ModelVis
— MethodModelVis(dvis::DataVis, fmvis::FullModelVis)
Given a DataSet and a FullModelVis, go through and interpolate at the u,v locations of the DataVis.
DiskJockey.visibilities.ModelVisReal
— MethodModelVisReal(mvis::ModelVis)
Convert a ModelVis
object, with visibilities stored as ComplexF64
, into a ModelVisReal
, with real and imaginary visibility values stored separately as Float64
.
DiskJockey.visibilities.RawModelVis
— TypeRawModelVis
Type to store the product of FFT'ing a single channel of a SkyImage.
Base.:-
— Method-(vis1::FullModelVis, vis2::FullModelVis)
Subtract two FullModelVis
's.
Base.conj!
— Methodconj!(dv::DataVis)
Import the complex conjugate function from Base, and extend it to work on a DataVis. I think this is necessary because the SMA and ALMA baseline conventions are swapped from what I'm using in the NRAO Synthesis Summer School textbook.
Base.conj!
— Methodconj!(dvarr::Array{DataVis, 1})
Apply $conj!$ to an entire DataVis array.
DiskJockey.visibilities.ModelVis2DataVis
— MethodModelVis2DataVis(mvis::ModelVis)
Collapse a ModelVis into a DataVis in order to write to disk.
DiskJockey.visibilities.ModelVisRotate
— MethodModelVisRotate(dvis::DataVis, fmvis::FullModelVis, PA::Real)
Given a DataSet, FullModelVis, and a desired position angle rotation, use the Fourier rotation theorem to sample the image at the rotated baselines and produce a rotated (sampled) model. A positive PA
value (in degrees) means that the new model is rotated $PA$ number of degrees counter-clockwise in the image plane (towards East, from North).
DiskJockey.visibilities.ResidVis
— MethodResidVis(dvarr::Array{DataVis, 1}, mvarr)
Return a model visibility file that contains the residuals.
DiskJockey.visibilities.chi2
— Methodchi2(dvis::DataVis, mvis::ModelVis)
Calculate the $\chi^2$ value of the current model. This function is not used in inference (see lnprob
), but it is sometimes a useful number to report.
DiskJockey.visibilities.copy_flags
— Methodcopy_flags(source::AbstractString, dest::AbstractString)
Copy the flags from one dataset to another.
DiskJockey.visibilities.fftfreq
— Methodfftfreq(n::Int, d::Float64)
After numpy.fft.fftfreq
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd.
DiskJockey.visibilities.fillModelVis
— MethodfillModelVis(vis::RawModelVis)
This function is designed to copy the partial arrays in RawModelVis into a full image for easy plotting. This means that the u axis can remain the same but we'll need to make the complex conjugate of the v axis.
DiskJockey.visibilities.get_nyquist_pixel
— Methodget_nyquist_pixel(max_base::Float64, angular_width::Float64)
Determine how many pixels the image needs at a given distance in order to satisfy the Nyquist sampling theorem.
max_base
is in kilolambda. angular_width
is in radians.
DiskJockey.visibilities.get_qq
— Methodget_qq(dv::DataVis)
Given a DataVis, convert the Cartesian spatial frequency coordinates $(u,v)$ into a radial spatial coordinate $q$.
DiskJockey.visibilities.interpolate_uv
— Methodinterpolate_uv(u::Float64, v::Float64, vis::FullModelVis)
Interpolates a dense grid of visibilities (e.g., from FFT of an image) to a specfic (u,v) point using spheroidal functions in a band-limited manner designed to reduce aliasing.
DiskJockey.visibilities.lnprob
— Methodlnprob(dvis::DataVis, mvis::DataVis)
Lnprob for computing the difference between two datasets. Does not check whether the baselines of the two datasets are the same. Use this function at your own discretion.
DiskJockey.visibilities.lnprob
— Methodlnprob(dvis::DataVis, mvis::ModelVis, mu_RA::Real, mu_DEC::Real)
Calculate the lnlikelihood using a single loop to do the phase shifting and summation. No extra memory needed for re-copying the model.
DiskJockey.visibilities.lnprob
— Methodlnprob(dvis::DataVis, mvis::ModelVis)
Likelihood function used to calculate the likelihood of the data visibilities given a current model of them. Asserts that the model visibilities were sampled at the same baselines as the data.
DiskJockey.visibilities.lnprob_real
— Methodlnprob_real(dvis::DataVis, mvis::ModelVis, mu_RA::Float64, mu_DEC::Float64)
Calculate the lnlikelihood using a single loop to do the phase shifting and summation. No extra memory needed for re-copying the model. Uses Euler formula to do the calculation, rather than exponentiating a complex number.
DiskJockey.visibilities.max_baseline
— Methodmax_baseline(dvarr)
Determine the maximum uu or vv baseline contained in the dataset, so we know at what resolution we will need to synthesize the images.
returned in kilolambda.
DiskJockey.visibilities.phase_shift!
— Methodphase_shift!(fvis::FullModelVis, mu_RA, mu_DEC)
Given a new model centroid in the image plane (in arcseconds), shift the model visibilities by corresponding amount.
DiskJockey.visibilities.phase_shift!
— Methodphase_shift!(mvis::ModelVis, mu_RA, mu_DEC)
Given a new model centroid in the image plane (in arcseconds), shift the model visibilities by corresponding amount.
DiskJockey.visibilities.plan_interpolate
— Methodplan_interpolate(dvis::DataVis, uu::Vector{Float64}, vv::Vector{Float64})
Return a function that is used to interpolate the visibilities, in the spirit of interpolate_uv but much faster. Closures save time and money!
The uu and vv vectors are the visibility coordinates for the dense visibility model.
The point is that if the distance to the source and the size of the sythesized image are not changing, then we will always be interpolating from a dense Visibility grid that has the exact same U and V spacings, meaning that the weighting terms used to evaluate the interpolation for a specific visibility can be cached.
So, using a closure, those weighting terms are calculated once and then cached for further use.
DiskJockey.visibilities.rfftfreq
— Methodrfftfreq(n::Int, d::Float64)
Return the frequencies corresponding to the output of the real FFT. After numpy.fft.rfftfreq f = [0, 1, ..., n/2-1, n/2] / (dn) if n is even f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (dn) if n is odd.
DiskJockey.visibilities.transform
— Functiontransform(img::SkyImage, index::Int=1)
Transform the SkyImage produced by RADMC using FFT.
DiskJockey.visibilities.write
— Methodwrite(dv::DataVis, fname::AbstractString)
Take in a visibility data set and then write it to the HDF5 file The HDF5 file actually expects multi-channel data, so instead we will need to store all of this information with arrays of shape (..., 1) [an extra trailing] dimension of 1.
DiskJockey.visibilities.write
— Methodwrite(dvarr::Array{DataVis, 1}, fname::AbstractString)
Write an array of DataVis to a single HDF5 file.
gridding.jl
DiskJockey.gridding.corrfun!
— Methodcorrfun!(img::SkyImage, mu_RA, mu_DEC)
Apply the correction function to the SkyImage
, with an offset in RA and DEC.
DiskJockey.gridding.corrfun!
— Methodcorrfun!(img::SkyImage)
Apply the correction function to (and mutate) a SkyImage
in place.
DiskJockey.gridding.corrfun
— Methodcorrfun(img::SkyImage)
Apply the correction function to a SkyImage
, but return a copy of the image, leaving the original unchanged.
DiskJockey.gridding.corrfun
— Methodcorrfun(eta::T) where {T}
Gridding correction function, but able to be passed either floating point numbers or vectors of Float64
.
DiskJockey.gridding.corrfun
— Methodcorrfun(eta::T, alpha::Float64) where {T}
Gridding correction function, used to pre-divide the image to correct for the effect of the gcffun
. This function is also the Fourier transform of gcffun
.
DiskJockey.gridding.gcffun
— Methodgcffun(eta::T) where {T}
The gridding convolution function, used to do the convolution and interpolation of the visibilities in the Fourier domain. This is also the Fourier transform of corrfun
.
DiskJockey.gridding.gcffun
— Methodgcffun(eta::T, alpha::Float64) where {T}
The gridding convolution function, with variable $\alpha$.
DiskJockey.gridding.spheroid
— Methodspheroid(eta, alpha)
Prolate spheroidal wavefunction, assuming that $m = 6$. This allows arguments for $\eta < 1.0 + 10^{-7}$, but returns 0.0 (i.e., the spheroid window is truncated).
DiskJockey.gridding.spheroid
— Methodspheroid(eta)
spheroid
function which assumes $\alpha$ = 1.0, $m=6$, built for speed.
gauss.jl
DiskJockey.gauss
— ModuleProvide routines for making fake Gaussian models which have analytic Fourier transforms, for the purposes of testing.
DiskJockey.gauss.FTGauss
— MethodFTGauss(uu::AbstractVector{Float64}, vv::AbstractVector{Float64}, p::Vector{Float64}, k::Int)
p
is a length 5 vector of mu_RA
, mu_DEC
, sigma_RA
, sigma_DEC
, rho
.
Given two arrays of u and v coordinates in [kλ], fill an array with the analytic FT of imageGauss
evaluated at every pairwise (u,v) pair.
DiskJockey.gauss.FTGauss
— MethodFTGauss(uu::Float64, vv::Float64, p::Vector{Float64}, k::Real)
Given u and v coordinates in [kλ], evaluate the analytic FT of the aforementioned Gaussian.
p
is a length 5 vector of [mu_RA, mu_DEC, sigma_x, sigma_y, rho]
in units of arcseconds, corresponding to the image plane.
N.B. Here Sigma refers to the (same) covariance matrix in the image domain.
This function always returns a complex value.
DiskJockey.gauss.imageGauss
— MethodimageGauss(ll::AbstractVector{Float64}, mm::AbstractVector{Float64}, p::Vector{Float64}, k::Real; theta=0)
Given two arrays of $l$ and $m$ coordinates, corresponding to $x$ and $y$, fill an array of the Gaussian image following the MATLAB convention for images (each row corresponds to a different y value).
p0
is a vector of [mu_RA, mu_DEC, sigma_x, sigma_y, rho]
in units of arcseconds. $\rho$ is the correlation of the Gaussian, ranging from 0 to 1.
\[\rho = \frac{\sigma_{xy}}{\sigma_x \sigma_y}\]
$\mu_\alpha$ and $\mu_\delta$ are the locations of the centroid emission relative to the image origin (RA=0, DEC=0).
$k$ is a scaling pre-factor to adjust the amplitude of the Gaussian.
The image intensity as a function of $l$ and $m$ (sky plane coordinates) is
\[ I(l,m) = \frac{k}{2 \pi \sqrt{|\boldsymbol{\Sigma}|}} \exp \left \{ -\frac{1}{2} \boldsymbol{R}^\mathrm{T} \boldsymbol{\Sigma}^{-1} \boldsymbol{R} \right \}\]
Where $\boldsymbol{\Sigma}$ is
\[\boldsymbol{\Sigma} = \left [ \begin{array}{cc} \sigma_x & \sigma_{xy} \\ \sigma_{xy} & \sigma_y \\ \end{array} \right ]\]
$\theta$ is a desired angle to rotate the Gaussian about the origin. To make sense of the order of operations, the rotation must occur about the origin. A positive value means a counter-clockwise rotation of the Gaussian from North towards East.
EnsembleSampler.jl
This is a Julia port of the Python package emcee
, written by Dan Foreman-Mackey and collaborators.
Index
DiskJockey.gauss
DiskJockey.image
DiskJockey.model.registered_params
DiskJockey.image.RawImage
DiskJockey.image.SkyImage
DiskJockey.image.SkyImage
DiskJockey.image.TausurfImg
DiskJockey.image.TausurfPos
DiskJockey.image.ZerothMoment
DiskJockey.model.Grid
DiskJockey.model.Grid
DiskJockey.model.Grid
DiskJockey.model.Grid
DiskJockey.model.Grid
DiskJockey.model.ParametersNuker
DiskJockey.model.ParametersStandard
DiskJockey.model.ParametersVertical
DiskJockey.model.ParametersVerticalEta
DiskJockey.visibilities.DataVis
DiskJockey.visibilities.DataVis
DiskJockey.visibilities.DataVis
DiskJockey.visibilities.DataVis
DiskJockey.visibilities.DataVisReal
DiskJockey.visibilities.ModelVis
DiskJockey.visibilities.ModelVisReal
DiskJockey.visibilities.RawModelVis
Base.:-
Base.:-
Base.conj!
Base.conj!
DiskJockey.constants.fftspace
DiskJockey.gauss.FTGauss
DiskJockey.gauss.FTGauss
DiskJockey.gauss.imageGauss
DiskJockey.gridding.corrfun
DiskJockey.gridding.corrfun
DiskJockey.gridding.corrfun
DiskJockey.gridding.corrfun!
DiskJockey.gridding.corrfun!
DiskJockey.gridding.gcffun
DiskJockey.gridding.gcffun
DiskJockey.gridding.spheroid
DiskJockey.gridding.spheroid
DiskJockey.image.convert
DiskJockey.image.imToSky
DiskJockey.image.imToSpec
DiskJockey.image.imread
DiskJockey.image.integrateSpec
DiskJockey.image.taureadImg
DiskJockey.image.taureadPos
DiskJockey.model.Sigma
DiskJockey.model.Sigma
DiskJockey.model.convert_dict
DiskJockey.model.convert_vector
DiskJockey.model.generate_vel_mask
DiskJockey.model.lnprior_base
DiskJockey.model.write_grid
DiskJockey.model.write_lambda
DiskJockey.visibilities.ModelVis2DataVis
DiskJockey.visibilities.ModelVisRotate
DiskJockey.visibilities.ResidVis
DiskJockey.visibilities.chi2
DiskJockey.visibilities.copy_flags
DiskJockey.visibilities.fftfreq
DiskJockey.visibilities.fillModelVis
DiskJockey.visibilities.get_nyquist_pixel
DiskJockey.visibilities.get_qq
DiskJockey.visibilities.interpolate_uv
DiskJockey.visibilities.lnprob
DiskJockey.visibilities.lnprob
DiskJockey.visibilities.lnprob
DiskJockey.visibilities.lnprob_real
DiskJockey.visibilities.max_baseline
DiskJockey.visibilities.phase_shift!
DiskJockey.visibilities.phase_shift!
DiskJockey.visibilities.plan_interpolate
DiskJockey.visibilities.rfftfreq
DiskJockey.visibilities.transform
DiskJockey.visibilities.write
DiskJockey.visibilities.write