API Reference
GadgetIO.AbstractGadgetHeaderGadgetIO.GadgetCubeGadgetIO.GadgetCubeGadgetIO.GadgetCylinderGadgetIO.GadgetShellGadgetIO.GadgetSphereGadgetIO.HaloIDGadgetIO.InfoLineGadgetIO.KeyHeaderGadgetIO.SnapshotHeaderGadgetIO.SubfindHeaderGadgetIO.allocate_data_dictGadgetIO.block_presentGadgetIO.block_presentGadgetIO.check_block_positionGadgetIO.check_block_positionGadgetIO.check_blocksGadgetIO.check_blocksizeGadgetIO.check_blocksize_format1GadgetIO.check_in_cylinderGadgetIO.check_infoGadgetIO.check_infoGadgetIO.check_snapshot_formatGadgetIO.check_subfind_parttype_for_multiple_blocksGadgetIO.construct_matched_dictGadgetIO.convert_headerGadgetIO.convert_string_to_int8GadgetIO.filter_cubeGadgetIO.filter_cylinderGadgetIO.filter_idsGadgetIO.filter_positionsGadgetIO.filter_sphereGadgetIO.filter_subfindGadgetIO.filter_subfindGadgetIO.find_files_for_keysGadgetIO.find_most_massive_haloGadgetIO.find_read_positionsGadgetIO.find_read_positionsGadgetIO.find_read_positionsGadgetIO.get_block_positionsGadgetIO.get_block_positionsGadgetIO.get_block_positions_format1GadgetIO.get_block_positions_format2GadgetIO.get_datatype_nameGadgetIO.get_geometry_box_cornersGadgetIO.get_geometry_box_cornersGadgetIO.get_geometry_box_cornersGadgetIO.get_geometry_box_cornersGadgetIO.get_geometry_centerGadgetIO.get_geometry_centerGadgetIO.get_geometry_centerGadgetIO.get_geometry_centerGadgetIO.get_geometry_maskGadgetIO.get_geometry_maskGadgetIO.get_geometry_maskGadgetIO.get_geometry_maskGadgetIO.get_index_boundsGadgetIO.get_index_listGadgetIO.get_index_list_arrGadgetIO.get_index_list_dictGadgetIO.get_index_list_setGadgetIO.get_infoGadgetIO.get_int8_blocknameGadgetIO.get_int_posGadgetIO.get_keylistGadgetIO.get_pos_block_nameGadgetIO.get_rad_block_nameGadgetIO.get_requested_infoGadgetIO.get_total_particlesGadgetIO.get_total_particlesGadgetIO.global_idxs_to_halo_idGadgetIO.global_idxs_to_halo_idGadgetIO.global_idxs_to_halo_idGadgetIO.halo_ids_to_read_positionsGadgetIO.halo_ids_to_read_positionsGadgetIO.head_to_dictGadgetIO.head_to_dictGadgetIO.head_to_structGadgetIO.head_to_structGadgetIO.join_blocksGadgetIO.load_halo_idsGadgetIO.load_halo_idsGadgetIO.load_read_positionsGadgetIO.parse_balanceGadgetIO.parse_balanceGadgetIO.peano_hilbert_keyGadgetIO.print_blocksGadgetIO.print_blocksGadgetIO.print_performanceGadgetIO.read_all_parttypesGadgetIO.read_blockGadgetIO.read_blockGadgetIO.read_block!GadgetIO.read_block!GadgetIO.read_blocks_filteredGadgetIO.read_blocks_filteredGadgetIO.read_bocknameGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_propGadgetIO.read_halo_prop_and_idGadgetIO.read_halo_prop_and_idGadgetIO.read_headerGadgetIO.read_headerGadgetIO.read_ids_in_haloGadgetIO.read_infoGadgetIO.read_infoGadgetIO.read_info_lineGadgetIO.read_key_blockGadgetIO.read_key_indexGadgetIO.read_keyheaderGadgetIO.read_particles_by_idGadgetIO.read_particles_by_idGadgetIO.read_particles_by_idGadgetIO.read_particles_in_boxGadgetIO.read_particles_in_boxGadgetIO.read_particles_in_boxGadgetIO.read_particles_in_box_peanoGadgetIO.read_particles_in_geometryGadgetIO.read_particles_in_geometryGadgetIO.read_particles_in_geometryGadgetIO.read_particles_in_haloGadgetIO.read_particles_in_haloGadgetIO.read_particles_in_haloGadgetIO.read_particles_in_volumeGadgetIO.read_particles_in_volumeGadgetIO.read_particles_in_volumeGadgetIO.read_pidsGadgetIO.read_positions_from_PH_keysGadgetIO.read_positions_from_keys_filesGadgetIO.read_positions_to_halo_idsGadgetIO.read_snapGadgetIO.read_snapGadgetIO.read_subfindGadgetIO.read_subfindGadgetIO.read_subfindGadgetIO.read_subfind_headerGadgetIO.read_subfind_headerGadgetIO.read_subfind_lengthGadgetIO.reduce_read_positionsGadgetIO.save_halo_idsGadgetIO.save_halo_idsGadgetIO.save_read_positionsGadgetIO.save_read_positionsGadgetIO.select_fileGadgetIO.shift_across_box_borderGadgetIO.snap_to_dictGadgetIO.subfind_block_parttypeGadgetIO.write_blockGadgetIO.write_headerGadgetIO.write_info_block
Exported Functions
GadgetIO.block_present — Functionblock_present(filename::String, blockname::String, blocks::Vector{String}=[""])Checks if a given block is present in the snapshot file, or in the supplied blocks Vector.
GadgetIO.filter_cube — Methodfilter_cube(snap_file::String, corner_lowerleft::Array{<:Real}, corner_upperright::Array{<:Real},
parttype::Integer)Reads positions from snap_file and returns the indices of particles contained in a box defined by corner_lowerleft and corner_upperright.
GadgetIO.filter_cylinder — Methodfilter_cylinder(filename::String, pt1::Array{<:Real}, pt2::Array{<:Real}, r::Real)Reads the positions contained in a file and returns the indices of particles contained in a cylinder defined by the endpoints pt1 and pt2 and radius r.
GadgetIO.filter_ids — Methodfilter_ids(snap_file::String, selected_ids::Vector{<:Integer})Reads IDs from snap_file and returns the indices of particles matching the selected_ids
GadgetIO.filter_subfind — Functionfilter_subfind(sub_base::String, filter_function::Function, files=nothing)Filters all entries in a subfind file that fulfill the 'filter_funcion' requirements and returns a Vector of HaloIDs.
Examples
# load packages
using GadgetIO, GadgetUnits
# define filter function
function find_mvir_gt_1e15(filename)
h = read_header(filename)
GU = GadgetPhysical(h) # unit conversion
# read Mvir and convert to solar masses
M = read_subfind(filename, "MVIR") .* GU.m_msun
return findall(M .> 1.0e15)
end
# basename of subfind output (without .*)
sub_base = /path/to/groups_000/sub_000
# get relevant halos from first 10 files
halo_ids = filter_subfind(sub_base, find_mvir_gt_1e15, 0:9)GadgetIO.find_most_massive_halo — Functionfind_most_massive_halo(filebase::String [, nfiles::Int=1])Reads the selected file and its subfiles and returns position, virial radius and a HaloID object that contains the subfile which contains the most massive halo and the position in the block.
GadgetIO.find_read_positions — Methodfind_read_positions( snap_base::String, geometry::AbstractGadgetGeometry;
parttype::Integer=0,
verbose::Bool=true )Finds the number of particles and their storage location in a snapshot directory that are contained in the space defined by geometry.
GadgetIO.find_read_positions — Methodfind_read_positions( snap_base::String, filter_function::Function)Finds the number of particles and their storage location in a snapshot directory that pass the filter_function.
GadgetIO.get_index_list — Methodget_index_list(list_to_find::Vector{<:Integer}, list_to_check::Vector{<:Integer})Finds the indices at which list_to_check contains elements from list_to_find. If both either of the lists are not sorted it uses a Set lookup, otherwise it uses a Vector forward-search.
GadgetIO.get_total_particles — Methodget_total_particles(h::AbstractGadgetHeader, parttype::Integer)Calculates to total number of particles present in the simulation. Accounts for integer overflow.
GadgetIO.get_total_particles — Methodget_total_particles(h::AbstractGadgetHeader, parttype::Integer)Calculates to total number of particles present in the simulation. Accounts for integer overflow.
GadgetIO.global_idxs_to_halo_id — Methodglobal_idxs_to_halo_id(sub_base::String, idxs::Vector{<:Integer};
parttype::Integer=0)Converts global halo indices to HaloIDs.
GadgetIO.global_idxs_to_halo_id — Methodglobal_idxs_to_halo_id(sub_base::String, offset::Integer, n_to_read::Integer;
parttype::Integer=0)Converts a given number of indices defined by offset and n_to_read to HaloIDs.
GadgetIO.halo_ids_to_read_positions — Methodhalo_ids_to_read_positions(halo_ids::Vector{HaloID})Convert a Vector of HaloIDs to a dictionary of read_positions. To be used with read_blocks_filtered.
GadgetIO.head_to_dict — Methodhead_to_dict(filename::String)Returns the header of a snapshot as a dictionary.
GadgetIO.head_to_struct — Methodhead_to_struct(filename::String)Returns the header of a snapshot as a SnapshotHeader object.
GadgetIO.load_halo_ids — Methodsave_halo_ids(filename::String)Loads a Vector of HaloIDs from a file.
GadgetIO.load_read_positions — Methodload_read_positions(save_file::String)Loads the relevant read-in positions from a binary file.
GadgetIO.parse_balance — Methodparse_balance(filename)Reads the balance.txt log file and returns a tuple of Arrays of (step_number, timing, active).
GadgetIO.print_blocks — Methodprint_blocks(filename::String; verbose::Bool=true)Reads the block names of blocks in a snapshot and returns them in an array. Outputs them to console if verbose=true
GadgetIO.print_performance — Methodprint_performance(filename)Basic info on performance from balance.txt file.
GadgetIO.read_block — Methodread_block(filename::String, block_id::Union{String, Integer};
parttype::Integer=0,
block_position::Integer=-1,
info::Union{Nothing,InfoLine}=nothing,
h::Union{Nothing,SnapshotHeader}=nothing,
offset=0, n_to_read=-1)Reads a block in a snapshot with block_id as a given name or position in the file. Defaults to reading gas particles. Block Names are case sensitive.
Keyword Arguments
parttype: Which particle type to read (0-indexed)0: Gas (default)1: Dark Matter2: Boundary3: Bulge4: Stars5: Black Holes-1: All particle types
block_position: Position of the block in the data file[bytes]. Can be used to speed up IO.info:InfoLinefor the given block. Can be used to speed up IO, or if noINFOblock is present.h:SnapshotHeaderfor given file. Can be used to speed up IO.offset: Adds an offset to start reading the block at a later point. Can be used for sub-IO.n_to_read: How many particles to read. Can be used for sub-IO.
Examples (Format 2)
In case an INFO block is present:
gas_pos = read_block(filename, "POS", parttype=0)If not you need to supply your own InfoLine
pos_info = InfoLine("POS", Float32, 1, [1, 1, 1, 1, 1, 1])
gas_pos = read_block(filename, "POS", info=pos_info, parttype=0)
# Examples (Format 1)
In case you want to read the default blocks:julia gaspos = readblock(filename, 1, parttype=0)
If not you need to supply your own `InfoLine`julia posinfo = InfoLine("", Float32, 1, [1, 1, 1, 1, 1, 1]) gaspos = readblock(filename, 1, info=posinfo, parttype=0) ```
GadgetIO.read_blocks_filtered — Methodread_blocks_filtered( snap_base::String, blocks::Array{String};
filter_function::Union{Function, Nothing}=nothing,
read_positions::Union{Dict, Nothing}=nothing,
parttype::Integer=0, verbose::Bool=true )Reads the specified blocks from all distributed files where particles pass the filter_function, or are given by a Dict of read_positions. For read_positions please see find_read_positions.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, block::AbstractString, i_global::AbstractVector{<:Integer}; verbose::Bool=true)Get halo properties defined by the block for an Array of global indices. Returns an array with the requested block.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, block::AbstractString, haloids::AbstractVector{HaloID}; verbose::Bool=true)Get halo properties defined by the block for an Array of HaloIDs. Returns an array with the requested block.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blockname::AbstractString, haloid::HaloID; verbose::Bool=true)Get halo property from block blockname by halo id. Returns an array or scalar depending on the block type.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blockname::AbstractString, i_global::Integer; verbose::Bool=true)Get halo property from block blockname by global halo index i_global (zero-based index).
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blocks::AbstractVector{<:AbstractString}, i_global::AbstractVector{<:Integer}; verbose::Bool=true)Get halo properties defined by an Array of blocks for an Array of global indices. Please note that this only works if all blocks are of the same halo type. Returns a dictionary with all requested blocks.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blocks::AbstractVector{<:AbstractString}, haloids::AbstractVector{HaloID}; verbose::Bool=true)Get halo properties defined by an Array of blocks for an Array of HaloIDs. Please note that this only works if all blocks are of the same halo type. Returns a dictionary with all requested blocks.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blocks::AbstractVector{<:AbstractString}, haloid::HaloID; verbose::Bool=true)Get halo properties defined by an Array of blocks for a HaloID. Please note that this only works if all blocks are of the same halo type. Returns a dictionary with all requested blocks.
GadgetIO.read_halo_prop — Methodread_halo_prop(sub_base, blocks::AbstractVector{<:AbstractString}, i_global::Integer; verbose::Bool=true)Get halo properties defined by an Array of blocks for a global index. Please note that this only works if all blocks are of the same halo type. Returns a dictionary with all requested blocks.
GadgetIO.read_halo_prop_and_id — Methodread_halo_prop_and_id(sub_base, blockname::AbstractString, i_global::Integer; verbose::Bool=true)Get halo property and HaloID from block blockname by global halo index i_global (zero-based index). nfiles should generally be set to h.num_files, obtained from read_header. When nfiles is not passed, it is read automatically from the header.
GadgetIO.read_header — Methodread_header(filename::String)Reads the header of a snapshot file or file base (without .0, .1, etc.) and returns a SnapshotHeader object.
See also: head_to_struct
GadgetIO.read_ids_in_halo — Methodread_ids_in_halo( sub_base::String, halo::HaloID;
halo_type::Integer=1, verbose::Bool=true)Reads the IDs of all particles contained in a halo.
GadgetIO.read_info — Methodread_info(filename; verbose::Bool=false)Reads the info block of a snapshot and returns the information in an array of InfoLine types. If verbose=true the blocknames are also printed to console.
GadgetIO.read_particles_by_id — Methodread_particles_by_id(snap_base::String, ids::Array{<:Integer},
blocks::Array{String};
parttype::Integer=0, verbose::Bool=true,
pos0::Array{<:Real}=[-1.234, -1.234, -1.234],
r0::Real=0.0)Reads particles filtered by the provided IDs. Returns all requested blocks as entries in a Dict.
GadgetIO.read_particles_by_id — Methodread_particles_by_id(snap_base::String, ids::Array{<:Integer},
block::String;
parttype::Integer=0, verbose::Bool=true,
pos0::Array{<:Real}=[-1.234, -1.234, -1.234],
r0::Real=0.0)Reads particles filtered by the provided IDs. Returns the requested block as an Array.
GadgetIO.read_particles_in_box — Methodread_particles_in_box(filename::String, block::String,
corner_lowerleft::Array{<:Real}, corner_upperright::Array{<:Real};
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true)Like read_particles_in_box but for a single block. Returns the block as an array.
See also: read_particles_in_box
GadgetIO.read_particles_in_box — Methodread_particles_in_box(filename::String, blocks::Vector{String},
corner_lowerleft::Array{<:Real}, corner_upperright::Array{<:Real};
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true)Reads all particles within a box defined by a lower left and upper right corner for a given particle type. Returns a dictionary with all requested blocks. If use_keys=true it uses Peano-Hilbert keys to constrain the read-in, otherwise it uses a brute-force read-in with a filter function. Peano-Hilbert key based read-in is significantly faster.
GadgetIO.read_particles_in_geometry — Methodread_particles_in_geometry( filename::String, block::String,
geometry::AbstractGadgetGeometry;
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true, do_shift_across_box_border::Bool=true)Reads all particles within a space defined by an AbstractGeometry struct for a given particle type. Returns a dictionary with the requested block.
GadgetIO.read_particles_in_geometry — Methodread_particles_in_geometry( filename::String, blocks::Vector{String},
geometry::AbstractGadgetGeometry;
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true, do_shift_across_box_border::Bool=true)Reads all particles within a space defined by an AbstractGeometry struct for a given particle type. Returns a dictionary with all requested blocks. If shift_across_box_border is true, the particles are moved beyond the borders of a periodic box, if false, the periodicity of the box is still accounted for, but the particles' positions are not shifted.
GadgetIO.read_particles_in_halo — Methodread_particles_in_halo(snap_base::String, blocks::Array{String},
sub_base::String, halo::HaloID;
radius::Union{Real,Nothing}=nothing,
rad_scale::Real=1.0, halo_type::Integer=1,
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true)Reads all particles of type parttype that are contained in a halo defined by its HaloID. If radius is given (in simulation units), particles are read within at least this radius times rad_scale. Otherwise, R200, RMEA, or RHMS times rad_scale is used depending on halo_type (1, 1, and 2, respectively). Returns a Dict with each of the blocks as entries.
GadgetIO.read_particles_in_halo — Methodread_particles_in_halo( snap_base::String, block::String,
sub_base::String, halo::HaloID;
kwargs...)Reads all particles of type parttype that are contained in a halo defined by its HaloID. If radius is given (in simulation units), particles are read within at least this radius times rad_scale. Otherwise, R200, RMEA, or RHMS times rad_scale is used depending on halo_type (1, 1, and 2, respectively). Returns an Array with the requested block.
GadgetIO.read_particles_in_volume — Methodread_particles_in_box(filename::String, block::String,
center_pos, radius;
parttype::Integer=0, verbose::Bool=true)Like read_particles_in_volume but for a single block. Returns the block as an array.
See also: read_particles_in_volume
GadgetIO.read_particles_in_volume — Methodread_particles_in_box(filename::String, blocks::Vector{String},
center_pos, radius;
parttype::Integer=0, verbose::Bool=true,
use_keys::Bool=true)Reads all particles within a box encapsulating a volume defined by center position and radius for a given particle type. Returns a dictionary with all requested blocks.
See also: read_particles_in_box
GadgetIO.read_snap — Functionread_snap(filename::String [, blockname::String="", parttype::Integer=-1] )Wrapper function to read snapshot in various ways: filename only: returns the entire snapshot as a dictionary. blockname: Returns only that block. If parttype specified only for that particle type.
Examples
julia> gas_pos = read_snap(filename, "POS", 0)GadgetIO.read_subfind — Methodread_subfind(filename::String, blockname::String, ids::AbstractVector{<:Integer}; return_haloid::Bool=false)Reads the block at the given subfind indices (ids, 0-indexed).
If return_haloid is true, returns a tuple of the block array and the corresponding HaloIDs.
Example
# Read the virial masses of the first four halos in subfind:
mvir = read_subfind(filebase, "MVIR", [0, 1, 2, 3])
# or:
mvir, haloids = read_subfind(filebase, "MVIR", [0, 1, 2, 3]; return_haloid=true)GadgetIO.read_subfind — Methodread_subfind(filename::String, blockname::String)Example
To read e.g. the virial radius of halos use
R_vir = read_subfind(filename, "RVIR")GadgetIO.read_subfind_header — Methodread_subfind_header(filename::String)Reads the header of a subfind file or file base (without .0, .1, etc.) into a SubfindHeader struct.
GadgetIO.save_halo_ids — Methodsave_halo_ids(filename::String, halo_ids::Vector{HaloID})Writes a Vector of HaloIDs to a files.
GadgetIO.save_read_positions — Methodsave_read_positions(save_file::String, read_positions::Dict)Saves the relevant read-in positions to a binary file.
GadgetIO.snap_to_dict — Methodsnap_to_dict(filename::String)Reads whole snapshot into memory and returns a dictionary sorted by particle type and block names. Be cautious with large snapshots!
GadgetIO.write_block — Functionwrite_block(f::IOStream, data,
blockname::String="";
snap_format::Integer=2)Write data to a block to an opened file f.
GadgetIO.write_header — Methodwrite_header(f::IOStream, h::SnapshotHeader; snap_format::Integer=2)Writes the header block to an opened file f.
GadgetIO.write_info_block — Methodwrite_info_block(f::IOStream, info::Vector{InfoLine}; snap_format::Integer=2)Writes the info block to an opened file f.
Exported Types
GadgetIO.AbstractGadgetHeader — TypeAbstractGadgetHeaderAbstract type to unify snapshot and subfind headers.
GadgetIO.GadgetCube — Typestruct GadgetCube{T} <: AbstractGadgetGeometry
corner_lower_left::Vector{T}
corner_upper_right::Vector{T}
endDefines a cube by corner_lower_left and corner_upper_right. To be used for read_particles_in_geometry
GadgetIO.GadgetCube — MethodGadgetCube(center::Vector{T}, side_length::T) where TDefine a GadgetCube by its center and side length.
GadgetIO.GadgetCylinder — Typestruct GadgetCylinder{T} <: AbstractGadgetGeometry
pos_start::Vector{T}
pos_end::Vector{T}
radius::T
endDefines a cylinder by two end points pos_start and pos_start as well as a radius. To be used for read_particles_in_geometry
GadgetIO.GadgetShell — Typestruct GadgetShell{T} <: AbstractGadgetGeometry
center::Vector{T}
radius::T
width::T
endDefines a shell by center, radius and width. Radius is defined to the middle of the shell thickness. To be used for read_particles_in_geometry
GadgetIO.GadgetSphere — Typestruct GadgetSphere{T} <: AbstractGadgetGeometry
center::Vector{T}
radius::T
endDefines a sphere by center and radius. To be used for read_particles_in_geometry
GadgetIO.HaloID — Typestruct HaloID
file::Int64
id::Int64
endStores the subfile that contains the halo in file and the position in the block in id.
GadgetIO.InfoLine — Typestruct InfoLine([ block_name="", data_type=Float32, n_dim=Int32(0),
is_present=zeros(Int32, 6) ])Contains the data of a single entry in the INFO block of a Gadget snapshot.
Fields
| Name | Meaning |
|---|---|
block_name::String | name of the data block, e.g. "POS" |
data_type::DataType | datatype of the block, e.g. Float32 for single precision, Float64 for double |
n_dim::Int32 | number of dimensions of the block, usually 1 or 3 |
is_present::Vector{Int32} | array of flags for which particle type this block is present, |
| e.g. gas only: [ 1, 0, 0, 0, 0, 0 ], | |
| or gas + BHs: [ 1, 0, 0, 0, 0, 1 ] |
GadgetIO.SnapshotHeader — Typemutable struct SnapshotHeader <: AbstractGadgetHeaderContains the data of the HEAD block of a Gadget snapshot.
Fields
| Name | Meaning |
|---|---|
npart::Vector{Int32} | an array of particle numbers per type in this snapshot |
massarr::Vector{Float64} | an array of particle masses per type in this snapshot - if zero: MASS block present |
time::Float64 | time / scale factor of the simulation |
z::Float64 | redshift of the simulation |
flag_sfr::Int32 | 1 if simulation was run with star formation, else 0 |
flag_feedback::Int32 | 1 if simulation was run with stellar feedback, else 0 |
nall::Vector{UInt32} | total number of particles in the simulation |
flag_cooling::Int32 | 1 if simulation was run with cooling, else 0 |
num_files::Int32 | number of snapshots over which the simulation is distributed |
omega_0::Float64 | Omega matter |
boxsize::Float64 | total size of the simulation box |
omega_l::Float64 | Omega dark enery |
h0::Float64 | little h |
flag_stellarage::Int32 | 1 if simulation was run with stellar age, else 0 |
flag_metals::Int32 | 1 if simulation was run with metals, else 0 |
npartTotalHighWord::Vector{UInt32} | If Npart > 1584^3 (>2^32) this contains a high bit: ntotal = npartTotalHighWord*2^32 + nall |
flag_entropy_instead_u::Int32 | 1 if snapshot U field contains entropy instead of internal energy, else 0 |
flag_doubleprecision::Int32 | 1 if snapshot is in double precision, else 0 |
flag_ic_info::Int32 | 1 if initial snapshot file contains an info block, else 0 |
lpt_scalingfactor::Float32 | factor to use second order ic generation |
fill::Vector{Int32} | the HEAD block needs to be filled with zeros to have a size of 256 bytes |
GadgetIO.SubfindHeader — Typestruct SubfindHeaderContains the data of the HEAD block in the subfind output
Fields
| Name | Meaning |
|---|---|
nhalos::Int32 | number of halos in the output file |
nsubhalos::Int32 | number of subhalos in the output file |
nfof::Int32 | number of particles in the FoF |
ngroups::Int32 | number of large groups in the output file |
time::Float64 | time / scale factor of the simulation |
z::Float64 | redshift of the simulation |
tothalos::UInt32 | total number of halos over all output files |
totsubhalos::UInt32 | total number of subhalos over all output files |
totfof::UInt32 | total number of particles in the FoF |
totgroups::UInt32 | 1 if simulation was run with cooling, else 0 |
num_files::Int32 | number of files over which subfind data is distributed |
boxsize::Float64 | total size of the simulation box |
omega_0::Float64 | Omega matter |
omega_l::Float64 | Omega dark enery |
h0::Float64 | little h |
flag_doubleprecision::Int32 | 1 if snapshot is in double precision, else 0 |
flag_ic_info::Int32 | 1 if initial snapshot file contains an info block, else 0 |
Private Functions
GadgetIO.allocate_data_dict — Methodallocate_data_dict( blocks::Array{String}, N_to_read::Integer,
snap_info::Array{InfoLine}, no_mass_block::Bool )Helper function to allocate the data Dict.
GadgetIO.check_block_position — Methodcheck_block_position(filename::String, blocknum::Integer)Helper function to find read positions.
GadgetIO.check_block_position — Methodcheck_block_position(filename::String, blockname::String)Helper function to find read positions.
GadgetIO.check_blocks — Methodcheck_blocks(snap_base::String, blocks::Array{String})Check if all requested blocks are present.
GadgetIO.check_blocksize — Methodcheck_blocksize(f::IOStream, position_before::Integer, blocksize_before::Integer)Checks for integer overflow in the size of the block.
GadgetIO.check_blocksize_format1 — Methodcheck_blocksize_format1(f::IOStream, position_before::Integer, blocksize_before::Integer)Checks for integer overflow in the size of the block.
GadgetIO.check_in_cylinder — Methodcheck_in_cylinder(x, pt1, pt2, r)Checks if a 3D point x is in a cylinder defined by its endpoints pt1 and pt2 and radius r.
GadgetIO.check_info — Methodcheck_info(filename::String, blocknum::Integer)Helper function to assign default InfoLine to the block number if none was given.
GadgetIO.check_info — Methodcheck_info(filename::String, blockname::String)Helper function to read INFO block or construct InfoLine for MASS block, if no INFO block is present. Returns a single InfoLine struct.
GadgetIO.check_snapshot_format — Methodcheck_block_format(filename)Checks which binary format the file is in.
GadgetIO.check_subfind_parttype_for_multiple_blocks — Methodcheck_subfind_parttype_for_multiple_blocks(sub_base, blocks::AbstractVector{<:AbstractString})Checks if all requested blocks are for the same halo type and returns the correct halo type if true.
GadgetIO.construct_matched_dict — Methodconstruct_matched_dict(data_in::Dict{String, Union{Vector{T}, Array{T,2}}},
blocks::Array{String,1}, matched::Array{<:Integer,1}) where TWrite all matching particles to a new dictionary.
GadgetIO.convert_header — Methodconvert_header(h::SnapshotHeader)Converts a SnapshotHeader to a SubfindHeader.
GadgetIO.convert_string_to_int8 — Methodconvert_string_to_int8(name::String)Converts a string to an array of Int8 to write to file.
GadgetIO.filter_positions — Methodfilter_positions(snap_file::String, corner_lowerleft::Array{<:Real}, corner_upperright::Array{<:Real},
parttype::Integer)Reads positions from snap_file and returns the indices of particles contained in a box defined by corner_lowerleft and corner_upperright.
GadgetIO.filter_sphere — Methodfilter_sphere(filename::String, center::Array{<:Real}, r::Real; parttype::Integer=0)Reads the positions contained in a file and returns the indices of particles contained in a cylinder defined by the endpoints pt1 and pt2 and radius r.
GadgetIO.find_files_for_keys — Methodfind_files_for_keys(filebase::String, nfiles::Integer, keylist::Vector{<:Integer})Selects the files in which the particles associated with the given Peano-Hilbert keys are stored.
GadgetIO.get_block_positions — Methodget_block_positions(filename::String;
snap_format::Integer=2)Returns a dictionary with the starting positions of all blocks in a snapshot in bits.
Example
# Format 2 -> default
block_positions = get_block_positions(filename)
block_positions["POS"]
# Format 1
block_positions = get_block_positions(filename)
block_positions[1]GadgetIO.get_block_positions_format1 — Methodget_block_positions_format1(filename::String)Returns a dictionary with the starting positions of all blocks in a snapshot in bits.
Example
block_positions = get_block_positions(filename)
block_positions["POS"]GadgetIO.get_block_positions_format2 — Methodget_block_positions_format2(filename::String)Returns a dictionary with the starting positions of all blocks in a snapshot in bits.
Example
block_positions = get_block_positions(filename)
block_positions["POS"]GadgetIO.get_datatype_name — Methodfunction get_datatype_name(dt::DataType, dim::Integer)Convert the datatype into a string and then to a vector of 8bit integers to match name in Gadget.
GadgetIO.get_geometry_box_corners — Methodget_geometry_box_corners(cube::GadgetCube)Returns a Tuple with the lower left and upper right corner of a box which contains the cube.
GadgetIO.get_geometry_box_corners — Methodget_geometry_box_corners(cylinder::GadgetCylinder)Returns a tuple with the lower left and upper right corner of a box which contains the cylinder.
GadgetIO.get_geometry_box_corners — Methodget_geometry_box_corners(shell::GadgetShell)Returns a tuple with the lower left and upper right corner of a box which contains the shell.
GadgetIO.get_geometry_box_corners — Methodget_geometry_box_corners(sphere::GadgetSphere)Returns a tuple with the lower left and upper right corner of a box which contains the sphere.
GadgetIO.get_geometry_center — Methodfunction get_geometry_center(sphere::GadgetCube)Returns the center of cube.
GadgetIO.get_geometry_center — Methodfunction get_geometry_center(cylinder::GadgetCylinder)Returns the center of cylinder.
GadgetIO.get_geometry_center — Methodfunction get_geometry_center(shell::GadgetShell)Returns the center of shell.
GadgetIO.get_geometry_center — Methodfunction get_geometry_center(sphere::GadgetSphere)Returns the center of sphere.
GadgetIO.get_geometry_mask — Methodget_geometry_mask(cube::GadgetCube, pos::Matrix{T}) where TReturns the indices of all particles contained in the cube.
GadgetIO.get_geometry_mask — Methodget_geometry_mask(cylinder::GadgetCylinder, pos::Matrix{T}) where TReturns the indices of all particles contained in the cylinder.
GadgetIO.get_geometry_mask — Methodget_geometry_mask(shell::GadgetShell, pos::Matrix{T}) where TReturns the indices of all particles contained in the shell.
GadgetIO.get_geometry_mask — Methodget_geometry_mask(sphere::GadgetSphere, pos::Matrix{T}) where TReturns the indices of all particles contained in the sphere.
GadgetIO.get_index_bounds — Methodget_index_bounds(ids::Vector{<:Integer}, low_bounds::Vector{<:Integer}, high_bounds::Vector{<:Integer})Returns sorted Vector of indices i, for which low_bounds[i] ≤ ids[j] ≤ high_bounds[i] for any j. All parameters ids, low_bounds, and high_bounds have to already be sorted.
GadgetIO.get_index_list_arr — Methodget_index_list_arr(list_to_find::Vector{<:Integer}, list_to_check::Vector{<:Integer})Get positions in list_to_check where list_to_check matches list_to_find. Uses forward-searching in sorted array. Both arrays have to be sorted.
GadgetIO.get_index_list_dict — Methodget_index_list_dict(list_to_find::Vector{<:Integer}, list_to_check::Vector{<:Integer})Get positions in list_to_check where list_to_check matches list_to_find. Uses a Dict for lookup -> slower than the array search, but works on unsorted arrays.
GadgetIO.get_index_list_set — Methodget_index_list_set(list_to_find::Vector{<:Integer}, list_to_check::Vector{<:Integer})Get positions in list_to_check where list_to_check matches list_to_find. Uses a Set for lookup -> slower than the array search get_index_list_arr, but works on unsorted arrays like get_index_list_dict, just faster.
GadgetIO.get_info — Methodget_info(info::AbstractVector{InfoLine}, blockname::String)Helper function to obtain a given InfoLine from a list or construct it for a MASS block, if no INFO block is present. Returns a single InfoLine struct.
GadgetIO.get_int8_blockname — Methodget_int8_blockname(info::InfoLine)Pad the stored block name with spaces and convert to Array of Int8.
GadgetIO.get_int_pos — Methodget_int_pos(pos::Real, domain_corner::Real, domain_fac::Real, bits::Integer)Computes the integer position along the PH line.
GadgetIO.get_keylist — Methodget_keylist(h_key::KeyHeader, x0::Array{<:Real}, x1::Array{<:Real})Get all Peano-Hilbert keys for domain defined by the corner points x0 and x1.
GadgetIO.get_pos_block_name — Methodfunction get_pos_block_name(halo_type)Returns the position block name depending on the halo type.
GadgetIO.get_rad_block_name — Methodfunction get_rad_block_name(sub_file, halo_type)Returns the radius block name depending on the halo type.
GadgetIO.get_requested_info — Methodget_requested_info(snap_info::Array{InfoLine}, block::AbstractString)Checks if the InfoLine is present for the requested block, or if the MASS block is requested, but not in the INFO block.
GadgetIO.join_blocks — Methodjoinblocks(offsetkey, partperkey)
Joins neighboring blocks to simplify read-in.
GadgetIO.peano_hilbert_key — Methodpeano_hilbert_key(bits::Integer, x::Integer, y::Integer, z::Integer)Computes a Peano-Hilbert key for an integer triplet (x,y,z) with x,y,z typically in the range between 0 and 2^bits-1. Values outside this range can occur when reading across the periodic box borders.
GadgetIO.read_all_parttypes — Methodread_all_parttypes( filename::String, block_id::String;
block_position::Integer=-1,
info::Union{Nothing,InfoLine}=nothing,
h::Union{Nothing,SnapshotHeader}=nothing)Reads the requested block for all particle types.
GadgetIO.read_block! — Functionread_block!(a::AbstractArray, f::IOStream,
offset::Integer,
nread::Integer, n_to_read::Integer;
parttype::Integer,
block_position::Integer,
info::InfoLine,
h::SnapshotHeader)Read part of a block from a given file stream into a pre-allocated array.
GadgetIO.read_block! — Methodread_block!(a::AbstractArray, f::IOStream,
offset::Array{<:Integer},
nread::Integer, n_to_read::Array{<:Integer};
parttype::Integer,
block_position::Integer,
info::InfoLine,
h::SnapshotHeader)Read part of a block from a given file stream into a pre-allocated array.
GadgetIO.read_bockname — Methodread_bockname(f::IOStream)Reads the name of the Format 2 block.
GadgetIO.read_info_line — Methodread_info_line(f::IOStream)Helper function to read the binary data into a InfoLine struct.
GadgetIO.read_key_block — Methodread_key_block( filename_keyfile::String, key_info::Vector{InfoLine},
fields::Vector{String}, key::String, parttype::Integer)Returns key block for different key. Valid values of key: KEY, NKEY, OKEY
GadgetIO.read_key_index — Methodread_key_index(file_key_index::String)Reads the .key.index file.
GadgetIO.read_keyheader — Methodread_keyheader(filename::String)Reads the header of a .key file.
GadgetIO.read_particles_in_box_peano — Methodread_particles_in_box_peano(filename::String, blocks::Vector{String},
corner_lowerleft::Array{<:Real}, corner_upperright::Array{<:Real};
parttype::Integer=0, verbose::Bool=true)Reads all particles within a box defined by a lower left and upper right corner for a given particle type based on peano hilbert key reading. Returns a dictionary with all requested blocks.
GadgetIO.read_pids — Methodread_pids(sub_base::String, N_ids::Signed, offset::Signed)Reads the PID block in the subfind output.
GadgetIO.read_positions_from_PH_keys — Methodread_positions_from_PH_keys(filebase::String,
corner_lowerleft::Array{<:Real},
corner_upperright::Array{<:Real};
parttype::Integer, verbose::Bool)Finds the Peano-Hilbert keys in a cube defined by corner_lowerleft and corner_upperright.
GadgetIO.read_positions_from_keys_files — Methodread_positions_from_PH_keys(files::Vector{<:Integer}, filebase::String,
blocks::AbstractVector{String}, parttype::Integer,
keylist::Vector{<:Integer}, key_info::Vector{InfoLine},
verbose::Bool)Helper function to get positions and length of particle blocks in files.
GadgetIO.read_positions_to_halo_ids — Methodread_positions_to_halo_ids(read_positions)Converts read_positions to a Vector of HaloIDs.
GadgetIO.read_subfind_length — Methodread_subfind_length(filename::String, blockname::String)Get number of entries for block blockname. Uses the header, so it is faster than reading the whole block.
GadgetIO.reduce_read_positions — Methodreduce_read_positions(sel::Array{<:Integer})Reduces the individual read positions by finding sub-ranges. Returns an array of read indices and an array with the number of entries per index.
GadgetIO.select_file — Methodselect_file(filebase::String, filenum::Integer)Checks if the requested files exists and returns the path.
GadgetIO.shift_across_box_border — Methodshift_across_box_border(x::Real, x_halo::Real, boxsize::Real, boxsize_half::Real)Shift coordinate x across the box border if the zero coordinate x₀ is on the other side.
GadgetIO.subfind_block_parttype — Functionsubfind_block_parttype(filename, blockname)Get the particle type for which a subfind block is relevant.
Private Types
GadgetIO.KeyHeader — Typestruct KeyHeaderHelper struct to store header information of .key files.
Fields
| Name | Meaning |
|---|---|
nkeys_file | Number of keys in this .key file |
domain_corners | Corners of the domains defined by these keys |
domain_fac | Factor needed for reconstructung int positions |
bits | Size of PH keys it bits |
nkeys_total | Total number of keys in all files |
nkeys_total_highword | Total number of keys in all files |