Utils
CosmoParticles.get_dims
— Functionget_dims(projection::Symbol)
get_dims(dims::AbstractArray)
Returns the 2D dimensions of the passed projection, or the dimensions themselves.
The following dimensions are returned:
[1, 3]
::edgeon
or:xz
[2, 3]
::sideon
or:yz
[1, 2]
::faceon
or:xy
CosmoParticles.get_losdim
— Functionget_losdim(projection::Symbol)
get_losdim(dims::AbstractArray)
Returns the 1D line-of-sight dimension of the passed projection, or of the passed 2D dimensions.
The following dimensions are returned:
2
::edgeon
or:xz
or[1, 3]
1
::sideon
or:yz
or[2, 3]
3
::faceon
or:xy
or[1, 2]
CosmoParticles.factor_to_physical
— Functionfactor_to_physical(z::Real, n::Real)
Returns $(1 + z)^{-n}$.
This is not exported.
CosmoParticles.factor_to_comoving
— Functionfactor_to_comoving(z::Real, n::Real)
Returns $(1 + z)^n$.
This is not exported.
CosmoParticles.product_preserve_type
— FunctionCosmoParticles.product_preserve_type(arr::AbstractArray{T}, b::Real) where {T}
Multiply an array with a scalar while preserving the element type of the array.
For unitful arrays, the scalar factor is converted to the number type of the quantity before multiplying.
This is not exported.
CosmoParticles.product_preserve_type!
— FunctionCosmoParticles product_preserve_type!(arr::AbstractArray{T}, b::Real) where {T}
Multiply an array with a scalar in-place while preserving the element type of the array.
By converting the scalar factor to the array element type, this can be more performant than a normal broadcasted product. For unitful arrays, the scalar factor is converted to the number type of the quantity before multiplying.
This is not exported.
CosmoParticles.ustrip_lazy
— FunctionCosmoParticles.ustrip_lazy([unit,] a::Number)
CosmoParticles.ustrip_lazy([unit,] a::AbstractArray)
CosmoParticles.ustrip_lazy!(unit, a::AbstractArray)
Strips off the units of unitful arrays in a performant way while keeping the number type conserved (not always the case for ustrip
).
Like ustrip
for normal unitful arrays, but without reallocating non-unitful or lazy arrays. Differently to ustrip
, this also works for Number
s and arrays thereof, simply returning the original array.
Note that after calling this method with a different conversion unit, the original array still has the old units, but the numerical values correspond to the new units. This method should always be called as a = uconvert_lazy!(u, a)
.
This is not exported.
CosmoParticles.uconvert_lazy
— FunctionCosmoParticles.uconvert_lazy(u::Unitful.Units, a::AbstractArray{<:Quantity})
Converts the unitful array to the given units while preserving the number type passed (not always the case for uconvert
).
This is not exported.
CosmoParticles.uconvert_lazy!
— FunctionCosmoParticles.uconvert_lazy!(u::Unitful.Units, a::AbstractArray{<:Quantity{T,D,U}}) where {T,D,U}
Converts the unitful array to the specified units in-place.
Note that after calling this method the original array still has the old units, but the numerical values correspond to the new units. This method should always be called as a = uconvert_lazy!(u, a)
.
This is not exported.