Data Acquisition Functions
GADGETPlotting.get_age — Method
get_age(snapshot::String, time::Unitful.Quantity; <keyword arguments>)::Dict{String,Any}Get the ages of the stars at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.time::Unitful.Quantity: Clock time ofsnapshot, with units. All available time units in Unitful.jl and UnitfulAstro.jl can be used.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
snap_0::String = "": Path to the fist snapshot. Only relevant for cosmological simulations (sim_cosmo= 1).filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.
Returns
- A dictionary with two entries.
"ages"⟹ The ages of the stars."unit"⟹ The unit of time used.
GADGETPlotting.get_birth_place — Method
get_birth_place(
snap_index::Int64,
snap_files::Vector{String},
time_stamps::Vector{Float64},
stamps_unit::Unitful.FreeUnits;
<keyword arguments>
)::Dict{String, Any}Get the birth location of the stars in a given snapshot.
Arguments
snap_index::Int64: Index insnap_filesof the snapshot whose stars will be located.snap_files::Vector{String}: Output of the functionget_snapshot_pathcorresponding to the key"snap_files", containing an Array with the paths to the snapshots.time_stamps::Vector{Float64}: Clock time of every snapshot insnap_files.stamps_unit::Unitful.FreeUnits: Unit of time of thetime_stamps.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.length_unit::Unitful.FreeUnits = UnitfulAstro.kpc: Unit of length to be used in the output, all available length units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A 2 dimensional arrays with the positions of the stars. Each row is a star and each column corresponds to coordinates x, y and z respectively.
GADGETPlotting.get_cpu_txt — Method
get_cpu_txt(
source_path::String,
target::String;
<keyword arguments>
)::Dict{String, Matrix{Float64}}Get the data from the cpu.txt file.
For the row in target a matrix with all the CPU usage data (as percentages of total CPU time) is returned.
Arguments
source_path::String: Path to the directory containing the cpu.txt file.target::String: Target process.step::Int64 = 1: Step used to traverse the CPU cycles, i.e. one everystepcycles is returned.
Returns
- A dictionary with one entry.
- process ⟹ Matrix with CPU cycles as its first column, and CPU usage (in percentage) as its second column.
GADGETPlotting.get_cpu_txt — Method
get_cpu_txt(
source_path::String,
targets::Vector{String};
<keyword arguments>
)::Dict{String, Matrix{Float64}}Get the data from the cpu.txt file.
For each target row in targets a matrix with all the CPU usage data (as percentages of total CPU time) is returned.
Arguments
source_path::String: Path to the directory containing the cpu.txt file.targets::Vector{String}: Target processes.step::Int64 = 1: Step used to traverse the CPU cycles, i.e. one everystepcycles is returned.
Returns
- A dictionary with as many entries as strings in
targets.- process ⟹ Matrix with CPU cycles as its first column, and CPU usage (in percentage) as its second column.
GADGETPlotting.get_density — Method
get_density(snapshot::String; <keyword arguments>)::Dict{String,Any}Get the densities of the gas particles at a specific time step.
Arguments
snapshot::String: Path to the snapshot file.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.density_unit::Unitful.FreeUnits = UnitfulAstro.Msun / UnitfulAstro.kpc^3: Unit of density to be used in the output, all available density units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with two entries.
"density"⟹ Densities of the gas particles."unit"⟹ The unit of density used, i.e. is a pass-through ofdensity_unit.
GADGETPlotting.get_fatom — Method
get_fatom(snapshot::String; <keyword arguments>)::Vector{Float64}Get the fraction of atomic gas of each particle at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.
Returns
- Vector with fraction of atomic gas of each particle
GADGETPlotting.get_fmol — Method
get_fmol(snapshot::String; <keyword arguments>)::Vector{Float64}Get the fraction of molecular gas of each particle at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.
Returns
- Vector with fraction of molecular gas of each particle
GADGETPlotting.get_hsml — Method
get_hsml(snapshot::String; <keyword arguments>)::Dict{String,Any}Get the smoothing lengths of the gas particles at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.length_unit::Unitful.FreeUnits = UnitfulAstro.kpc: Unit of length to be used in the output, all available length units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with two entries.
"hsml"⟹ Smoothing lengths of the gas particles."unit"⟹ The unit of length used, i.e. is a pass-through oflength_unit.
GADGETPlotting.get_mass — Method
get_mass(snapshot::String, type::String; <keyword arguments>)::Dict{String,Any}Get the mass of all the particles at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.type::String: Particle type.- "gas" ⟶ Gas particle.
- "dark_matter" ⟶ Dark matter particle.
- "stars" ⟶ Star particle.
sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.mass_unit::Unitful.FreeUnits = UnitfulAstro.Msun: Unit of mass to be used in the output, all available mass units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with three entries.
"mass"⟹ Masses of the particles."unit"⟹ The unit of mass used, i.e. is a pass-through ofmass_unit."type"⟹ Particle type, i.e. is a pass-through oftype.
GADGETPlotting.get_metal_mass — Method
get_metal_mass(snapshot::String, type::String; <keyword arguments>)::Dict{String,Any}Get the mass of several elements within each particle at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.type::String: Particle type.- "gas" ⟶ Gas particle.
- "stars" ⟶ Star particle.
sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.mass_unit::Unitful.FreeUnits = UnitfulAstro.Msun: Unit of mass to be used in the output, all available mass units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with two entries.
"Z"⟹ Matrix where each row is an element, and each column a particle.- 01: He (Helium)
* 02: C (Carbon)
* 03: Mg (Magnesium)
* 04: 0 (Oxygen)
* 05: Fe (Iron)
* 06: Si (Silicon)
* 07: H (Hydrogen)
* 08: N (Nitrogen)
* 09: Ne (Neon)
* 10: S (Sulfur)
* 11: Ca (Calcium)
* 12: Zn (Zinc)"unit"⟹ The unit of mass used, i.e. is a pass-through ofmass_unit."type"⟹ Particle type, i.e. is a pass-through oftype.
GADGETPlotting.get_metallicity — Method
get_metallicity(snapshot::String, type::String; <keyword arguments>)::Dict{String,Any}Get the metallicity of the particles at a specific time step. With metallicity define as the total mass of all elements except Hydrogen and Helium.
Arguments
snapshot::String: Path to a given snapshot.type::String: Particle type.- "gas" ⟶ Gas particle.
- "stars" ⟶ Star particle.
sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.mass_unit::Unitful.FreeUnits = UnitfulAstro.Msun: Unit of mass to be used in the output, all available mass units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with two entries.
"Z"⟹ Metallicities of the particles."unit"⟹ The unit of mass used, i.e. is a pass-through ofmass_unit."type"⟹ Particle type, i.e. is a pass-through oftype.
GADGETPlotting.get_position — Method
get_position(snapshot::String; <keyword arguments>)::Dict{String, Any}Get the coordinates of all the particles at a specific time step.
Arguments
snapshot::String: Path to a given snapshot.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
center::Union{String, Nothing} = nothing: How to adjust the center of mass.- nothing: No adjustments to the center of mass are made.
- "local": Each type of particle gets its center of mass to (0, 0, 0) independently.
- "baryon": Baryons and dark matter get their centers of mass to (0, 0, 0) independently.
- "global": The center of mass of the whole system gets to (0, 0, 0).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.box_size::Unitful.Quantity = 1000.0UnitfulAstro.kpc: Size of the plotting region if vacuum boundary conditions were used. It has to have units but they don't have to be the same aslength_unit.length_unit::Unitful.FreeUnits = UnitfulAstro.kpc: Unit of length to be used in the output, all available length units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with six entries.
"gas","dark_matter","stars"⟹ 2 dimensional arrays with the positions of the particles of the type given by the key. Each row is a particle and each column correspond to coordinates x, y and z respectively."box_size"⟹ The range of values for the plotting of the positions, i.e. a range of ±box_sizeif vacuum boundary conditions were used, or (0,header.boxsize) if periodic boundary conditions were used. Notice how the side length of the region is 2 *box_sizefor vacuum boundary conditions andheader.boxsizefor periodic boundary conditions."periodic"⟹ If the boundary condition are periodic."unit"⟹ The unit of length used, i.e. is a pass-through oflength_unit.
GADGETPlotting.get_sfr_txt — Method
get_sfr_txt(
source_path::String,
snapshot::String;
<keyword arguments>
)::Dict{Union{Int64, String}, Any}Get the column data from the sfr.txt file.
Transform from internal units to the ones given by mass_unit, time_unit and sfr_unit.
Warning
This function takes a modified version of sfr.txt generated by a private version of GADGET3. GADGET4 produces a sfr.txt, but it is not compatible with this function.
Arguments
source_path::String: Path to the directory containing the sfr.txt file.snapshot::String: Path to a particular snapshot file, to use its header.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
mass_unit::Unitful.FreeUnits = UnitfulAstro.Msun: Unit of mass to be used in the output, all available mass units in Unitful.jl and UnitfulAstro.jl can be used.time_unit::Unitful.FreeUnits = UnitfulAstro.Myr: Unit of time to be used in the output, all available time units in Unitful.jl and UnitfulAstro.jl can be used.sfr_unit::Unitful.FreeUnits = UnitfulAstro.Msun / UnitfulAstro.yr: Unit of mass/time to be used in the output, all available time and mass units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with seven entries.
1⟹ The first column (time).2⟹ The second column (total mass - probability).3⟹ The third column (SFR - original GADGET).4⟹ The fourth column (SFR - probability).5⟹ The fifth column (real total mass).6⟹ The sixth column (real SFR)."units"⟹ Units used, i.e. is a pass-through ofmass_unit,time_unitandsfr_unit.
GADGETPlotting.get_snapshot_path — Method
function get_snapshot_path(
base_name::String,
source_path::String,
)::Dict{String, Vector{String}}Find the paths to the GADGET output files, grouping them by snapshot.
Arguments
base_name::String: Base name of the snapshot files, set in the GADGET variableSnapshotFileBase.source_path::String: Path to the directory containing the snapshot files, set in the GADGET variableOutputDir.
Returns
- A dictionary with two entries.
"numbers"⟹ The numbers that characterize each snapshot."snap_files"⟹ The paths to the snapshot files.
GADGETPlotting.get_temperature — Method
get_temperature(snapshot::String; <keyword arguments>)::Dict{String,Any}Get the temperature of the gas particles at a specific time step.
To compute the temperature we use
\[T = (\gamma - 1) \, \frac{e \, m}{k_B} \, ,\]
where $\gamma$ is the adiabatic index, $e$ is the internal energy per unit mass, $m$ the mass per particle (protons and electrons) and $k_B$ is the Boltzmann constant. In particular, we take $\gamma = 5/3$. For how we compute $e$ and $m$ see the comments in the source code of this function.
Arguments
snapshot::String: Path to a given snapshot.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.temp_unit::Unitful.FreeUnits = Unitful.K: Unit of temperature to be used in the output, all available temperature units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary with two entries.
"temperature"⟹ Temperatures of the particles."unit"⟹ The unit of temperature used, i.e. is a pass-through oftemp_unit.
GADGETPlotting.get_time_evolution — Method
get_time_evolution(snap_files::Vector{String}; <keyword arguments>)::Dict{String, Any}Get the time series of several parameters for the whole simulation.
The parameters are:
- "scale_factor"
- "redshift"
- "clock_time" (Physical time)
- "sfr" (SFR)
- "sfr_prob" (SFR probability - Not normalized)
- "gas_number" (Gas particle number)
- "dm_number" (Dark matter particle number)
- "star_number" (Star number)
- "gas_mass" (Total gas mass)
- "dm_mass" (Total dark matter mass)
- "star_mass" (Total star mass)
- "gas_density" (Global gas density)
- "gas_frac" (Gas fraction)
- "dm_frac" (Dark matter fraction)
- "star_frac" (Star fraction)
- "gas_bar_frac" (Baryonic gas fraction)
- "star_bar_frac" (Baryonic star fraction)
Arguments
snap_files::Vector{String}: Output of the functionget_snapshot_pathcorresponding to the key"snap_files", containing an Array with the paths to the snapshots.sim_cosmo::Int64 = 0: Value of the GADGET variableComovingIntegrationOn:- 0 ⟶ Newtonian simulation (static universe).
- 1 ⟶ Cosmological simulation (expanding universe).
filter_function::Function = pass_all: A function with the signature:foo(snap_file::String, type::String)::Vector{Int64}See the function
pass_allfor an example. By default, no particles are filtered.mass_unit::Unitful.FreeUnits = UnitfulAstro.Msun: Unit of mass to be used in the output, all available mass units in Unitful.jl and UnitfulAstro.jl can be used.time_unit::Unitful.FreeUnits = UnitfulAstro.Myr: Unit of time to be used in the output, all available time units in Unitful.jl and UnitfulAstro.jl can be used.sfr_unit::Unitful.FreeUnits = UnitfulAstro.Msun / UnitfulAstro.yr: Unit of mass/time to be used in the output, all available time and mass units in Unitful.jl and UnitfulAstro.jl can be used.length_unit::Unitful.FreeUnits = UnitfulAstro.kpc: Unit of length to be used in the output, all available length units in Unitful.jl and UnitfulAstro.jl can be used.density_unit::Unitful.FreeUnits = UnitfulAstro.Msun / UnitfulAstro.kpc^3: Unit of density to be used in the output, all available density units in Unitful.jl and UnitfulAstro.jl can be used.
Returns
- A dictionary.
"{property}"⟹ Numeric values of the property in the key (one value per snapshot) for the whole simulation."units"⟹ Units used, for easy piping with other functions."labels"⟹ Labels to be used when plotting the quantities.