Auxiliary functions
These functions are used internally and none are exported.
These functions may depend on the particulars of the simulation code (e.g. units).
Base.intersect
— MethodNew methods for Base.intersect
to use with the Colon
type.
Base.intersect
— MethodNew methods for Base.intersect
to use with the Vector{Bool}
type.
Base.isempty
— MethodNew method for Base.isempty
to check for empty LaTeXStrings.
Base.iszero
— MethodNew method for Base.iszero
to compare IndexType
with 0 as an integer.
Base.union
— MethodNew methods for Base.union
to use with the Vector{Bool}
type.
GalaxyInspector.absCoor
— MethodabsCoor(
plot::Union{Makie.FigureAxisPlot,Makie.Axis,Makie.Figure},
r_x::Real,
r_y::Real,
)::NTuple{2,Float64}
Compute the absolute x and y coordinates of a plot, from the relative ones.
Arguments
plot::Union{Makie.FigureAxisPlot,Makie.Axis,Makie.Figure}
: Plot, axis, or figure for which the absolute coordinates will be calculated. In the case of a figure, it will use the limits from the current axis object.r_x::Real
: Relative x coordinate.r_y::Real
: Relative y coordinate.
Returns
- A tuple with the absolute coordinates, (x, y).
Examples
julia> absCoor(lines(rand(100)), 0.5, 0.5)
(50.50000071525574, 0.48792968317866325)
GalaxyInspector.area
— MethodArea of a circle with radius r
.
GalaxyInspector.barPlotLabelFormater
— MethodbarPlotLabelFormater(x::LaTeXString)::LaTeXString
Format a number to be a barplot label.
Method for compatibility with the barplot! function of Makie.
Arguments
x::Number
: Value to be formatted.
Returns
- The bar label.
GalaxyInspector.barPlotLabelFormater
— MethodbarPlotLabelFormater(x::Number)::LaTeXString
Format a number to be a barplot label.
For values between 0 and 0.01 the label will be "< 0.01", otherwise it will be the value itself with 2 digits.
Arguments
x::Number
: Value to be formatted.
Returns
- The bar label.
GalaxyInspector.bigiel2008
— Methodbigiel2008(
ΣH::Vector{<:SurfaceDensity};
<keyword arguments>
)::Vector{<:Number}
Kennicutt-Schmidt law for the molecular or neutral gas, taken from a set of observations of nearby galaxies.
From Bigiel et al. (2008) (Section 3.1), we have
\[\Sigma_\mathrm{SFR} = a \left( \frac{\Sigma_\mathrm{HI, H_2, gas}}{10 \, \mathrm{M_\odot \, pc^{-2}}} \right)^{\!N} \, ,\]
where N is the power-law index, and $A = \log_{10}(a)$, where $a$ is $\Sigma_\mathrm{SFR}$ at the fiducial gas surface density of $10 \, \mathrm{M_\odot \, pc^{-2}}$.
Arguments
ΣH::Vector{<:SurfaceDensity}
: Values of the molecular or neutral gas surface density, with units.molecular::Bool=true
: If the x axis will be the area mass density of molecular hydrogen, or, if set to false, the area mass density of neutral hydrogen.log_output::Bool=true
: If the output will the $\log_{10}$ of the star formation area density, or the star formation area density itself (with units). Iflog_output
= true, the implied unit is $\mathrm{M_\odot \, yr^{-1} \, kpc^{-2}}$
Returns
- The star formation area density.
References
F. Bigiel et al. (2008). THE STAR FORMATION LAW IN NEARBY GALAXIES ON SUB-KPC SCALES. The Astrophysical Journal, 136(6), 2846. doi:10.1088/0004-6256/136/6/2846
GalaxyInspector.cleanPlot!
— MethodDefault function to end cleanPlot!
recursion if an unknown type is encountered.
GalaxyInspector.cleanPlot!
— MethodcleanPlot!(ax::Makie.Axis)::Bool
Empty an axis.
Arguments
ax::Makie.Axis
: Axis to be emptied.
Returns
- Flag to indicate that an axis has been emptied.
GalaxyInspector.cleanPlot!
— MethodcleanPlot!(figure::Makie.Figure)::Nothing
Delete all the legends of a figure and empty all its axes.
Arguments
figure::Makie.Figure
: Figure to be cleaned.
GalaxyInspector.cleanPlot!
— MethodcleanPlot!(legend::Union{Makie.Legend,Makie.Colorbar})::Bool
Delete a legend or colorbar.
Arguments
legend::Union{Makie.Legend,Makie.Colorbar}
: Legend or colorbar to be deleted.
Returns
- Flag to indicate that a legend or colorbar has been deleted.
GalaxyInspector.computeParticleBandProfile
— MethodcomputeParticleBandProfile(
positions::Matrix{<:Unitful.Length},
quantity::Vector{<:Number},
grid::CircularGrid;
<keyword arguments>
)::NTuple{2,Vector{<:Number}}
Compute a profile of the mean and standard deviation of quantity
, using an 1D histogram
Empty bins have NaN as mean and standard deviation.
Arguments
positions::Matrix{<:Unitful.Length}
: Positions of the cells/particles. Each column is a cell/particle and each row a dimension.quantity::Vector{<:Number}
: The profile will be of this quantity.grid::CircularGrid
: Circular grid.flat::Bool=true
: If the profile will be 2D, using rings, or 3D, using spherical shells.
Returns
A tuple with two elements:
- A vector with the mean value for each bin.
- A vector with the standard deviation for each bin.
GalaxyInspector.computeParticleProfile
— MethodcomputeParticleProfile(
positions::Matrix{<:Unitful.Length},
quantity::Vector{<:Number},
grid::CircularGrid;
<keyword arguments>
)::Vector{<:Number}
Compute a profile, using an 1D histogram.
Arguments
positions::Matrix{<:Unitful.Length}
: Positions of the cells/particles. Each column is a cell/particle and each row a dimension.quantity::Vector{<:Number}
: The profile will be of this quantity.grid::CircularGrid
: Circular grid.norm_values::Vector{<:Number}=Number[]
: Values to normalizequantity
.flat::Bool=true
: If the profile will be 2D, using rings, or 3D, using spherical shells.total::Bool=true
: If the sum (default) or the mean ofquantity
will be computed for each bin.cumulative::Bool=false
: If the profile will be accumulated or not.density::Bool=false
: If the profile will be of the density ofquantity
.empty_nan::Bool=true
: If empty bins will be set to NaN, 0 is used otherwise. Be careful ifempty_nan
= true andcumulative
= true, because every bin after the first NaN will be set to NaN.
Returns
- Vector with the values of the profile.
GalaxyInspector.cubicSplineKernel
— MethodcubicSplineKernel(q::Real, h::Number)::Number
2D cubic spline kernel.
Arguments
q::Real
: Relative distance to the neighbor, $|r - r'| / h$.h::Number
: Smoothing length.
Returns
- The kernel function evaluated at a separation
q
*h
, and with a smoothing lengthh
.
References
J. J. Monaghan (1992). Smoothed Particle Hydrodynamics. Annual Review of Astronomy and Astrophysics, 30, 543-574. doi:10.1146/annurev.aa.30.090192.002551
M.B. Liu et al. (2010). Smoothed Particle Hydrodynamics (SPH): an Overview and Recent Developments. Archives of Computational Methods in Engineering, 17, 25–76. doi:10.1007/s11831-010-9040-7
GalaxyInspector.deltas
— Methoddeltas(data::Vector{<:Number})::Vector{<:Number}
Compute the difference between each consecutive pair of elements in data
.
Arguments
data::Vector{<:Number}
: Data vector. It has to have at least 2 elements.
Returns
- A vector with the difference between each consecutive pair of elements in
data
, the first element is 0 by convention.
GalaxyInspector.density3DProjection
— Methoddensity3DProjection(
data_dict::Dict,
grid::CubicGrid,
quantity::Symbol,
type::Symbol;
<keyword arguments>
)::Array{Float64,3}
Sample the 3D density field of a given quantity using a cubic grid
If the source of the field are particles, a simple 3D histogram is used. If they are Voronoi cells instead, the density of the cell that intersects each voxel is used.
Arguments
data_dict::Dict
: A dictionary with the following shape::sim_data
-> ::Simulation (seeSimulation
).:snap_data
-> ::Snapshot (seeSnapshot
).:gc_data
-> ::GroupCatalog (seeGroupCatalog
).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).- ...
groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).- ...
grid::CubicGrid
: Cubic grid.quantity::Symbol
: Which density will be calculated. The options are::stellar_mass
-> Stellar density.:gas_mass
-> Gas density.:hydrogen_mass
-> Hydrogen density.:dm_mass
-> Dark matter density.:bh_mass
-> Black hole density.:molecular_mass
-> Molecular hydrogen ($\mathrm{H_2}$) density.:br_molecular_mass
-> Molecular hydrogen ($\mathrm{H_2}$) density, computed using the pressure relation in Blitz et al. (2006).:atomic_mass
-> Atomic hydrogen ($\mathrm{HI}$) density.:ionized_mass
-> Ionized hydrogen ($\mathrm{HII}$) density.:neutral_mass
-> Neutral hydrogen ($\mathrm{HI + H_2}$) density.:stellar_gas_mass
-> Stellar gas mass (according to our SF model).:ode_metal_mass
-> Metal mass (according to our SF model).:dust_mass
-> Dust mass.
type::Symbol
: If the source of the field are:particles
or Voronoi:cells
.m_unit::Unitful.Units=u"Msun"
: Mass unit.l_unit::Unitful.Units=u"kpc"
: Length unit.filter_function::Function=filterNothing
: A function with the signature:filter_function(data_dict) -> indices
where
data_dict::Dict
: A dictionary with the following shape::sim_data
-> ::Simulation (seeSimulation
).:snap_data
-> ::Snapshot (seeSnapshot
).:gc_data
-> ::GroupCatalog (seeGroupCatalog
).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).cell/particle type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).- ...
groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).groupcat type
-> (block
-> data ofblock
,block
-> data ofblock
, ...).- ...
indices::Dict
: A dictionary with the following shape:cell/particle type
-> idxs::IndexTypecell/particle type
-> idxs::IndexTypecell/particle type
-> idxs::IndexType- ...
Returns
- A 3D array with the density at each point of the 3D grid.
References
L. Blitz et al. (2006). The Role of Pressure in GMC Formation II: The H2-Pressure Relation. The Astrophysical Journal, 650(2), 933. doi:10.1086/505417
GalaxyInspector.energyIntegrand
— MethodenergyIntegrand(a::Real, header::SnapshotHeader)::Float64
The integrand of the integral that converts the scale factor into physical time:
\[\frac{1}{H\,\sqrt{\mathcal{E}}} \, ,\]
where
\[\mathcal{E} = \Omega_\Lambda + (1 - \Omega_\Lambda - \Omega_m) \, a^{-2} + \Omega_m \, a^{-3} \, ,\]
\[H = H_0 \, a \, .\]
Arguments
a::Real
: Scale factor.header::SnapshotHeader
: Header of the relevant snapshot file.
Returns
- The integrand evaluated at
a
, in $\mathrm{Gyr}$.
GalaxyInspector.evaluateNormal
— MethodevaluateNormal(data::Vector{<:Number})::Vector{<:Number}
Evaluate a normal distribution at the values in data
.
The median and standard deviation of the distribution are the ones from data
itself.
Arguments
data::Vector{<:Number}
: Data vector used to compute the mean and standard deviation of the normal distribution.
Returns
- The normal distribution evaluated at the values in
data
.
GalaxyInspector.findClosestSnapshot
— MethodfindClosestSnapshot(simulation_path::String, time::Unitful.Time)::Int
Find the global index, in the context of the simulation, of the snapshot with a physical time closest to time
.
Arguments
simulation_path::String
: Path to the simulation directory, set in the code variableOutputDir
.time::Unitful.Time
: Target physical time.
Returns
- The index of the snapshot with a physical time closest to
time
.
GalaxyInspector.findClosestSnapshot
— MethodfindClosestSnapshot(simulation_path::String, times::Vector{<:Unitful.Time})::Vector{Int}
Find the global index, in the context of the simulation, of the snapshot with a physical time closest to each of the ones given in times
.
Arguments
simulation_path::String
: Path to the simulation directory, set in the code variableOutputDir
.times::Vector{<:Unitful.Time}
: Target physical times.
Returns
- The indices of the snapshots with physical times closest to
times
.
GalaxyInspector.flattenGrid
— MethodflattenGrid(cubic_grid::CubicGrid)::SquareGrid
Using a CubicGrid
construct a SquareGrid
with the same center, number of bins, and physical side length.
Arguments
cubic_grid::CubicGrid
: Cubic grid.
Returns
- A square grid.
GalaxyInspector.formatError
— MethodformatError(q_mean::Number, q_error::Number)::NTuple{2,<:Number}
Nicely format a magnitude with uncertainty.
It follows the traditional rules for error presentation: the error has only one significant digit, unless such digit is a one, in which case two significant digits are used. The median will have as many digits as to match the last significant position of the error. An error equal to 0 will leave the mean unchanged.
Arguments
q_mean::Number
: Mean value.q_error::Number
: Error value. It must be positive.
Returns
- A tuple with the formatted mean and error values.
Examples
julia> formatError(69.42069, 0.038796)
(69.42, 0.04)
julia> formatError(69.42069, 0.018796)
(69.421, 0.019)
julia> formatError(15.42, 0.00004)
(15.42, 4.0e-5)
julia> formatError(69.42069, 0.0)
(69.42069, 0.0)
julia> formatError(69.42069, 93.4)
(70.0, 90.0)
julia> formatError(69.42069, 123.4)
(70.0, 120.0)
julia> formatError(15.42069, 16.4)
(15.0, 16.0)
GalaxyInspector.getEmpty
— MethodAlways returns an empty vector, for any type and number of arguments.
GalaxyInspector.getLabel
— MethodgetLabel(
label::AbstractString,
factor::Int,
unit::Unitful.Units;
<keyword arguments>
)::AbstractString
Construct an axis label.
Arguments
label::AbstractString
: Variable name.factor::Int
: Exponential factor to scale down the units. If different from 0, a term of the form 10^factor
will be added to the label.unit::Unitful.Units
: Unit of the axis.latex::Bool=true
: If the output will be aLaTeXString
, or a plainString
.
Returns
- The
LaTeXString
orString
: "label
[10^factor
unit
]". Iflabel
is "", an empty string is returned. Thefactor
term only appears iffactor
!= 0, the unit term only appears ifunit
!=Unitful.NoUnits
, and the brackets only appears if there are a factor and/or a unit term.
GalaxyInspector.getNothing
— MethodAlways returns nothing
, for any type and number of arguments.
GalaxyInspector.getUnitLabel
— MethodgetUnitLabel(factor::Int, unit::Unitful.Units; <keyword arguments>)::AbstractString
Construct the unit part of an axis label.
Arguments
factor::Int
: Exponential factor to scale down the units. If different from 0, a term of the form 10^factor
will be added to the label.unit::Unitful.Units
: Unit of the axis.latex::Bool=true
: If the output will be aLaTeXString
, or a plainString
.
Returns
- The
LaTeXString
orString
: "10^factor
unit
". Thefactor
term only appears iffactor
!= 0, the unit term only appears ifunit
!=Unitful.NoUnits
.
GalaxyInspector.histogram1D
— Methodhistogram1D(
positions::Vector{<:Number},
grid::Union{LinearGrid,CircularGrid},
)::Vector{Int}
Compute a 1D histogram of positions
.
Arguments
positions::Vector{<:Number}
: Values for which the histogram will be constructed.grid::Union{LinearGrid,CircularGrid}
: A linear or circular grid.
Returns
- A vector with the counts.
GalaxyInspector.histogram1D
— Methodhistogram1D(
positions::Vector{<:Number},
values::Vector{<:Number},
grid::Union{LinearGrid,CircularGrid};
<keyword arguments>
)::Vector{<:Number}
Compute a 1D histogram of values
.
Arguments
positions::Vector{<:Number}
: Positions of thevalues
within a 1D axis. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each bin, according to theirpositions
.grid::Union{LinearGrid,CircularGrid}
: A linear or circular grid.total::Bool=true
: If the sum (default) or the mean ofvalues
will be computed for each bin.empty_nan::Bool=true
: If NaN will be put into empty bins, 0 is used otherwise.
Returns
- A vector with the histogram values.
GalaxyInspector.histogram1D
— Methodhistogram1D(
positions::Vector{<:Number},
values::Vector{<:Number},
edges::Vector{<:Number};
<keyword arguments>
)::Vector{<:Number}
Compute a 1D histogram of values
.
Arguments
positions::Vector{<:Number}
: Positions of thevalues
within a 1D axis. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each bin, according to theirpositions
.edges::Vector{<:Number}
: A sorted list of bin edges.total::Bool=true
: If the sum (default) or the mean ofvalues
will be computed for each bin.empty_nan::Bool=true
: If NaN will be put into empty bins, 0 is used otherwise.
Returns
- A vector with the histogram values.
GalaxyInspector.histogram1D
— Methodhistogram1D(positions::Vector{<:Number}, edges::Vector{<:Number})::Vector{Int}
Compute a 1D histogram of positions
.
Arguments
positions::Vector{<:Number}
: Values for which the histogram will be constructed.edges::Vector{<:Number}
: A sorted list of bin edges.
Returns
- A vector with the counts.
GalaxyInspector.histogram2D
— Methodhistogram2D(positions::Matrix{<:Number}, grid::SquareGrid)::Matrix{Int}
Compute a 2D histogram of positions
.
Arguments
positions::Matrix{<:Number}
: Values for which the histogram will be constructed.grid::SquareGrid
: A square grid.
Returns
- A matrix with the counts.
GalaxyInspector.histogram2D
— Methodhistogram2D(
positions::Matrix{<:Number},
values::Vector{<:Number},
grid::SquareGrid;
<keyword arguments>
)::Matrix{<:Number}
Compute a 2D histogram of values
.
Arguments
positions::Matrix{<:Number}
: Positions of the values in the grid. Each column corresponds to a value and each row is a dimension. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each square bin, according to theirpositions
.grid::SquareGrid
: A square grid.total::Bool=true
: If the sum (default) or the mean ofvalues
will be computed in each bin.empty_nan::Bool=true
: If NaN will be put into empty bins, 0 is used otherwise.
Returns
- A matrix with the histogram values.
GalaxyInspector.histogram2D
— Methodhistogram2D(
positions::Matrix{<:Number},
values::Vector{<:Number},
x_edges::Vector{<:Number},
y_edges::Vector{<:Number};
<keyword arguments>
)::Matrix{<:Number}
Compute a 2D histogram of values
.
Arguments
positions::Matrix{<:Number}
: Positions of the values in the grid. Each column corresponds to a value and each row is a dimension. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each square bin, according to theirpositions
.x_edges::Vector{<:Number}
: A sorted list of bin edges for the x axis.y_edges::Vector{<:Number}
: A sorted list of bin edges for the y axis.total::Bool=true
: If the sum (default) or the mean ofvalues
will be computed in each bin.empty_nan::Bool=true
: If NaN will be put into empty bins, 0 is used otherwise.
Returns
- A matrix with the histogram values.
GalaxyInspector.histogram2D
— Methodhistogram2D(
positions::Matrix{<:Number},
x_edges::Vector{<:Number},
y_edges::Vector{<:Number},
)::Matrix{Int}
Compute a 2D histogram of positions
.
Arguments
positions::Matrix{<:Number}
: Values for which the histogram will be constructed.x_edges::Vector{<:Number}
: A sorted list of bin edges for the x axis.y_edges::Vector{<:Number}
: A sorted list of bin edges for the y axis.
Returns
- A matrix with the counts.
GalaxyInspector.histogram3D
— Methodhistogram3D(positions::Matrix{<:Number}, grid::CubicGrid)::Array{Int,3}
Compute a 3D histogram of positions
.
Arguments
positions::Matrix{<:Number}
: Values for which the histogram will be constructed.grid::CubicGrid
: A cubic grid.
Returns
- A 3D tensor with the counts.
GalaxyInspector.histogram3D
— Methodhistogram3D(
positions::Matrix{<:Number},
values::Vector{<:Number},
grid::CubicGrid;
<keyword arguments>
)::Array{<:Number,3}
Compute a 3D histogram of values
.
Arguments
positions::Matrix{<:Number}
: Positions of the values in the grid. Each column corresponds to a value and each row is a dimension. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each square bin, according to theirpositions
.grid::CubicGrid
: A cubic grid.total::Bool=true
: If the sum (default) or the mean ofvalues
will be computed in each bin.empty_nan::Bool=true
: If NaN will be put into empty bins, 0 is used otherwise.
Returns
- A 3D tensor with the histogram values.
GalaxyInspector.hvcatImages
— MethodhvcatImages(
blocks_per_row::Int,
paths::Vector{String};
<keyword arguments>
)::Nothing
Join several images vertically and horizontally.
The elements will fill the rows and columns starting at the top left, going from left to right and from top to bottom (row-major order).
Arguments
blocks_per_row::Int
: Number of columns.paths::Vector{String}
: Paths to the images.output_path::String="./joined_images.png"
: Path to the output image.
GalaxyInspector.invBigiel2008
— MethodinvBigiel2008(
Σsfr ::Vector{<:MassFlowDensity};
<keyword arguments>
)::Vector{<:Number}
Inverse Kennicutt-Schmidt law for the molecular or neutral gas, taken from a set of observations of nearby galaxies.
From Bigiel et al. (2008) (Section 3.1, Eq. 2), we have
\[\Sigma_\mathrm{SFR} = a \left( \frac{\Sigma_\mathrm{HI, H_2, gas}}{10 \, \mathrm{M_\odot \, pc^{-2}}} \right)^{\!N} \, ,\]
where N is the power-law index, and $A = \log_{10}(a)$, where $a$ is $\Sigma_\mathrm{SFR}$ at the fiducial gas surface density of $10 \, \mathrm{M_\odot \, pc^{-2}}$.
Arguments
Σsfr ::Vector{<:MassFlowDensity}
: Values of the star formation area density, with units.molecular::Bool=true
: If the output will be the area mass density of molecular hydrogen, or, if set to false, the area mass density of neutral hydrogen.log_output::Bool=true
: If the output will the $\log_{10}$ of the molecular or neutral gas surface density, or the molecular or neutral gas surface density itself (with units). Iflog_output
= true, the implied unit is $10 \, \mathrm{M_\odot \, pc^{-2}}$
Returns
- The molecular or neutral gas surface density.
References
F. Bigiel et al. (2008). THE STAR FORMATION LAW IN NEARBY GALAXIES ON SUB-KPC SCALES. The Astrophysical Journal, 136(6), 2846. doi:10.1088/0004-6256/136/6/2846
GalaxyInspector.invKennicutt1998
— MethodinvKennicutt1998(Σsfr::Vector{<:MassFlowDensity}; <keyword arguments>)::Vector{<:Number}
Inverse Kennicutt-Schmidt law, taken from a set of observations of nearby galaxies.
From Kennicutt (1998) (Section 4, Eq. 4), we have
\[\Sigma_\mathrm{SFR} = a \left( \frac{\Sigma_\mathrm{gas}}{1 \, \mathrm{M_\odot \, pc^{-2}}} \right)^{\!N} \mathrm{M_\odot \, yr^{-1] \, kpc^{-2}} \, ,\]
where N is the power-law index and $a$ is $\Sigma_\mathrm{SFR}$ at the fiducial gas surface density of $1 \, \mathrm{M_\odot \, pc^{-2}}$.
Arguments
Σsfr::Vector{<:MassFlowDensity}
: Values of the star formation area density, with units.log_output::Bool=true
: If the output will the $\log_{10}$ of the gas mass surface density, or the gas mass surface density itself (with units). Iflog_output
= true, the implied unit is $\mathrm{M_\odot \, pc^{-2}}$
Returns
- The gas mass surface density.
References
R. C. Kennicutt (1998). The Global Schmidt Law in Star-forming Galaxies. The Astrophysical Journal, 498(2), 541-552. doi:10.1086/305588
GalaxyInspector.isPositive
— MethodTest for strict positivity.
GalaxyInspector.kennicutt1998
— Methodkennicutt1998(Σgas::Vector{<:SurfaceDensity}; <keyword arguments>)::Vector{<:Number}
Kennicutt-Schmidt law, taken from a set of observations of nearby galaxies.
From Kennicutt (1998) (Section 4, Eq. 4), we have
\[\Sigma_\mathrm{SFR} = a \left( \frac{\Sigma_\mathrm{gas}}{1 \, \mathrm{M_\odot \, pc^{-2}}} \right)^{\!N} \mathrm{M_\odot \, yr^{-1] \, kpc^{-2}} \, ,\]
where N is the power-law index and $a$ is $\Sigma_\mathrm{SFR}$ at the fiducial gas surface density of $1 \, \mathrm{M_\odot \, pc^{-2}}$.
Arguments
Σgas::Vector{<:SurfaceDensity}
: Values of the gas mass surface density, with units.log_output::Bool=true
: If the output will the $\log_{10}$ of the star formation area density, or the star formation area density itself (with units). Iflog_output
= true, the implied unit is $\mathrm{M_\odot \, yr^{-1} \, kpc^{-2}}$
Returns
- The star formation area density.
References
R. C. Kennicutt (1998). The Global Schmidt Law in Star-forming Galaxies. The Astrophysical Journal, 498(2), 541-552. doi:10.1086/305588
GalaxyInspector.listHistogram1D
— MethodlistHistogram1D(
positions::Vector{<:Number},
values::Vector{<:Number},
grid::Union{LinearGrid,CircularGrid},
)::Vector{Vector{<:Number}}
Compute a 1D histogram of values
, returning the full list of values
within each bin.
Arguments
positions::Vector{<:Number}
: Positions of thevalues
within a 1D axis. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each bin, according to theirpositions
.grid::Union{LinearGrid,CircularGrid}
: A linear or circular grid.
Returns
- A vector with the lists of `values` within each bin.
GalaxyInspector.listHistogram1D
— MethodlistHistogram1D(
positions::Vector{<:Number},
values::Vector{<:Number},
edges::Vector{<:Number},
)::Vector{Vector{<:Number}}
Compute a 1D histogram of values
, returning the full list of values
within each bin.
Arguments
positions::Vector{<:Number}
: Positions of thevalues
within a 1D axis. This determines to which bin each value will be added.values::Vector{<:Number}
: The values that will be added up in each bin, according to theirpositions
.edges::Vector{<:Number}
: A sorted list of bin edges.
Returns
- A vector with the lists of
values
within each bin.
GalaxyInspector.listHistogram3D
— MethodlistHistogram3D(positions::Matrix{<:Number}, grid::CubicGrid)::Array{Vector{Int},3}
Compute a 3D histogram of positions
, returning the full list of indices within each bin.
Arguments
positions::Matrix{<:Number}
: Positions of the points in the grid. Each column corresponds to a point and each row is a dimension. This determines to which bin the index of each point will be added.grid::CubicGrid
: A cubic grid.
Returns
- A tensor with the indices of the points within each bin.
GalaxyInspector.metaFormatter
— MethodmetaFormatter(level::LogLevel, _module, group, id, file, line)
Formatter for loggers.
See the documentation for ConsoleLogger
GalaxyInspector.parserWS
— MethodparserWS(data::AbstractString)::Union{Float64,Missing}
Parse a string as a Float64, ignoring white spaces. If the string is empty return missing.
Arguments
data::AbstractString
: String to be parsed.
Returns
- Number in the string as a Float64.
GalaxyInspector.plotParams
— MethodplotParams(quantity::Symbol)::PlotParams
Select the plotting parameters for a given quantity
.
Arguments
quantity::Symbol
: The options are::stellar_mass
-> Stellar mass.:gas_mass
-> Gas mass.:hydrogen_mass
-> Hydrogen mass.:dm_mass
-> Dark matter mass.:bh_mass
-> Black hole mass.:molecular_mass
-> Molecular hydrogen ($\mathrm{H_2}$) mass.:br_molecular_mass
-> Molecular hydrogen ($\mathrm{H_2}$) mass, computed using the pressure relation in Blitz et al. (2006).:atomic_mass
-> Atomic hydrogen ($\mathrm{HI}$) mass.:ionized_mass
-> Ionized hydrogen ($\mathrm{HII}$) mass.:neutral_mass
-> Neutral hydrogen ($\mathrm{HI + H_2}$) mass.:stellar_gas_mass
-> Stellar gas mass (according to our SF model).:ode_metal_mass
-> Metal mass (according to our SF model).:ode_metallicity
-> Metallicity (according to our SF model).:dust_mass
-> Dust mass.:generic_mass
-> Parameters for plots with several different masses.:stellar_number
-> Number of stellar particles.:gas_number
-> Number of gas cells.:dm_number
-> Number of dark matter particles.:bh_number
-> Number of black hole particles.:molecular_fraction
-> Gas mass fraction of molecular hydrogen.:br_molecular_fraction
-> Gas mass fraction of molecular hydrogen, computed using the pressure relation in Blitz et al. (2006).:atomic_fraction
-> Gas mass fraction of atomic hydrogen.:ionized_fraction
-> Gas mass fraction of ionized hydrogen.:neutral_fraction
-> Gas mass fraction of neutral hydrogen.:molecular_neutral_fraction
-> Fraction of molecular hydrogen in the neutral gas.:ionized_neutral_fraction
-> Fraction of ionized gas to neutral gas.:stellar_gas_fraction
-> Stellar gas fraction (according to our SF model).:metal_gas_fraction
-> Metallicity (according to our SF model).:dust_fraction
-> Dust mass fraction.:generic_fraction
-> Parameters for plots with several different fraction.:gas_mass_density
-> Gas mass density.:hydrogen_mass_density
-> Hydrogen mass density.:gas_number_density
-> Gas number density.:molecular_number_density
-> Molecular hydrogen number density.:br_molecular_number_density
-> Molecular hydrogen number density, computed using the pressure relation in Blitz et al. (2006).:atomic_number_density
-> Atomic hydrogen number density.:ionized_number_density
-> Ionized hydrogen number density.:neutral_number_density
-> Neutral hydrogen number density.:stellar_area_density
-> Stellar area mass density, for a radius ofDISK_R
.:gas_area_density
-> Gas mass surface density, for a radius ofDISK_R
.:molecular_area_density
-> Molecular mass surface density, for a radius ofDISK_R
.:br_molecular_area_density
-> Molecular mass surface density, for a radius ofDISK_R
, computed using the pressure relation in Blitz et al. (2006).:atomic_area_density
-> Atomic hydrogen area mass density, for a radius ofDISK_R
.:ionized_area_density
-> Ionized hydrogen area mass density, for a radius ofDISK_R
.:neutral_area_density
-> Neutral mass surface density, for a radius ofDISK_R
.:sfr_area_density
-> Star formation rate area density, for the lastAGE_RESOLUTION
and a radius ofDISK_R
.:generic_area_density
-> Parameters for plots with several different area densities.:gas_td
-> Total gas depletion time.:molecular_td
-> Molecular hydrogen ($\mathrm{H_2}$) depletion time.:br_molecular_td
-> Molecular hydrogen ($\mathrm{H_2}$) depletion time, computed using the pressure relation in Blitz et al. (2006).:atomic_td
-> Atomic hydrogen ($\mathrm{HI}$) depletion time.:ionized_td
-> Ionized hydrogen ($\mathrm{HII}$) depletion time.:neutral_td
-> Neutral hydrogen ($\mathrm{HI + H_2}$) depletion time.:gas_metallicity
-> Mass fraction of all elements above He in the gas (solar units).:stellar_metallicity
-> Mass fraction of all elements above He in the stars (solar units).:X_gas_abundance
-> Gas abundance of element $\mathrm{X}$, as $12 + \log_{10}(\mathrm{X \, / \, H})$. The possibilities are the keys ofELEMENT_INDEX
.:X_stellar_abundance
-> Stellar abundance of element $\mathrm{X}$, as $12 + \log_{10}(\mathrm{X \, / \, H})$. The possibilities are the keys ofELEMENT_INDEX
.:stellar_radial_distance
-> Distance of every stellar particle to the origin.:gas_radial_distance
-> Distance of every gas cell to the origin.:dm_radial_distance
-> Distance of every dark matter particle to the origin.:stellar_xy_distance
-> Projected distance of every stellar particle to the origin.:gas_xy_distance
-> Projected distance of every gas cell to the origin.:dm_xy_distance
-> Projected distance of every dark matter particle to the origin.:gas_sfr
-> SFR associated to each gas particle/cell within the code.:mass_accretion
-> Gas accretion rate. Positive values mean gas infall into the virial radius $R_{200}$, and negative values mean outflow.:stellar_specific_am
-> Norm of the stellar specific angular momentum.:gas_specific_am
-> Norm of the gas specific angular momentum.:dm_specific_am
-> Norm of the dark matter specific angular momentum.:stellar_circularity
-> Stellar circularity.:stellar_vcirc
-> Stellar circular velocity.:stellar_vradial
-> Stellar radial speed.:stellar_vtangential
-> Stellar tangential speed.:stellar_vzstar
-> Stellar speed in the z direction, computed as $v_z \, \mathrm{sign}(z)$.:stellar_age
-> Stellar age.:sfr
-> Star formation rate.:ssfr
-> The specific star formation rate.:observational_sfr
-> Star formation rate of the lastAGE_RESOLUTION
.:observational_ssfr
-> The specific star formation rate of the lastAGE_RESOLUTION
.:stellar_eff
-> Star formation efficiency per free-fall time for the gas that has turn into stars.:gas_eff
-> Star formation efficiency per free-fall time for the gas.:molecular_eff
-> Star formation efficiency per free-fall time for the molecular hydrogen ($\mathrm{H_2}$) gas.:br_molecular_eff
-> Star formation efficiency per free-fall time for the molecular hydrogen ($\mathrm{H_2}$) gas, computed using the pressure relation in Blitz et al. (2006).:atomic_eff
-> Star formation efficiency per free-fall time for the atomic hydrogen ($\mathrm{HI}$) gas.:ionized_eff
-> Star formation efficiency per free-fall time for the ionized hydrogen ($\mathrm{HII}$) gas.:neutral_eff
-> Star formation efficiency per free-fall time for the neutral hydrogen ($\mathrm{HI + H_2}$) gas.:temperature
-> Gas temperature, as $\log_{10}(T \, / \, \mathrm{K})$.:pressure
-> Gas pressure.:scale_factor
-> Scale factor.:redshift
-> Redshift.:physical_time
-> Physical time since the Big Bang.:lookback_time
-> Physical time left to reach the last snapshot.:ode_gas_it
-> Integration time.:ode_gas_tau_s
-> Star formation time scale, $\tau_\mathrm{S}$.:ode_gas_eta_d
-> Photodissociation efficiency, $\eta_\mathrm{diss}$.:ode_gas_eta_i
-> Photoionization efficiency, $\eta_\mathrm{ion}$.:ode_gas_r
-> Mass recycling parameter, $R$.:ode_gas_cold_mf
-> Cold gas mass fraction.:ode_stellar_it
-> Integration time, for the gas that form the stars.:ode_stellar_tau_s
-> Star formation time scale, $\tau_\mathrm{S}$, for the gas that form the stars.:ode_stellar_eta_d
-> Photodissociation efficiency, $\eta_\mathrm{diss}$, for the gas that form the stars.:ode_stellar_eta_i
-> Photoionization efficiency, $\eta_\mathrm{ion}$, for the gas that form the stars.:ode_stellar_r
-> Mass recycling parameter, $R$, for the gas that form the stars.:ode_stellar_cold_mf
-> Cold gas mass fraction, for the gas that form the stars.:ode_stellar_gas_rho
-> Gas mass density, for the gas that form the stars.:ode_stellar_gas_Z
-> Gas metallicity, for the gas that form the stars (solar units).:ode_stellar_gas_mass
-> Cell mass, for the gas that form the stars.:ode_stellar_gas_sfr
-> SFR associated to the gas particles/cells within the code, for the gas that form the stars.:ode_stellar_gas_P
-> Gas pressure, for the gas that form the stars.
Returns
A
PlotParams
object, with entries:request::Dict{Symbol,Vector{String}}
-> Data request forreadSnapshot
.var_name::AbstractString
-> Name of the quantity for the plot axis.exp_factor::Int
-> Numerical exponent to scale down the axis.unit::Unitful.Units
-> Target unit for the axis.axis_label::AbstractString
-> Label for the axis.
References
L. Blitz et al. (2006). The Role of Pressure in GMC Formation II: The H2-Pressure Relation. The Astrophysical Journal, 650(2), 933. doi:10.1086/505417
GalaxyInspector.pointData
— MethodExtract all the data points in a Makie plot, axis, or figure. In the case of a figure, it will only take the data from the current axis object. It only works for scatter, line and scatterline plots.
GalaxyInspector.projectIntoCircularGrid
— MethodprojectIntoCircularGrid(
image::Matrix{<:Number},
n_bins::Int;
<keyword arguments>
)::Vector{<:Number}
Project image
into a circular grid, averaging the values in each concentric ring.
Arguments
image::Matrix{<:Number}
: Original matrix. It has to be a square matrix.n_bins::Int
: Number of bins for the circular grid.inscribed::Bool=true
: If the circular grid will be inscribed inimage
when doing the projection. If set to false, the matrix will be inscribed into the circular grid instead.total::Bool=false
: If the sum (total
= true) or the mean (total
= false) of the values in each of the old pixels that fall within each ring will be used.
Returns
- A vector with the averages of the values in each concentric ring.
GalaxyInspector.rangeCut!
— MethodrangeCut!(
raw_values::Vector{<:Number},
range::Tuple{<:Number,<:Number};
<keyword arguments>
)::Bool
Delete every element in raw_values
that is outside the given range
.
Arguments
raw_values::Vector{<:Number}
: Dataset that will be pruned.range::Tuple{<:Number,<:Number}
: The range in question.keep_edges::Bool=true
: If the edges of the range will be kept.min_left::Int=1
: Minimum number of values that need to be left after pruning to proceed with the transformation.
Returns
- If a transformation was performed.
GalaxyInspector.rangeCut!
— MethodrangeCut!(
m_data::Vector{<:Number},
s_data::Vector,
range::Tuple{<:Number,<:Number};
<keyword arguments>
)::Bool
Delete every element in m_data
that is outside the given range
.
Every corresponding element in s_data
(i.e. with the same index) will be deleted too.
Arguments
m_data::Vector{<:Number}
: Master dataset that will be pruned.s_data::Vector
: Slave dataset that will be pruned according to which values ofm_data
are outsiderange
.range::Tuple{<:Number,<:Number}
: The range in question.keep_edges::Bool=true
: If the edges of the range will be kept.min_left::Int=1
: Minimum number of values that need to be left in the master dataset after pruning to proceed with the transformation.
Returns
- If a transformation was performed.
GalaxyInspector.reduceResolution
— MethodreduceResolution(
hr_matrix::Matrix{<:Number},
factor::Int;
<keyword arguments>
)::Matrix{<:Number}
Reduce the number of rows and columns of hr_matrix
by factor
, averaging or adding up its values.
Arguments
hr_matrix::Matrix{<:Number}
: Original "high resolution" matrix. It has to be a square matrix.factor::Int
: Factor by which the number of rows and columns will be reduced. It has to divide the size ofhr_matrix
exactly.total::Bool=false
: If the sum (total
= true) or the mean (total
= false) of the values in each of the old pixels will be used for the new pixels.
Returns
- The new smaller matrix, with the average values.
GalaxyInspector.reduceTicks
— MethodreduceTicks(hr_ticks::Vector{<:Number}, factor::Int)::Vector{<:Number}
Reduce the number of ticks in hr_ticks
by factor
keeping the total length of the axis the same and assuming hr_ticks
are regularly spaced.
Arguments
hr_ticks::Vector{<:Number}
: Original "high resolution" list of ticks.factor::Int
: Factor by which the number of ticks will be reduced. It has to divide the size ofhr_ticks
exactly.
Returns
- The new shorter tick list.
GalaxyInspector.ring
— Methodring(vec::Vector, index::Integer)::Vector
Make the indexing operation vec[index]
work using modular arithmetic for the indices.
Arguments
vec::Vector
: Vector.index::Integer
: Index.
Returns
vec[mod1(index, length(vec))]
Examples
julia> ring([1, 2, 3], 11)
2
julia> ring([1, 2, 3], 3)
3
julia> ring([1, 2, 3], -5)
1
GalaxyInspector.safeSelect
— MethodsafeSelect(vec::Vector, index::IndexType)
Make the indexing operation vec[index]
ignoring indices that are out of bounds.
Arguments
vec::Vector
: Vector.index::IndexType
: Indices. It can be an integer (a single element), a vector of integers (several elements), anUnitRange
(e.g. 5:13), anStepRange
(e.g. 5:2:13) or (:) (every element).
Returns
vec[index (minus out of bounds indices)]
Examples
julia> safeSelect([1, 2, 3], 11)
Int[]
julia> safeSelect([1, 2, 3], 1:5)
3-element Vector{Int}:
1
2
3
julia> safeSelect([1, 2, 3], 1:3:10)
1
julia> safeSelect([1, 2, 3], [1, 2, 5, 9])
2-element Vector{Int}:
1
2
julia> safeSelect([1, 2, 3], (:))
3-element Vector{Int}:
1
2
3
GalaxyInspector.sanitizeData!
— MethodsanitizeData!(
x_data::Vector{<:Number},
y_data::Vector{<:Number};
<keyword arguments>
)::NTuple{4,Bool}
Do the following transformations over x_data
and y_data
, in order:
- Trim them to fit within the domain of the functions
func_domain[1]
andfunc_domain[2]
, respectively. - Trim them to fit within
range[1]
andrange[2]
, respectively. - Scale them down by a factor 10^
exp_factor[1]
and 10^exp_factor[2]
, respectively.
By default, no transformation is done.
The datasets must have the same length, and any operation that deletes an element, will delete the corresponding element (i.e. with the same index) in the other dataset, so that the dataset will remain of equal length.
Arguments
x_data::Vector{<:Number}
: First dataset to be sanitized.y_data::Vector{<:Number}
: Second dataset to be sanitized.func_domain::NTuple{2,Function}=(identity, identity)
:x_data
will be trimmed to fit within the domain of the functionfunc_domain[1]
, andy_data
will be trimmed to fit within the domain of the functionfunc_domain[2]
. The options are the scaling functions accepted by Makie: log10, log2, log, sqrt, Makie.logit, Makie.Symlog10, Makie.pseudolog10, and identity.range::Tuple{Tuple{<:Number,<:Number},Tuple{<:Number,<:Number}}=((-Inf, Inf), (-Inf, Inf))
: Every element inx_data
that falls outside ofrange[1]
will be deleted, and every element iny_data
that falls outside ofrange[2]
will be deleted.keep_edges::NTuple{2,Bool}=(true, true)
: If the edges of each correspondingrange
will be kept.min_left::Int=1
: Minimum number of values that need to be left in each dataset after any of the transformations to proceed with them.exp_factor::NTuple{2,Int}=(0, 0)
: Every element inx_data
will be divided by 10^exp_factor[1]
, and every element iny_data
will be divided by 10^exp_factor[2]
.
Returns
A tuple with four flags:
- If
x_data
was successfully modified to fit within the domain offunc_domain[1]
. - If
y_data
was successfully modified to fit within the domain offunc_domain[2]
. - If
x_data
was successfully modified to fit withinrange[1]
. - If
y_data
was successfully modified to fit withinrange[2]
.
- If
GalaxyInspector.sanitizeData!
— MethodsanitizeData!(
raw_values::Vector{<:Number};
<keyword arguments>
)::NTuple{2,Bool}
Do the following transformations over raw_values
, in order:
- Trim it to fit within the domain of the function
func_domain
. - Trim it to fit within
range
. - Scale it down by a factor of 10^
exp_factor
.
By default, no transformation is done.
Arguments
raw_values::Vector{<:Number}
: Dataset to be sanitized.func_domain::Function=identity
:raw_values
will be trimmed to fit within the domain of the functionfunc_domain
. The options are the scaling functions accepted by Makie: log10, log2, log, sqrt, Makie.logit, Makie.Symlog10, Makie.pseudolog10, and identity.range::Tuple{<:Number,<:Number}=(-Inf, Inf)
: Every element inraw_values
that falls outside ofrange
will be deleted.keep_edges::Bool=true
: If the edges ofrange
will be kept.min_left::Int=1
: Minimum number of values that need to be left after each transformation to proceed with it.exp_factor::Int=0
: Every element inraw_values
will be divided by 10^exp_factor
.
Returns
A tuple with two flags:
- If
raw_values
was mutated to fit within the domain offunc_domain
. - If
raw_values
was mutated to fit withinrange
.
- If
GalaxyInspector.scaledBins
— MethodscaledBins(
values::Vector{<:Number},
n_bins::Int;
<keyword arguments>
)::Vector{Float64}
Compute a set of bin edges, to encompass a given list of values.
Arguments
values::Vector{<:Number}
: Values to be binned.n_bins::Int
: Number of bins.scaling::Function=identity
: Scaling function. The options are the scaling functions accepted by Makie: log10, log2, log, sqrt, Makie.logit, Makie.Symlog10, Makie.pseudolog10, and identity.limits::Tuple{<:Number,<:Number}=(-Inf, Inf)
: Set it to a value different than(-Inf, Inf)
if you want to fix the limits of the bins.
Returns
- A sorted list of bin edges.
GalaxyInspector.setLogging!
— MethodsetLogging!(verb::Bool; <keyword arguments>)::Nothing
Set if logging messages will be printed out. By default no logs are printed.
Arguments
verb::Bool
: If logs will be printed out using the default logger.stream::IO=stdout
: Sets where to print the logs. It can be a file.
GalaxyInspector.setPositive
— MethodCreate a copy of list
with every negative value set to 0.
GalaxyInspector.smoothWindow
— MethodsmoothWindow(
x_data::Vector{<:Number},
y_data::Vector{<:Number},
n_bins::Int;
<keyword arguments>
)::NTuple{2,Vector{<:Number}}
Separate the values of x_data
in n_bins
bins and compute the mean value of x_data
and y_data
within each one.
Arguments
x_data::Vector{<:Number}
: x-axis data.y_data::Vector{<:Number}
: y-axis data.n_bins::Int
: Number of bins.scaling::Function=identity
: Scaling function for the x axis. The options are the scaling functions accepted by Makie: log10, log2, log, sqrt, Makie.logit, Makie.Symlog10, Makie.pseudolog10, and identity. All the values ofx_data
must be in the domain ofscaling
.
Returns
- A tuple with two vectors, containing the smoothed-out x and y values.
GalaxyInspector.unitList
— MethodList component units of a Unitful.Quantity
object.
GalaxyInspector.unitList
— MethodList component units of a Unitful.FreeUnits
object.
GalaxyInspector.volume
— MethodVolume of a sphere with radius r
.
GalaxyInspector.xlimits!
— MethodExtract the limits of the x axis, from a Makie plot, axis, or figure. In the case of a figure, it will take the limits from the current axis object.
GalaxyInspector.xscale
— MethodExtract the scale function of the x axis, from a Makie plot, axis, or figure. In the case of a figure, it will take the scale from the current axis object.
GalaxyInspector.ylimits!
— MethodExtract the limits of the y axis, from a Makie plot, axis, or figure. In the case of a figure, it will take the limits from the current axis object.
GalaxyInspector.yscale
— MethodExtract the scale function of the y axis, from a Makie plot, axis, or figure. In the case of a figure, it will take the scale from the current axis object.