Examples

You can find some examples here for common maps. These examples assume that you also have GadgetIO.jl, GadgetUnits.jl and SPHKernels.jl installed.

In all examples snap_base points to the snapshot you want to map and map_path points to the folder where you want to store the fits files.

Read data and convert units

First we need to read the data and convert it to physical units (unless you want to bother with comoving coordinates and h0 in cosmological simulations).

Here halo_pos is the position of the halo you want to map and rvir is its virial radius.

# read the header
h = read_header(snap_base)
# define a unit conversion struct from `GadgetUnits.jl`
GU = GadgetPhysical(h)

# define the blocks you want to read
blocks = ["POS", "VEL", "HSML", "RHO", "U", "MASS", "BFLD", "MACH"]

# read all particles in a cubic volume around the halo
data = read_particles_in_volume(snap_base, blocks, halo_pos, rvir)

# convert to physical code units for mapping
pos  = data["POS"]  .* GU.x_physical
hsml = data["HSML"] .* GU.x_physical
rho  = data["RHO"]  .* GU.rho_physical
mass = data["MASS"] .* GU.m_physical

# we want to map the entire cube we read
xy_size = 2rvir
z_size  = 2rvir

# define mapping parameters and convert to physical units
par = mappingParameters(center = halo_pos .* GU.x_physical,
                        x_size = xy_size * GU.x_physical,
                        y_size = xy_size * GU.x_physical,
                        z_size = z_size * GU.x_physical,
                        Npixels = 1024,
                        boxsize=h.boxsize)

# define the kernel you want to use for mapping
k = WendlandC4(Float64, 2)

2D surface density

To get the projected 2D surface density from your data you can use

# you need to make a copy of the positions if you plan to re-use them
# the mapping shifts them in place
pos_map = copy(pos)

# convert density to physical cgs units
rho_gcm3 = data["RHO"] .* GU.rho_cgs

# to get the integrated values along the LOS you need physical weights and not reduce the image
weights = part_weight_physical(length(hsml), par, GU.x_cgs)

# actual mapping
map = sphMapping(pos_map, hsml, mass, rho,
                rho_gcm3, weights,
                param = par, kernel = k,
                reduce_image = false)

# filename of the output image
fo_image = map_path * "rho.fits"

# store the fits image
write_fits_image(fo_image, quantitiy_map, par, snap = snap, units = "g/cm^2")

The units in this case are of course $g/cm^2$.

Magnetic Field

To map the mean magnetic field along the LOS you need to use the density as weight (this is the default behaviour, so you can leave the arguemnt empty) and set reduce_image=true

# you need to make a copy of the positions if you plan to re-use them
# the mapping shifts them in place
pos_map = copy(pos)

# compute absolute value of magnetic field in muG
B = @. 1.e6 * √(data["BFLD"][1, :]^2 + data["BFLD"][2, :]^2 + data["BFLD"][3, :]^2)


# actual mapping
map = sphMapping(pos_map, hsml, mass, rho, B,
                param = par, kernel = k,
                reduce_image = true)

# filename of the output image
fo_image = map_path * "B.fits"

# store the fits image
write_fits_image(fo_image, quantitiy_map, par, snap = snap, units = "muG")

Faraday Rotation

You can map the Faraday Rotation due to the LOS magnetic field strength for RM maps, or for continuous rotation of polarized synchrotron emission using

SPHtoGrid.rotation_measureFunction
rotation_measure(n_cm3::Real, B_los::Real, dz::Real; ν_obs=nothing)

Computes the rotation measure of the parallel magnetic field along the LOS.

Arguments

  • n_cm3::Real: Electron number density in [cm^-3].
  • B_los::Real: Magnetic field strength along the LOS in [G].

Returns

  • RM::Real: Rotation measure in [rad/m^2].

Mapping settings

source
rotation_measure(n_cm3::Real, B_los::Real, dz::Real, ν_obs::Real)

Computes the rotation measure of the parallel magnetic field along the LOS at a given frequency. To be used for continuous rotation of polarized emission along the LOS.

Arguments

  • n_cm3::Real: Electron number density in [cm^-3].
  • B_los::Real: Magnetic field strength along the LOS in [G].
  • dz::Real: Depth along the LOS in [cm]. See get_dz for a convenient helper function.
  • ν_obs::Real: Observing frequency in [Hz].

Returns

  • RM::Real: Rotation measure in [rad/cm^2].

Mapping settings

  • weight function: part_weight_physical
  • reduce image: false
  • stokes: true
  • sort_z: true
  • RM: use output of this function.
source

For the latter we provide the simple helper function

Missing docstring.

Missing docstring for get_dz. Check Documenter's build log for details.

X-Ray emission

To map the Xray surface brightness please use

SPHtoGrid.x_ray_emissivityFunction
x_ray_emissivity(T_keV::Vector{<:Real}, 
                 rho_cgs::Vector{<:Real},
                 metalicity::Union{Vector{Float64, Nothing}}=nothing; 
                 E0::Real=0.1, E1::Real=2.4, 
                 xH::Real=0.752,
                 cooling_function::Bool=false,
                 z::Real=0.0)

X-Ray emissivity for particles with temperature T_keV in $keV$, and density rho_cgs in $g/cm^3$. If available you can also add the metalicity in the gas. Emin and Emax give the minimum and maximum energy of the oberservation. xH gives the hydrogen fraction used in the simulation.

Returns

X-Ray emissivity in units of [erg/s/cm^3].

Arguments:

  • T_keV: SPH particle temperature [keV]
  • m_cgs: SPH particle mass in [g]
  • rho_cgs: SPH particle density in [g/cm^3]
  • E0: Minimum photon energy for Xray spectrum [keV]
  • E1: Maximum photon energy for Xray spectrum [keV]
  • xH: Hydrogen mass fraction in the simulation

Mapping settings

source

Here is an example code

# you need to make a copy of the positions if you plan to re-use them
# the mapping shifts them in place
pos_map = copy(pos)

# get temperature in keV
T_keV = get_T_keV(data["U"], data["MASS"], GU.T_eV)

# convert density to physical cgs units
rho_gcm3 = data["RHO"] .* GU.rho_cgs

# calculate X-ray emission per particle in the energy band Emin = 0.1 keV, Emax = 2.4 keV
Xray = x_ray_emissivity(T_keV, rho_cgs,
                        E0=0.1, E1=2.4)

# to get the integrated values along the LOS you need physical weights and not reduce the image
weights = part_weight_physical(length(hsml), par, GU.x_cgs)

# actual mapping
map = sphMapping(pos_map, hsml, mass, rho, Xray, weights,
                param = par, kernel = k,
                reduce_image = false)

# filename of the output image
fo_image = map_path * "Xray.fits"

# store the fits image
write_fits_image(fo_image, quantitiy_map, par, snap = snap, units = "erg/s/cm^2")

This returns a map in the units $erg/s/cm^2$.

Sunyaev-Z'eldovich Effect

You can compute compton-Y parameter, thermal and kinetic SZ effect with these functions:

SPHtoGrid.comptonYFunction
comptonY(n_cm3::Real, T_K::Real, z::Real)

Computes the Compton-Y parameter from electron density n_cm3 and temperature T in Kelvin at redshift z.

Arguments:

  • n_cm3: SPH particle density in [1/cm^3]
  • T_K: SPH particle temperature [K]
  • z: Redshift.

Mapping settings

source
comptonY(n_cm3::Vector{<:Real}, T_K::Vector{<:Real}, z::Real)

Computes the Compton-Y parameter from electron density n_cm3 and temperature T in Kelvin at redshift z.

Arguments:

  • n_cm3: SPH particle density in [1/cm^3]
  • T_K: SPH particle temperature [K]
  • z: Redshift

Mapping settings

source
SPHtoGrid.thermal_SZFunction
thermal_SZ( n_cm3::Vector{<:Real}, T_K::Vector{<:Real},
            z::Real=0.0, ν::Real=1.44e9; 
            DI_over_I::Bool=false )

Computes the thermal Sunyaev-Zel'dovich effect for electron density n_cm3 and temperature T_K in Kelvin at redshift z and observer frequency ν. DI_over_I outputs in units of $dI/I$ if set to true and dT/T otherwise.

Arguments:

  • n_cm3: SPH particle density in [1/cm^3]
  • T_K: SPH particle temperature [K]
  • z: Redshift
  • ν: Observing frequency

Mapping settings

source
SPHtoGrid.kinetic_SZFunction
kinetic_SZ(n_cm3::Real, vel_y_cgs::Real, 
           z::Real=0.0, ν::Real=1.e9;
           DI_over_I::Bool=false)

Computes the kinetic Sunyaev-Zel'dovich effect from electron density n_cm3 and velocity in y-direction to the projection plane in cgs units vel_y_cgs. If DI_over_I is set to true you also need to provide an observation frequency ν and redshift z.

Arguments:

  • n_cm3: SPH particle density in [1/cm^3]
  • vel_y_cgs: SPH particle velocity in y-direction in [cm/s]
  • z: Redshift
  • ν: Observing frequency

Mapping settings

source

Example for the thermal SZ effect

# you need to make a copy of the positions if you plan to re-use them
# the mapping shifts them in place
pos_map = copy(pos)

# get temperature in K
T_K = data["U"] .* GU.T_K

# convert code density to electron density
n_cm3 = data["RHO"] .* GU.rho_ncm3

# calculate thermal SZ for redshift given in header
th_SZ = thermal_SZ(n_cm3, T_K, h.z)

# to get the integrated values along the LOS you need physical weights and not reduce the image
weights = part_weight_physical(length(hsml), par, GU.x_cgs)

# actual mapping
map = sphMapping(pos_map, hsml, mass, rho, th_SZ, weights,
                param = par, kernel = k,
                reduce_image = false)

# filename of the output image
fo_image = map_path * "ThermalSZ.fits"

# store the fits image
write_fits_image(fo_image, quantitiy_map, par, snap = snap, units = "")

Gamma Ray emission

You can compute gamma-ray related maps as in Pfrommer & Enßlin (2004) with:

SPHtoGrid.jγ_PE04Function
jγ_PE04(rho_cgs::Real, T_K::Real, α_p::Real, Eγ::Real; 
        Xcr::Real=0.5, xH::Real=0.752)

Gamma-ray emissivity at photon energy [GeV] for thermal gas with properties rho_cgs [g/cm^3] and T_K [K]. Sets up a CR proton spectrum with energy slope α_p as a fraction Xcr of the thermal energy density. Returns emissivity in units [GeV cm^-3 s^-1 ]. See Pfrommer&Enßlin (2004), Eq. 19.

Function Arguments:

  • rho_cgs: SPH particle density in [g/cm^3]
  • T_K: SPH particle temperature [K]
  • α_p: Slope of proton energy spectrum S ~ 2.0 - 2.5
  • : Photon energy [GeV]
  • Xcr: CR proton to thermal pressure ratio.
  • xH: Hydrogen mass fraction in the simulation

Mapping settings

For mean value along line-of-sight:

  • weights: rho (weight with density)
  • reduce_image: true

For integral along line-of-sight, aka surface brightness:

source
SPHtoGrid.λγ_PE04Function
λγ_PE04(rho_cgs::Real, T_K::Real, α_p::Real; 
        Xcr::Real=0.5,
        Eγ_π0_min::Real=0.1, Eγ_π0_max::Real=200.0,
        xH::Real=0.752)

Number of γ-ray photons produced per time and volume from a proton spectrum given as a fraction Xcr of the energy density defined by rho_cgs [g/cm^3] and T_K [K], with a powerlaw slope in energy α_p. Integrated between photon energies Eγ_π0_min and Eγ_π0_max [GeV]. Returns number of photons in energy band in units of [γ cm^-3 s^-1]. See Pfrommer&Enßlin (2004), Eq. 25.

Function Arguments:

  • rho_cgs: SPH particle density in [g/cm^3]
  • T_K: SPH particle temperature [K]
  • α_p: Slope of proton energy spectrum S ~ 2.0 - 2.5
  • Xcr: CR proton to thermal pressure ratio.
  • Eγ_π0_min: Minimum photon energy for γ-ray spectrum [GeV]
  • Eγ_π0_max: Maximum photon energy for γ-ray spectrum [GeV]
  • xH: Hydrogen mass fraction in the simulation

Mapping settings

For mean value along line-of-sight:

  • weights: rho (weight with density)
  • reduce_image: true

For integral along line-of-sight, aka surface brightness:

source
SPHtoGrid.gamma_luminosity_pions_PE04Function
gamma_luminosity_pions_PE04(rho_cgs::Real, m_cgs::Real, T_K::Real, α_p::Real;
                            Xcr::Real=0.5,
                            Eγ_π0_min::Real=0.1, Eγ_π0_max::Real=200.0,
                            xH::Real=0.752)

γ-ray luminosity produced from a proton spectrum given as a fraction Xcr of the energy density defined by rho_cgs [g/cm^3] and T_K [K], with a powerlaw slope in energy α_p. Integrated over SPH particle volume for particle of mass m_cgs [g]. Integrated between photon energies Eγ_π0_min and Eγ_π0_max [GeV]. Returns total luminosity integrated over energy band in units of [GeV s^-1]. See Pfrommer&Enßlin (2004), Eq. 25.

Arguments:

  • rho_cgs: SPH particle density in [g/cm^3]
  • m_cgs: SPH particle mass in [g]
  • T_K: SPH particle temperature [K]
  • α_p: Slope of proton energy spectrum S ~ 2.0 - 2.5
  • Xcr: CR proton to thermal pressure ratio.
  • Eγ_π0_min: Minimum photon energy for γ-ray spectrum [GeV]
  • Eγ_π0_max: Maximum photon energy for γ-ray spectrum [GeV]
  • xH: Hydrogen mass fraction in the simulation

Mapping settings

source
SPHtoGrid.gamma_flux_pions_PE04Function
gamma_flux_pions_PE04(rho_cgs::Real, m_cgs::Real, T_K::Real, α_p::Real, d::Real;
                      Xcr::Real=0.5,
                      Eγ_π0_min::Real=0.1, Eγ_π0_max::Real=200.0,
                      xH::Real=0.752)

Flux of γ-ray photons produced from a proton spectrum given as a fraction Xcr of the energy density defined by rho_cgs [g/cm^3] and T_K [K], with a powerlaw slope in energy α_p. Integrated over SPH particle volume for particle of mass m_cgs [g]. Flux from a distance d [cm]. Integrated between photon energies Eγ_π0_min and Eγ_π0_max [GeV]. Returns total number of photons in energy band in untis of [γ cm^-2 s^-1]. See Pfrommer&Enßlin (2004), Eq. 25.

Arguments:

  • rho_cgs: SPH particle density in [g/cm^3]
  • m_cgs: SPH particle mass in [g]
  • T_K: SPH particle temperature [K]
  • α_p: Slope of proton energy spectrum S ~ 2.0 - 2.5
  • d: Distance to SPH particle or halo [cm].
  • Xcr: CR proton to thermal pressure ratio.
  • Eγ_π0_min: Minimum photon energy for γ-ray spectrum [GeV]
  • Eγ_π0_max: Maximum photon energy for γ-ray spectrum [GeV]
  • xH: Hydrogen mass fraction in the simulation

Mapping settings

source

Example for gamma-ray luminosity

# you need to make a copy of the positions if you plan to re-use them
# the mapping shifts them in place
pos_map = copy(pos)

# convert density to physical cgs units
rho_gcm3 = data["RHO"] .* GU.rho_cgs

# convert mass to physical cgs units
m_cgs = data["MASS"] .* GU.m_cgs

# get temperature in keV
T_keV = data["U"] .* GU.T_K

# calculate Iγ-ray luminosity per particle in the energy band Emin = 0.1 GeV, Emax = 200 GeV
# for proton spectra with slope 2.235
Lγ = gamma_luminosity_pions_PE04.(T_keV, m_cgs, rho_cgs, 2.235)

# weights ones means you sum up the values along the LOS
weights = ones(length(Lγ))

# actual mapping
map = sphMapping(pos_map, hsml, mass, rho, Lγ, weights,
                param = par, kernel = k,
                reduce_image = true)

# filename of the output image
fo_image = map_path * "L_gamma.fits"

# store the fits image
write_fits_image(fo_image, quantitiy_map, par, snap = snap, units = "GeV/s")

Synchrotron Emission

I implemented a number of different functions to compute synchrotron emissivity by shock accelerated electrons. Please use with caution as there are still some errors to be fixed!

SPHtoGrid.analytic_synchrotronFunction
analytic_synchrotron(P_cgs::Array{<:Real}, B_cgs::Array{<:Real}, 
                     Mach::Array{<:Real}, θ_B::Union{Nothing,Array{<:Real}}=nothing;
                     dsa_model::Union{Integer,AbstractShockAccelerationEfficiency}=1, 
                     ν0::Real=1.4e9,
                     K_ep::Real=0.01, CR_Emin::Real=1.0,
                     spectrum::Union{Nothing,Function}=nothing,
                     integrate_pitch_angle::Bool=true,
                     polarisation::Bool=false,
                     show_progress::Bool=false)

Computes the analytic synchrotron emission from a spectrum of electrons by explicitly integrating over the distribution function. The integral over the spectrum must be normalized to 1. The total energy density of the relativistic electrons is given by the CR to thermal pressure ratio obtained by employing a DSA model and computing Xcr as in Pfrommer et. al. (2017).

Returns synchrotron emissivity j_nu in units [erg/s/Hz/cm^3].

Arguments

  • P_cgs::Array{<:Real}: Thermal energy density in erg/cm^3.
  • B_cgs::Array{<:Real}: Magnetic field in Gauss.
  • Mach::Array{<:Real}: Mach number.
  • θ_B::Union{Nothing,Array{<:Real}}=nothing: Shock obliquity (optional).

Keyword Arguments

  • ν0::Real=1.4e9: Observation frequency in Hz.
  • dsa_model: Diffusive Shock Acceleration model. Takes values 0...4, or custom model. See next section.
  • K_ep::Real=0.01: Ratio of CR proton to electron energy acceleration.
  • CR_Emin::Real=1: Injection energy of CR electron population in GeV.
  • spectrum::Union{Nothing,Function}=nothing: Spectrum function. Must be normalized so that the integral over it is 1.
  • integrate_pitch_angle::Bool=true: Optional avoid pitch angle integration to reduce computational cost.
  • polarisation::Bool=false: Set to true if you want to compute the polarized emission instead of the total intensity.
  • show_progress::Bool=false: Enables a progress bar if set to true.

DSA Models

Takes either your self-defined AbstractShockAccelerationEfficiency (see DiffusiveShockAccelerationModels.jl for details!) or a numerical value as input. Numerical values correspond to:

Mapping settings

source
SPHtoGrid.analytic_synchrotron_GSFunction
analytic_synchrotron_GS( rho_cgs::Array{<:Real}, B_cgs::Array{<:Real},
                         T_K::Array{<:Real}, Mach::Array{<:Real};
                         xH::Real=0.76, dsa_model::Integer=1, ν0::Real=1.44e9,
                         integrate_pitch_angle::Bool=true )

Computes the analytic synchrotron emission with the simplified approach described in Ginzburg & Syrovatskii 1965, "Cosmic Magnetobremsstrahlung". Uses the implementaion from Donnert et. al. (2016).

Returns synchrotron emissivity j_nu in units [erg/s/Hzcm^3].

Arguments

  • rho_cgs::Array{<:Real}: Density in $g/cm^3$.
  • B_cgs::Array{<:Real}: Magnetic field in Gauss.
  • T_K::Array{<:Real}: Temperature in Kelvin.
  • Mach::Array{<:Real}: Mach number.
  • θ_B::Union{Nothing,Array{<:Real}}=nothing: Shock obliquity (optional).

Keyword Arguments

  • xH::Float64 = 0.76: Hydrogen fraction of the simulation, if run without chemical model.
  • ν0::Real=1.44e9: Observation frequency in $Hz$.
  • dsa_model::Integer=1: Diffusive Shock Acceleration model. Takes values 0...4, see next section.
  • K_ep::Real=0.01: Ratio of CR proton to electron energy acceleration.
  • show_progress::Bool=false: Enables a progress bar if set to true

DSA Models

Takes either your self-defined AbstractShockAccelerationEfficiency (see DiffusiveShockAccelerationModels.jl for details!) or a numerical value as input. Numerical values correspond to:

Mapping settings

source
SPHtoGrid.analytic_synchrotron_LongairFunction
analytic_synchrotron_emission( rho_cgs::Array{<:Real}, B_cgs::Array{<:Real},
                               T_K::Array{<:Real}, Mach::Array{<:Real};
                               xH::Real=0.76, dsa_model::Integer=1, ν0::Real=1.44e9,
                               integrate_pitch_angle::Bool=true )

Computes the analytic synchrotron emission with the simplified approach described in Longair Eq. 8.128. Returns J_ν in units [erg/cm^3/Hz/s].

Arguments

  • rho_cgs::Array{<:Real}: Density in $g/cm^3$.
  • B_cgs::Array{<:Real}: Magnetic field in Gauss.
  • T_K::Array{<:Real}: Temperature in Kelvin.
  • Mach::Array{<:Real}: Mach number.

Keyword Arguments

  • xH::Float64 = 0.76: Hydrogen fraction of the simulation, if run without chemical model.
  • dsa_model::Integer=1: Diffuse-Shock-Acceleration model. Takes values 0...4, see next section.
  • ν0::Real=1.44e9: Observation frequency in $Hz$.
  • K_ep::Real=0.01: Ratio of CR proton to electron energy density.
  • integrate_pitch_angle::Bool=true: Integrates over the pitch angle as in Longair Eq. 8.87.
  • convert_to_mJy::Bool=false: Convert the result from $[erg/cm^3/Hz/s]$ to $mJy/cm$.

DSA Models

Takes either your self-defined AbstractShockAccelerationEfficiency (see DiffusiveShockAccelerationModels.jl for details!) or a numerical value as input. Numerical values correspond to:

source
SPHtoGrid.analytic_synchrotron_HB07Function
analytic_synchrotron_HB07( rho_cgs::Array{<:Real}, m_cgs::Array{<:Real}, hsml_cgs::Array{<:Real},
                           B_cgs::Array{<:Real}, T_keV::Array{<:Real}, Mach::Array{<:Real},
                           θ_B::Union{Nothing, Array{<:Real}}=nothing;
                           xH::Real=0.752, ν0::Real=1.4e9, z::Real=0.0,
                           dsa_model::Union{Nothing,Integer,AbstractShockAccelerationEfficiency}=nothing,
                           ξe::Real=1.e-5,
                           show_progress::Bool=false )

Computes the analytic synchrotron emission with the simplified approach described in Hoeft&Brüggen (2007), following approach by Wittor et. al. (2017).

Returns synchrotron emissivity j_nu in units [erg/s/Hz/cm^3].

Arguments

  • rho_cgs::Array{<:Real}: Density in $g/cm^3$.
  • m_cgs::Array{<:Real}: Particle mass in $g$.
  • hsml_cgs::Array{<:Real}: HSML block in $cm$.
  • B_cgs::Array{<:Real}: Magnetic field in $G$.
  • T_keV::Array{<:Real}: Temperature in $keV$.
  • Mach::Array{<:Real}: Sonic Mach number.
  • θ_B::Union{Nothing,Array{<:Real}}=nothing: Shock obliquity (optional).

Keyword Arguments

  • xH::Float64 = 0.76: Hydrogen fraction of the simulation, if run without chemical model.
  • ν0::Real=1.44e9: Observation frequency in $Hz$.
  • z::Real=0.0: Redshift of the simulation.
  • dsa_model=nothing: Diffusive Shock Acceleration model. If set to a value overwrites the default Hoeft&Brüggen acceleration model. See next section.
  • ξe::Real=1.e-5: Ratio of CR proton to electron energy acceleration. Given as a fraction of thermal gas, essenitally Xcr * Kep. Default value from Nuza+2017. For dsa_model != nothing use something like ξe = 1.e-4.
  • show_progress::Bool=false: Enables a progress bar if set to true.

DSA Models

Takes either your self-defined AbstractShockAccelerationEfficiency (see DiffusiveShockAccelerationModels.jl for details!) or a numerical value as input. Numerical values correspond to:

Mapping settings

source

Stellar/DM density

If you want to map the mass density of a non-SPH particle, i.e. a particle distribution that does not have their density computed in the output snapshot you can do this with mass_density. This will perform an SPH loop to compute the mass density at particle position. Useful if you want to compute Stellar/DM density distributions.

Please note that this function uses a fixed number of neighbors (for simplicity) so the results will diverge from a proper SPH loop.

SPHtoGrid.mass_densityFunction
mass_density(pos::Matrix{<:Real}, mass::Vector{<:Real}; 
             kernel::AbstractSPHKernel=Cubic(Float64, 3),
             Nneighbors::Integer=32,
             boxsize::Vector{<:Real}=zeros(3),
             verbose::Bool=false)

Compute the density of an arbitrary particle distribution using the SPH method. Neighbor searches are performed using a (periodic) BallTree. The density is computed in input units, so additional unit conversion to cgs units is required, if input units are not cgs.

Arguments:

  • pos: particle position in physical code units.
  • mass: particle mass in physical code units.

Keyword Arguments

  • kernel::AbstractSPHKernel=Cubic(Float64, 3): SPH kernel to use for the density estimate. Works with any kernel from SPHKernels.jl.
  • Nneighbors::Integer=32: Number of neighboring particles to use for the density estimate.
  • boxsize::Vector{<:Real}=zeros(3): Boxsize in each dimension. Used for periodic boundary conditions. If set to zero, non-periodic boundary conditions are assumed.
  • verbose::Bool=false: If set to true gives progress reports and progress bar.

Returns

  • rho: mass density at particle position in input units.
  • hsml: smoothing length of each particle in input units.

Mapping settings

source

Image Functions

General

SPHtoGrid.surface_brightness_to_luminosityFunction
surface_brightness_to_luminosity(map::Matrix{<:Real}, pixelSideLength::Real; unit_factor::Real=1.0)

Converts a map of surface brightness to luminosity per pixel. Uses pixelSideLength as the diameter of a pixel in [kpc]. If unit_factor is provided it is multiplied to every pixel to perform unit conversion.

source
surface_brightness_to_luminosity(map::Matrix{<:Real}, par::mappingParameters; unit_factor::Real=1.0)

Converts a map of surface brightness to luminosity per pixel. If unit_factor is provided it is multiplied to every pixel to perform unit conversion.

source

Synchrotron Specific

SPHtoGrid.synchrotron_SB_to_luminosityFunction
synchrotron_SB_to_luminosity(map, pixelSideLength::Real)

Converts a map of synchrotron surface brightness [erg/s/Hz/cm^2] to synchrotron luminosity [W/Hz]. Uses pixelSideLength as the diameter of a pixel in [kpc].

source
synchrotron_SB_to_luminosity(map, par::mappingParameters)

Converts a map of synchrotron surface brightness [erg/s/Hz/cm^2] to synchrotron luminosity [W/Hz]. Uses par as the mappingParameters of the original map.

source
SPHtoGrid.total_synch_luminosity_from_SBFunction
total_synch_luminosity_from_SB(map::Matrix{<:Real}, pixelSideLength::Real)

Computes the total synchrotron luminosity in [W/Hz] from a map of synchrotron surface brightness in [erg/s/Hz/cm^2].

source
total_synch_luminosity_from_SB(map::Matrix{<:Real}, par::mappingParameters)

Computes the total synchrotron luminosity in [W/Hz] from a map of synchrotron surface brightness in [erg/s/Hz/cm^2].

source
total_synch_luminosity_from_SB(filename::String)

Computes the total synchrotron luminosity in [W/Hz] from a map of synchrotron surface brightness in [erg/s/Hz/cm^2].

source
SPHtoGrid.beam_in_kpcFunction
beam_in_kpc(θ_beam::Vector{Union{Real, Unitful.AbstractQuantity}}, 
            c::Cosmology.AbstractCosmology, z::Real)

Converts the beam from arcmin to kpc.

source
SPHtoGrid.convert_Pnu_map_to_mJy_beamFunction
convert_Pnu_map_to_mJy_beam(map::Matrix{<:Real}, 
                            d_pixel::Real,
                            beam::Vector{Union{Real, Unitful.AbstractQuantity}}, 
                            c::Cosmology.AbstractCosmology, 
                            z::Real)

Converts a map from units [W / Hz] to [mJy / beam].

Parameters:

  • map: original map in [W / Hz].
  • d_pixel: size of a pixel in $kpc$.
  • beam: dimensions of the beam in $arcmin$.
  • c: Cosmology used for conversion.
  • z: Redshift of the image.
source
convert_Pnu_map_to_mJy_beam(map::Matrix{<:Real}, 
                            d_pixel::Real,
                            beam::Union{Real, Unitful.AbstractQuantity}, 
                            c::Cosmology.AbstractCosmology, 
                            z::Real)

Converts a map from units [W / Hz] to [mJy / beam] for a circular beam.

Parameters:

  • map: original map in [W / Hz].
  • d_pixel: size of a pixel in $kpc$.
  • beam: radius of the beam in $arcmin$.
  • c: Cosmology used for conversion.
  • z: Redshift of the image.
source
convert_Pnu_map_to_mJy_beam(map::Matrix{<:Real}, 
                            d_pixel::Real,
                            beam::Union{T, Vector{T}}, 
                            h::AbstractGadgetHeader) where T::Union{Real, Unitful.AbstractQuantity}

Converts a map from units [W / Hz] to [mJy / beam] by using a Gadget header.

Parameters:

  • map: original map in [W / Hz].
  • d_pixel: size of a pixel in $kpc$.
  • beam: radius/dimensions of the beam in $arcmin$.
  • h: Gadget header of simulation
source
SPHtoGrid.polarisation_angleFunction
polarisation_angle(Q_image, U_image, Iν_image=nothing, Iν_cutoff= 0.0)

Compute the polarisation fraction image from Stokes Q and U images.

source