Operations

Transformations

CosmoParticles.rotateFunction
rotate(p::AbstractParticles, rotmat::AbstractMatrix{<:Real}, prop)
rotate(p::AbstractParticles, rotmat::AbstractMatrix{<:Real}, props=[:pos, :vel])

Rotates the specified properties props of the particles p by the rotation matrix rotmat.

Creates a copy of the particles with only new pointers to the rotated properties (by default position and velocity). This means that mutations to other properties will affect both the original particles as well as the rotated copied particles. The properties should be given as a single Symbol, or a vector of Symbols. Only the existing quantities will be rotated (e.g., this method does not throw an error if velocities are not given for the particles).

source
rotate(pc::AbstractParticleCollection, rotmat::AbstractMatrix{<:Real}, prop)
rotate(pc::AbstractParticleCollection, rotmat::AbstractMatrix{<:Real}, props=[:pos, :vel])

Rotates the specified properties props of the particles in the collection by the rotation matrix rotmat.

Creates a copy of the particle collection with only new pointers to the rotated particles (by default position and velocity). The properties should be given as a single Symbol, or a vector of Symbols.

source
LinearAlgebra.rotate!Function
LinearAlgebra.rotate!(p::AbstractParticles, rotmat::AbstractMatrix{<:Real}, props=[:pos, :vel])
LinearAlgebra.rotate!(p::AbstractParticles, rotmat::AbstractMatrix{<:Real}, prop)
LinearAlgebra.rotate!(pc::AbstractParticleCollection, rotmat::AbstractMatrix{<:Real}, props=[:pos, :vel])
LinearAlgebra.rotate!(pc::AbstractParticleCollection, rotmat::AbstractMatrix{<:Real}, prop)

In-place version of rotate.

This function is reexported.

source
CosmoParticles.translateFunction
translate(p::AbstractParticles, Δx, prop::Symbol=:pos)

Translates the specified property of the particles p by Δx.

Creates a copy of the particles with only new pointers to the translated property. Typically, Δx will be an AbstractVector, e.g., for positions or velocities.

source
translate(pc::AbstractParticleCollection, Δx::AbstractVector{<:Number}, prop::Symbol=:pos)

Translates the specified property of the particles in the collection pc by Δx.

Creates a copy of the particle collection with only new pointers to the translated properties for the particles. Typically, Δx will be an AbstractVector, e.g., for positions or velocities.

source
CosmoParticles.translate_periodicFunction
translate_periodic(p::AbstractParticles, centerpos, period, prop::Symbol=:pos)
translate_periodic(pc::AbstractParticleCollection, centerpos, period, prop::Symbol=:pos)

Translates the specified property of the particles or collection by the period such that all particles are the closest to centerpos as possible.

Creates a copy of the particles or the collection with only new pointers to the translated property. Typically, centerpos will be an AbstractVector, e.g., for positions, and period can be a Number or AbstractVector, depending on if the period is the same for all dimensions or if they are different.

source
CosmoParticles.translate_periodic_to_centerFunction
translate_periodic_to_center(p::AbstractParticles, centerpos, period, prop::Symbol=:pos)
translate_periodic_to_center(pc::AbstractParticleCollection, centerpos, period, prop::Symbol=:pos)

Translates the specified property of the particles or collection to place centerpos at the origin.

The particles are translated periodically to place them closest to centerpos.

Creates a copy of the particles or the collection with only new pointers to the translated property. Typically, centerpos will be an AbstractVector, e.g., for positions, and period can be a Number or AbstractVector, depending on if the period is the same for all dimensions or if they are different.

Also see translate_periodic.

source
CosmoParticles.to_comovingFunction
to_comoving(p::AbstractParticles, z::Real; propexp=[(:pos, 1), (:vel, 1)])
to_comoving(pc::AbstractParticleCollection; propexp=[(:pos, 1), (:vel, 1)])

Create new particles or collection with particle properties converted from physical to comoving.

The properties and the positional exponent of their units (e.g., 1 for positions, 3 for volumes, and -3 for densities) are passed as the keyword argument propexp as a vector of tuples. The redshift z is obtained from redshift for the particle collection.

The properties are multiplied by $(1 + z)^n$ where $n$ is the positional exponent.

source
CosmoParticles.to_comoving!Function
to_comoving!(p::AbstractParticles, z::Real; propexp=[(:pos, 1), (:vel, 1)])
to_comoving!(pc::AbstractParticleCollection; propexp=[(:pos, 1), (:vel, 1)])

Convert particle properties from physical to comoving in-place.

In-place version of to_comoving.

source
CosmoParticles.to_physicalFunction
to_physical(p::AbstractParticles, z::Real; propexp=[(:pos, 1), (:vel, 1)])
to_physical(pc::AbstractParticleCollection; propexp=[(:pos, 1), (:vel, 1)])

Create new particles or collection with particle properties converted from comoving to physical.

The properties and the positional exponent of their units (e.g., 1 for positions, 3 for volumes, and -3 for densities) are passed as the keyword argument propexp as a vector of tuples. The redshift z is obtained from redshift for the particle collection.

The properties are multiplied by $(1 + z)^{-n}$ where $n$ is the positional exponent.

source
CosmoParticles.to_physical!Function
to_physical!(p::AbstractParticles, z::Real; propexp=[(:pos, 1), (:vel, 1)])
to_physical!(pc::AbstractParticleCollection; propexp=[(:pos, 1), (:vel, 1)])

Convert particle properties from comoving to physical in-place.

In-place version of to_physical.

source

Further Operations

Base.sortFunction
Base.sort(p::AbstractParticles, prop::Symbol; affect=keys(p), kwargs...)

Create new particles with the particles sorted according to the specified property.

All property arrays of the particles are rearranged according to the property being sorted. If the keyword argument affect is a non-empty vector of Symbols, only those properties are rearranged and added to the newly created particles object. The other keyword arguments are passed on to Base.sortperm.

The sorting algorithm for unitful properties may also be RadixSort from SortingAlgorithms.jl.

source
Base.sort(pc::AbstractParticleCollection, prop::Symbol; [affect,] kwargs...)

Create new particle collection with the particles in the collection sorted by calling Base.sort on each of the particles objects.

If the keyword argument affect is a non-empty vector of Symbols, only the affected properties are kept for the particles. The specified affected properties do not have to be available for all particles. For collections of Particles, affect can alternatively be a vector of tuples in the following form: [(:dm, [:id, :pos, :mass]), (:gas, [:id, :pos, :mass, :temp])].

source
Base.sort!Function
Base.sort!(p::AbstractParticles, prop::Symbol; kwargs...)

Sort the particles in-place according to the specified property.

All property arrays of the particles are rearranged in-place according to the property being sorted. The keyword arguments are passed on to Base.sortperm.

The sorting algorithm for unitful properties may also be RadixSort from SortingAlgorithms.jl.

source
Base.sort!(pc::AbstractParticleCollection, prop::Symbol; kwargs...)

Sort the particles in the collection in-place by calling Base.sort! on each of the Particles objects.

source
Base.filterFunction
Base.filter(f, p::AbstractParticles; affect=keys(p))
Base.filter(f, pc::AbstractParticleCollection[; affect])

Create new particles or collection with the particles filtered by a mask returned by the function f.

The function f takes the particles as argument and has to either return a BitArray mask with a length of the number of particles or an array of indices. If the keyword argument affect is a non-empty vector of Symbols, only those properties are filtered and added to the newly created particles object.

For collections of Particles, affect can alternatively be a vector of tuples in the following form: [(:dm, [:id, :pos, :mass]), (:gas, [:id, :pos, :mass, :temp])].

source
Base.filter(p::AbstractParticles, ids; affect=keys(p))
Base.filter(pc::AbstractParticleCollection; ids[, affect])

Create new particles or collection with them filtered by keeping only the particles with the given IDs.

If the keyword argument affect is a non-empty vector of Symbols, only those properties are filtered and added to the newly created particles object.

For collections of Particles, affect can alternatively be a vector of tuples in the following form: [(:dm, [:id, :pos, :mass]), (:gas, [:id, :pos, :mass, :temp])].

source
Base.filter(p::AbstractParticles, geo::AbstractCosmoGeometry, prop::Symbol=:pos; affect=keys(p))
Base.filter(pc::AbstractParticleCollection, geo::AbstractCosmoGeometry, prop::Symbol=:pos[; affect])

Create new particles or collection with them filtered by keeping only the particles inside the given AbstractCosmoGeometry.

The geometry filter is applied to the property specified. If the keyword argument affect is a non-empty vector of Symbols, only those properties are filtered and added to the newly created particles object.

For collections of Particles, affect can alternatively be a vector of tuples in the following form: [(:dm, [:id, :pos, :mass]), (:gas, [:id, :pos, :mass, :temp])].

source
Base.filter!Function
Base.filter!(f, p::AbstractParticles)
Base.filter!(f, pc::AbstractParticleCollection)

Filter the particles or collection in-place by masks returned by the function f.

The function f takes a particles object as argument and has to either return a BitArray mask with a length of the number of particles or an array of indices.

source
Base.filter!(p::AbstractParticles; ids)
Base.filter!(pc::AbstractParticleCollection; ids)

Filter the particles or collection in-place by keeping only the particles with the given IDs.

source
Base.filter!(p::AbstractParticles, geo::AbstractCosmoGeometry, prop::Symbol=:pos)
Base.filter!(pc::AbstractParticleCollection, geo::AbstractCosmoGeometry, prop::Symbol=:pos)

Filter the particles or collection in-place by keeping only the particles inside the given AbstractCosmoGeometry.

The geometry filter is applied to the property specified.

source
Missing docstring.

Missing docstring for Base.delete. Check Documenter's build log for details.

Base.delete!Function
Base.delete!(p::AbstractParticles; ids)
Base.delete!(pc::AbstractParticleCollection; ids)

Filter the particles or collection in-place by removing all particles with the given IDs.

source
Base.delete!(p::AbstractParticles, geo::AbstractCosmoGeometry, prop::Symbol=:pos)
Base.delete!(pc::AbstractParticleCollection, geo::AbstractCosmoGeometry, prop::Symbol=:pos)

Filter the particles or collection in-place by keeping only the particles outside the given AbstractCosmoGeometry.

The geometry filter is applied to the property specified.

source
CosmoParticles.applyindFunction
CosmoParticles.applyind(p::AbstractParticles, ind::Union{AbstractVector,Colon}; affect=keys(p))

Create new particles with the given indices or mask applied to all particle properties.

This can also be called by the simple syntax p[ind]. If the keyword argument affect is a vector of Symbols, only those properties are indexed into and added to the newly created particles object.

This is not exported.

source
CosmoParticles.applyind!Function
CosmoParticles.applyind!(p::AbstractParticles, ind::Union{AbstractVector,Colon})

In-place application of indices or mask to all particle properties.

This is not exported.

source
CosmoParticles.removeindFunction
CosmoParticles.removeind(p::AbstractParticles, ind::AbstractVector; affect=keys(p))

Create new particles without the given indices or mask applied to all particle properties.

This can also be called by the simple syntax p[ind]. If the keyword argument affect is a vector of Symbols, only those properties are indexed into and added to the newly created particles object.

This is not exported.

source
CosmoParticles.removeind!Function
CosmoParticles.removeind!(p::AbstractParticles, ind::AbstractVector)

In-place removal of indices to all particle properties.

This is not exported.

source
CosmoParticles.findall_inFunction
CosmoParticles.findall_in(a::AbstractVector, set)

Return all indices of a that are in set.

If both a and set are sorted AbstractVectors, then the optimized findall_in_sorted is called. Otherwise, a Set is constructed from the Vector to perform the checks with in.

This is not exported.

source
CosmoParticles.findall_in_sortedFunction
CosmoParticles.findall_in_sorted(a::AbstractVector, set::AbstractVector)

Return all indices of a that are in set, where both a and set are assumed to be sorted.

This uses an optimized algorithm that is faster than creating a Set from set and performing checks with in.

This is not exported.

source

Internals

CosmoParticles.matrix_rotateFunction
CosmoParticles.matrix_rotate(vals::AbstractMatrix{<:Number}, rotmat::AbstractMatrix{<:Real})

Returns vals rotated by the rotation matrix rotmat by regular matrix multiplication. Works for any dimensions and is optimized for unitful arrays.

This is not exported.

source
CosmoParticles._applyindFunction
CosmoParticles._applyind(a, ind::Union{AbstractVector,Colon})

Apply indices or mask to a Number, Vector, or Matrix.

Other possible types: Nothing

The following indexing is applied:

  • a::Number: a is returned directly.
  • a::Vector: a[ind] is returned.
  • a::Matrix: a[:, ind] is returned.

This is not exported.

source
CosmoParticles._removeindFunction
CosmoParticles._removeind(a, ind::AbstractVector)

Remove indices of a Number, Vector, or Matrix.

The vector ind has to contain sorted and unique indices: sort!(unique!(ind)). Additionally, all elements in ind have to be valid indices in a.

Other possible types: Nothing

The following indexing is applied:

  • a::Number: a is returned directly.
  • a::Vector: a[Not(ind)] is returned.
  • a::Matrix: a[:, Not(ind)] is returned.

This is not exported.

source
CosmoParticles._translate_periodicFunction
_translate_periodic(x::Number, x₀::Number, period::Number, period_half::Number=1//2*period)

Returns the coordinate x shifted by the period if reference coordinate x₀ is on the other side.

For periodic simulation boxes, the period corresponds to the boxlength.

This is not exported.

source