Utils

CosmoParticles.get_dimsFunction
get_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
source
CosmoParticles.get_losdimFunction
get_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]
source
CosmoParticles.product_preserve_typeFunction
CosmoParticles.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.

source
CosmoParticles.product_preserve_type!Function
CosmoParticles 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.

source
CosmoParticles.ustrip_lazyFunction
CosmoParticles.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 Numbers 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.

source
CosmoParticles.uconvert_lazyFunction
CosmoParticles.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.

source
CosmoParticles.uconvert_lazy!Function
CosmoParticles.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.

source