Data acquisition functions

These functions are used internally and none are exported.

These functions depend on the particulars of the simulation code (e.g. units).

These function read the different output files from the simulation (snapshots, FoF catalogs, sfr.txt, etc.), and load the data into memory as dictionaries.


GalaxyInspector.addRequestMethod
addRequest(
    request::Dict{Symbol,Vector{String}},
    addition::Dict{Symbol,Vector{String}},
)::Dict{Symbol,Vector{String}}

Add the blocks in addition to request, only for the types already present in request.

Arguments

  • request::Dict{Symbol,Vector{String}}: The request dictionary for readSnapshot.
  • addition::Dict{Symbol,Vector{String}}: Request dictionary with the blocks to be added, only for the types already present in request.

Returns

  • A new dictionary with all the requests.
source
GalaxyInspector.countSnapshotMethod
countSnapshot(simulation_path::String)::Int

Count the number of snapshots in simulation_path.

Note

This function count the number of snapshots, no the number of snapshot files. So if each snapshot is made of more than one files, the count will not change.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.

Returns

  • The number of snapshots.
source
GalaxyInspector.countStarsMethod
countStars(path::String)::Int

Count the number of stars in a snapshot, excluding wind particles.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • The number of stars.
source
GalaxyInspector.findQtyExtremaMethod
findQtyExtrema(
    simulation_path::String,
    slice_n::Int,
    component::Symbol,
    block::String;
    <keyword arguments>
)::NTuple{2,<:Number}

Compute the minimum and maximum values of block.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.

  • slice_n::Int: Selects which snapshot to plot, starts at 1 and is independent of the number in the file name. If every snapshot is present, the relation is slice_n = (number in filename) + 1. If set to a negative number, the values in the whole simulation will be compared.

  • component::Symbol: Cell/particle type. The possibilities are the keys of PARTICLE_INDEX.

  • block::String: Target block. The possibilities are the keys of QUANTITIES.

  • f::Function=identity: A function with the signature:

    f(data) -> values

    where

    • data::VecOrMat{<:Number}: Data returned by getBlock.
    • values::Vector{<:Number}: A vector with the values to be compared.

Returns

  • Tuple with the minimum and maximum values.
source
GalaxyInspector.findRealStarsMethod
findRealStars(path::String)::Vector{Bool}

Find which stellar particles are real stars and not wind particles.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • A boolean vector with true for stars and false for wind particles.
source
GalaxyInspector.getBlockMethod
getBlock(path::String, component::Symbol, block::String)::VecOrMat{<:Number}

Convenience function to directly get the data associated with one block.

Arguments

  • path::String: Path to the snapshot file or folder.
  • component::Symbol: Type of cell/particle. The possibilities are the keys of PARTICLE_INDEX.
  • block::String: Target block. The possibilities are the keys of QUANTITIES.

Returns

  • The data for block.
source
GalaxyInspector.getGroupCatPathsMethod
getGroupCatPaths(simulation_path::String)::Dict{Symbol,Vector{String}}

Find the path and number of every group catalog in simulation_path.

Note

If each group catalog is made of multiple files, the :paths field will have paths to folders, each one containing the sub-files of the corresponding group catalog.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.

Returns

  • A dictionary with the following shape:

    • :numbers -> The number that characterize each group catalog.
    • :paths -> The full path to each group catalog.
source
GalaxyInspector.getSnapshotPathsMethod
getSnapshotPaths(simulation_path::String)::Dict{Symbol,Vector{String}}

Find the path and number of every snapshot in simulation_path.

Note

If each snapshot is made of multiple files, the :paths field will have paths to folders, each one containing the sub-files of the corresponding snapshot.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.

Returns

  • A dictionary with the following shape:

    • :numbers -> The number that characterize each snapshot.
    • :paths -> The full path to each snapshot.
source
GalaxyInspector.groupcatTypesMethod
groupcatTypes(data_dict::Dict)::Vector{Symbol}

Find which group catalog data types are part of the keys of data_dict.

Arguments

  • data_dict::Dict: A dictionary.

Returns

  • A vector with the group catalog data types.
source
GalaxyInspector.groupcatTypesMethod
groupcatTypes(path::String)::Vector{Symbol}

Find which group catalog data types are part of the snapshot in path.

Note

If each snapshot is made of multiple files, the function will check the first chunk.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • A vector with the group catalog data types.
source
GalaxyInspector.internalUnitsMethod
internalUnits(quantity::String, path::String)::Union{Unitful.Quantity,Unitful.Units}

Get the factor to convert a plain number into a Unitful quantity, using the correct internal code units.

Arguments

  • quantity::String: Target quantity. The options are the keys of QUANTITIES.
  • path::String: Path to the snapshot file or folder.

Returns

source
GalaxyInspector.isBlockPresentMethod
isBlockPresent(block::String, group::HDF5.Group)::Bool

Checks if a given data block exists in a HDF5 group.

Arguments

  • block::String: Target block. The possibilities are the keys of QUANTITIES.
  • group::HDF5.Group: HDF5 group.

Returns

  • If block exists in group.
source
GalaxyInspector.isBlockPresentMethod
isBlockPresent(component::Symbol, block::String, path::String)::Bool

Checks if a given block exists in a snapshot.

Note

If each snapshot is made of multiple files, the function will only check the first chunk.

Arguments

  • component::Symbol: The cell/particle type of the target block. The possibilities are the keys of PARTICLE_INDEX.
  • block::String: Target block. The possibilities are the keys of QUANTITIES.
  • path::String: Path to the snapshot file or folder.

Returns

  • If block exists in the snapshot.
source
GalaxyInspector.isCosmologicalMethod
isCosmological(path::String)::Bool

Check if the snapshot in path comes from a cosmological simulation.

Note

If each snapshot is made of multiple files, the function will read the first chunk to check if the simulation is cosmological.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • If the simulation is cosmological

    • false -> Newtonian simulation (ComovingIntegrationOn = 0, Redshift = 0.0).
    • true -> Cosmological simulation (ComovingIntegrationOn = 1, Redshift != 0.0).
source
GalaxyInspector.isSubfindActiveMethod
isSubfindActive(path::String)::Bool

Check if there is information about the halos and subhalos in the group catalog file.

Arguments

  • path::String: Path to the group catalog file or folder.

Returns

  • If there are halo and subhalo information in the group catalog file.
source
GalaxyInspector.makeDataDictMethod
makeDataDict(
    simulation_path::String,
    slice_n::Int,
    request::Dict{Symbol,Vector{String}},
    simulation_table::DataFrame,
)::Dict

Construct a data dictionary for a single snapshot.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.
  • slice_n::Int: Selects the target snapshot. Starts at 1 and is independent of the number in the file name. If every snapshot is present, the relation is slice_n = (number in filename) + 1.
  • request::Dict{Symbol,Vector{String}}: Dictionary with the shape cell/particle type -> [block, block, ...], where the possible types are the keys of PARTICLE_INDEX, and the possible quantities are the keys of QUANTITIES.
  • simulation_table::DataFrame: Dataframe with the path, time stamps, and number of each snapshot and group catalog file in simulation_path. It must have the same shape as the one returned by makeSimulationTable.

Returns

  • A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
source
GalaxyInspector.makeDataDictMethod
makeDataDict(
    simulation_path::String,
    slice_n::Int,
    request::Dict{Symbol,Vector{String}},
)::Dict

Construct a data dictionary for a single snapshot.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.
  • slice_n::Int: Selects the target snapshot. Starts at 1 and is independent of the number in the file name. If every snapshot is present, the relation is slice_n = (number in filename) + 1.
  • request::Dict{Symbol,Vector{String}}: Dictionary with the shape cell/particle type -> [block, block, ...], where the possible types are the keys of PARTICLE_INDEX, and the possible quantities are the keys of QUANTITIES.

Returns

  • A dictionary with the following shape:

    • :sim_data -> ::Simulation (see Simulation).
    • :snap_data -> ::Snapshot (see Snapshot).
    • :gc_data -> ::GroupCatalog (see GroupCatalog).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • cell/particle type -> (block -> data of block, block -> data of block, ...).
    • ...
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • groupcat type -> (block -> data of block, block -> data of block, ...).
    • ...
source
GalaxyInspector.makeSimulationTableMethod
makeSimulationTable(simulation_path::String)::DataFrame

Construct a dataframe with the path, time stamps and number of each snapshot and group catalog file in simulation_path.

Arguments

  • simulation_path::String: Path to the simulation directory, set in the code variable OutputDir.

Returns

  • A dataframe with 8 columns:

    • :ids -> Dataframe index of each snapshot, i.e. if there are 10 snapshots in total it runs from 1 to 10.
    • :numbers -> Number in the file name of each snapshot.
    • :scale_factors -> Scale factor of each snapshot.
    • :redshifts -> Redshift of each snapshot.
    • :physical_times -> Physical time since the Big Bang of each snapshot.
    • :lookback_times -> Physical time left to reach the last snapshot.
    • :snapshot_paths -> Full path to the snapshots.
    • :groupcat_paths -> Full path to the group catalog files.
source
GalaxyInspector.mergeRequestsMethod
mergeRequests(requests::Dict{Symbol,Vector{String}}...)::Dict{Symbol,Vector{String}}

Merge several request dictionaries, ignoring duplicates.

Arguments

Returns

  • A new dictionary with all the requests.
source
GalaxyInspector.readCpuFileMethod
readCpuFile(
    file_path::String,
    targets::Vector{String};
    <keyword arguments>
)::Dict{String,Matrix{Float64}}

Read the cpu.txt file.

For each process in targets a matrix with all the CPU usage data is returned.

Arguments

  • file_path::String: Path to the cpu.txt file.
  • targets::Vector{String}: Target processes.
  • step::Int=1: Step used to traverse the rows.

Returns

  • A dictionary with the following shape:

    target process -> matrix with columns:

    • Time step.
    • Simulation time (scale factor for cosmological simulations and physical time for non-cosmological simulations).
    • Clock time in seconds.
    • Clock time as a percentage.
    • Total clock time in seconds.
    • Total clock time as a percentage.
source
GalaxyInspector.readGoupCatBlocksMethod
readGoupCatBlocks(
    file_path::String,
    snapshot_path::String,
    request::Dict{Symbol,Vector{String}},
)::Dict{Symbol,Dict{String,VecOrMat{<:Number}}}

Read the specified blocks from a group catalog file.

Arguments

  • file_path::String: Path to the group catalog file.
  • snapshot_path::String: Path to the corresponding snapshot file or folder. This is needed for unit conversion.
  • request::Dict{Symbol,Vector{String}}: The blocks to be read. It must have the shape group type -> [block, block, block].

Returns

  • A dictionary with the following shape: group type -> (block -> data of block).
source
GalaxyInspector.readGroupCatHeaderMethod
readGroupCatHeader(path::Union{String,Missing})::GroupCatHeader

Read the header of a group catalog in the HDF5 format.

Note

If each group catalog is made of multiple files, the function will read the header of the first one.

Arguments

  • path::Union{String,Missing}: Path to the group catalog file or folder.

Returns

source
GalaxyInspector.readGroupCatalogMethod
readGroupCatalog(
    path::Union{String,Missing},
    snapshot_path::String,
    request::Dict{Symbol,Vector{String}},
)::Dict{Symbol,Dict{String,VecOrMat{<:Number}}}

Read the specified blocks from a group catalog file or folder.

Arguments

  • path::Union{String,Missing}: Path to the group catalog file or folder.
  • snapshot_path::String: Path to the corresponding snapshot file or folder. This is needed for unit conversion.
  • request::Dict{Symbol,Vector{String}}: Which blocks will be read. It must have the shape group type -> [block, block, block].

Returns

  • A dictionary with the following shape: group type -> (block -> data of block).
source
GalaxyInspector.readSfrFileMethod
readSfrFile(
    file_path::String,
    snap_path::String,
)::Dict{Int32,VecOrMat{<:Number}}

Read the sfr.txt file.

Arguments

  • file_path::String: Path to the sfr.txt file.
  • snapshot_path::String: Path to one snapshot file or folder of the simulation. This is needed for unit conversion.

Returns

  • A dictionary with the following shape:

    • 1 -> Time or scale factor (internal units).
    • 2 -> Total stellar mass to be formed prior to stochastic sampling (internal units).
    • 3 -> Instantaneous star formation rate of all cells ($\mathrm{M_\odot \, yr^{-1}}$).
    • 4 -> Instantaneous star formation rate of active cells ($\mathrm{M_\odot \, yr^{-1}}$).
    • 5 -> Total mass in stars formed after stochastic sampling (internal units).
    • 6 -> Cumulative stellar mass formed (internal units).
source
GalaxyInspector.readSnapBlocksMethod
readSnapBlocks(
    file_path::String,
    request::Dict{Symbol,Vector{String}},
)::Dict{Symbol,Dict{String,VecOrMat{<:Number}}}

Read the specified blocks from a snapshot file.

Arguments

  • file_path::String: Path to the snapshot file.
  • request::Dict{Symbol,Vector{String}}: The blocks to be read. It must have the shape cell/particle type -> [block, block, block].

Returns

  • A dictionary with the following shape: cell/particle type -> (block -> data of block).
source
GalaxyInspector.readSnapHeaderMethod
readSnapHeader(path::String)::SnapshotHeader

Read the header of a snapshot in the HDF5 format.

Note

If each snapshot is made of multiple files, the function will read the header of the first chunk.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

source
GalaxyInspector.readSnapshotMethod
readSnapshot(
    path::Union{String,Missing},
    request::Dict{Symbol,Vector{String}},
)::Dict{Symbol,Dict{String,VecOrMat{<:Number}}}

Read the specified blocks from a snapshot file or folder.

Arguments

  • path::Union{String,Missing}: Path to the snapshot file or folder.
  • request::Dict{Symbol,Vector{String}}: Which blocks will be read. It must have the shape cell/particle type -> [block, block, block].

Returns

  • A dictionary with the following shape: cell/particle type -> (block -> data of block).
source
GalaxyInspector.readTemperatureMethod
readTemperature(file_path::String)::Vector{<:Unitful.Temperature}

Compute the temperature of the gas cells in a snapshot.

Arguments

  • file_path::String: Path to the snapshot file.

Returns

  • The temperature of the gas cells.
source
GalaxyInspector.readTimeMethod
readTime(path::String)::Float64

Read the "Time" field in the header of a snapshot file.

Note

If each snapshot is made of multiple files, the function will read the header of the first chunk.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • The "Time" field in the header (for cosmological simulations it is the scale factor).
source
GalaxyInspector.snapshotTypesMethod
snapshotTypes(data_dict::Dict)::Vector{Symbol}

Find which cell/particle types are part of the keys of data_dict.

Arguments

  • data_dict::Dict: A dictionary.

Returns

  • A vector with the cell/particle types.
source
GalaxyInspector.snapshotTypesMethod
snapshotTypes(path::String)::Vector{Symbol}

Find which cell/particle types are part of the snapshot in path.

Note

If each snapshot is made of multiple files, the function will check the first chunk.

Arguments

  • path::String: Path to the snapshot file or folder.

Returns

  • A vector with the cell/particle types.
source